All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5/7] [xen-ocaml-tools.hg] get xenstored to compile under minios
@ 2009-04-17 15:44 Alex Zeffertt
  0 siblings, 0 replies; only message in thread
From: Alex Zeffertt @ 2009-04-17 15:44 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 244 bytes --]

   * support OCAMLC_CROSS_PREFIX instead of always linking against ocaml libs on
devel machine
   * caml.o, main-caml.o targets for use by xen-unstable.hg/stubdom/Makefile
   * do not call syslog/closelog on minios as they are not implemented


[-- Attachment #2: minios-stubdom-build --]
[-- Type: text/plain, Size: 12310 bytes --]

Integrate with xen-unstable.hg

Support being checked out under xen-unstable.hg/tools/ and used to build the xenstored
daemon instead of building the C version in xen-unstable.hg/tools/xenstore/.  (Although
xen-unstable.hg/tools/xenstore/ will still be used to build the xenstore clients.)

Also support building xenstored as a stubdomain.  This however depends on the xenstored
stubdomain patch series for xen-unstable.hg and linux-2.6.18-xen.hg, and also the 
ocaml-crosscompile patch for xen-unstable.hg.

After applying this patch
 * this OCAML version of xenstored as a dom0 daemon should still build, and work
 * the OCAML version of the xenstore stubdom should build, but not work (that requires
   a later patch)

Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com>

diff -r d9ac5ae2dbed bottom.make
--- a/bottom.make	Thu Mar 26 16:12:51 2009 +0000
+++ b/bottom.make	Tue Apr 07 16:20:28 2009 +0100
@@ -8,9 +8,6 @@
 
 %.cmx: %.ml
 	$(OCAMLOPT) $(OCAMLOPTFLAGS) -c -o $@ $<
-
-%.o: %.c
-	$(CC) $(CFLAGS) -c -o $@ $<
 
 META: META.in
 	sed 's/@VERSION@/$(VERSION)/g' < $< $o
diff -r d9ac5ae2dbed common.make
--- a/common.make	Thu Mar 26 16:12:51 2009 +0000
+++ b/common.make	Tue Apr 07 16:20:28 2009 +0100
@@ -1,14 +1,20 @@
-CC ?= gcc
-OCAMLOPT ?= ocamlopt
-OCAMLC ?= ocamlc
-OCAMLMKLIB ?= ocamlmklib
-OCAMLDEP ?= ocamldep
-
-CFLAGS = -Wall -fPIC -O2
+-include $(XEN_ROOT)/Config.mk
+CC ?= cc
+OCAMLOPT ?= $(OCAMLC_CROSS_PREFIX)ocamlopt
+OCAMLC ?= $(OCAMLC_CROSS_PREFIX)ocamlc
+OCAMLMKLIB ?= $(OCAMLC_CROSS_PREFIX)ocamlmklib
+OCAMLDEP ?= $(OCAMLC_CROSS_PREFIX)ocamldep
+OCAMLFIND ?= $(OCAMLC_CROSS_PREFIX)ocamlfind
+CAMLLIB = $(shell $(OCAMLC_CROSS_PREFIX)ocamlc -where)
 
 XEN_ROOT ?= $(TOPLEVEL)/../xen-unstable.hg
 XEN_DIST_ROOT ?= $(XEN_ROOT)/dist/install
-CFLAGS += -I$(XEN_DIST_ROOT)/usr/include
+CFLAGS += -Wall -fPIC -O2  -I$(CAMLLIB) -I$(XEN_DIST_ROOT)/usr/include
+
+ifneq ($(CONFIG_STUBDOM),)
+  DEF_CPPFLAGS += -I$(CAMLLIB)
+  CFLAGS += -DHAVE_LIBXC
+endif
 
 OCAMLOPTFLAG_G := $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^  *\(-g\) .*/\1/p')
 OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -dtypes $(OCAMLINCLUDE) -cc $(CC)
@@ -19,8 +25,8 @@
 DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 
-OCAMLABI := $(shell ocamlc -version)
-OCAMLLIBDIR := $(shell ocamlc -where)
+OCAMLABI := $(shell $(OCAMLC_CROSS_PREFIX)ocamlc -version)
+OCAMLLIBDIR := $(shell $(OCAMLC_CROSS_PREFIX)ocamlc -where)
 OCAMLDESTDIR ?= $(OCAMLLIBDIR)
 
 o= >$@.new && mv -f $@.new $@
diff -r d9ac5ae2dbed libs/eventchn/Makefile
--- a/libs/eventchn/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/eventchn/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -26,11 +26,11 @@
 
 .PHONY: install
 install: $(LIBS) META
-	ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore eventchn META $(INTF) $(LIBS) *.a *.so *.cmx
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir) -ldconf ignore eventchn META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-	ocamlfind remove eventchn
+	$(OCAMLFIND) remove eventchn
 
 include $(TOPLEVEL)/bottom.make
 
diff -r d9ac5ae2dbed libs/log/Makefile
--- a/libs/log/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/log/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -34,11 +34,11 @@
 
 .PHONY: install
 install: $(LIBS) META
-	ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore log META $(INTF) $(LIBS) *.a *.so *.cmx
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir) -ldconf ignore log META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-	ocamlfind remove log
+	$(OCAMLFIND) remove log
 
 include $(TOPLEVEL)/bottom.make
 
diff -r d9ac5ae2dbed libs/log/syslog_stubs.c
--- a/libs/log/syslog_stubs.c	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/log/syslog_stubs.c	Tue Apr 07 16:20:28 2009 +0100
@@ -19,6 +19,8 @@
 #include <caml/memory.h>
 #include <caml/alloc.h>
 #include <caml/custom.h>
+
+#ifndef __MINIOS__
 
 static int __syslog_level_table[] = {
 	LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING,
@@ -71,3 +73,17 @@
 	closelog();
 	CAMLreturn(Val_unit);
 }
+
+#else 
+/* MINIOS StubDOM TODO: We need to redirect this to dom0 somehow ... */
+value stub_syslog(value facility, value level, value msg) 
+{
+	CAMLparam3(facility, level, msg);
+	CAMLreturn(Val_unit);
+}
+value stub_closelog(value unit)
+{
+	CAMLparam1(unit);
+	CAMLreturn(Val_unit);
+}
+#endif /* __MINIOS__ */
diff -r d9ac5ae2dbed libs/mmap/Makefile
--- a/libs/mmap/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/mmap/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -26,11 +26,11 @@
 
 .PHONY: install
 install: $(LIBS) META
-	ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore mmap META $(INTF) $(LIBS) *.a *.so *.cmx
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir) -ldconf ignore mmap META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-	ocamlfind remove mmap
+	$(OCAMLFIND) remove mmap
 
 include $(TOPLEVEL)/bottom.make
 
diff -r d9ac5ae2dbed libs/stdext/Makefile
--- a/libs/stdext/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/stdext/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -3,10 +3,7 @@
 
 OCAMLINCLUDE += -I ../uuid
 
-OCAML_TEST_INC = -I $(shell ocamlfind query oUnit)
-OCAML_TEST_LIB = $(shell ocamlfind query oUnit)/oUnit.cmxa
-
-OBJS = filenameext stringext hashtblext listext pervasiveext threadext trie opt unixext
+OBJS = filenameext stringext hashtblext listext pervasiveext trie opt unixext 
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = stdext.cma stdext.cmxa
 
@@ -30,22 +27,13 @@
 	$(OCAMLMKLIB) -o stdext_stubs $+
 
 ## OBJS
-threadext.cmo: threadext.ml
-	$(OCAMLC) $(OCAMLCFLAGS) -thread -c -o $@ $<
-
-threadext.cmi: threadext.mli
-	$(OCAMLC) $(OCAMLCFLAGS) -thread -c -o $@ $<
-
-threadext.cmx: threadext.ml
-	$(OCAMLOPT) $(OCAMLOPTFLAGS) -thread -c -o $@ $<
-
 .PHONY: install
 install: $(LIBS) META
-	ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore stdext META $(INTF) $(LIBS) *.a *.so *.cmx
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir) -ldconf ignore stdext META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-	ocamlfind remove stdext
+	$(OCAMLFIND) remove stdext
 
 include $(TOPLEVEL)/bottom.make
 
diff -r d9ac5ae2dbed libs/uuid/Makefile
--- a/libs/uuid/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/uuid/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -19,11 +19,11 @@
 
 .PHONY: install
 install: $(LIBS) META
-	ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
-	ocamlfind remove uuid
+	$(OCAMLFIND) remove uuid
 
 include $(TOPLEVEL)/bottom.make
 
diff -r d9ac5ae2dbed libs/xb/Makefile
--- a/libs/xb/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/xb/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -40,10 +40,10 @@
 
 .PHONY: install
 install: $(LIBS) META
-	ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xb META $(INTF) $(LIBS) *.a *.so *.cmx
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir) -ldconf ignore xb META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-	ocamlfind remove xb
+	$(OCAMLFIND) remove xb
 
 include $(TOPLEVEL)/bottom.make
diff -r d9ac5ae2dbed libs/xc/Makefile
--- a/libs/xc/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/xc/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -29,11 +29,11 @@
 
 .PHONY: install
 install: $(LIBS) META
-	ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xc META $(INTF) $(LIBS) *.a *.so *.cmx
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir) -ldconf ignore xc META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-	ocamlfind remove xc
+	$(OCAMLFIND) remove xc
 
 
 include $(TOPLEVEL)/bottom.make
diff -r d9ac5ae2dbed libs/xc/xc_stubs.c
--- a/libs/xc/xc_stubs.c	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/xc/xc_stubs.c	Tue Apr 07 16:20:28 2009 +0100
@@ -24,6 +24,7 @@
 #include <caml/fail.h>
 #include <caml/callback.h>
 
+#include <sys/types.h>
 #include <sys/mman.h>
 #include <stdint.h>
 #include <string.h>
@@ -31,10 +32,6 @@
 #include "xc.h"
 
 #include "mmap_stubs.h"
-
-#define PAGE_SHIFT		12
-#define PAGE_SIZE               (1UL << PAGE_SHIFT)
-#define PAGE_MASK               (~(PAGE_SIZE-1))
 
 #define _H(__h) (Int_val(__h))
 #define _D(__d) ((uint32_t)Int_val(__d))
@@ -49,7 +46,7 @@
 	caml_raise_with_string(*caml_named_value("xc.error"), xc_error_get());
 }
 
-CAMLprim value stub_xc_interface_open()
+CAMLprim value stub_xc_interface_open(void)
 {
         int handle;
         handle = xc_interface_open();
@@ -58,7 +55,7 @@
         return Val_int(handle);
 }
 
-CAMLprim value stub_xc_using_injection()
+CAMLprim value stub_xc_using_injection(void)
 {
 	if (xc_using_injection ()){
 		return Val_int(1);
diff -r d9ac5ae2dbed libs/xs/Makefile
--- a/libs/xs/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/libs/xs/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -27,11 +27,11 @@
 
 .PHONY: install
 install: $(LIBS) META
-	ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xs META $(INTF) xs.mli xst.mli xsraw.mli $(LIBS) *.a *.cmx
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir) -ldconf ignore xs META $(INTF) xs.mli xst.mli xsraw.mli $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
-	ocamlfind remove xs
+	$(OCAMLFIND) remove xs
 
 include $(TOPLEVEL)/bottom.make
 
diff -r d9ac5ae2dbed xenstored/Makefile
--- a/xenstored/Makefile	Thu Mar 26 16:12:51 2009 +0000
+++ b/xenstored/Makefile	Tue Apr 07 16:20:28 2009 +0100
@@ -18,13 +18,27 @@
 	-ccopt -L -ccopt ../libs/xb ../libs/xb/xb.cmxa \
 	-ccopt -L -ccopt ../libs/stdext ../libs/stdext/stdext.cmxa
 
-PROGRAMS = xenstored
+ifeq ($(CONFIG_STUBDOM),)
+  # linux executable target
+  OUTPUT = xenstored
+else 
+  # mini-OS application target
+  OUTPUT = caml.o main-caml.o
+endif
 
-all: $(INTF) $(PROGRAMS)
+all: $(INTF) $(OUTPUT)
 
-bins: $(PROGRAMS)
+bins: $(OUTPUT)
+
+ifeq ($(CONFIG_STUBDOM),)
 
 xenstored: $(foreach obj,$(OBJS),$(obj).cmx)
 	$(OCAMLOPT) $(OCAMLOPTFLAGS) -o $@ $(XENSTOREDLIBS) $(foreach obj,$(OBJS), $(obj).cmx)
 
+else
+
+caml.o: $(foreach obj,$(OBJS),$(obj).cmx)
+	$(OCAMLOPT) $(XENSTOREDLIBS) $^ -output-obj -o $@
+endif
+
 include $(TOPLEVEL)/bottom.make
diff -r d9ac5ae2dbed xenstored/main-caml.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xenstored/main-caml.c	Tue Apr 07 16:20:28 2009 +0100
@@ -0,0 +1,42 @@
+/*
+ * Caml bootstrap
+ *
+ * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, January 2008
+ */
+
+#include <stdio.h>
+#include <errno.h>
+
+#include <caml/mlvalues.h>
+#include <caml/callback.h>
+#include <unistd.h>
+
+/* Ugly binary compatibility with Linux */
+FILE *_stderr asm("stderr");
+int *__errno_location;
+/* Will probably break everything, probably need to fetch from glibc */
+void *__ctype_b_loc;
+
+int main(int argc, char *argv[], char *envp[])
+{
+    value *val;
+
+    /* Get current thread's value */
+    _stderr = stderr;
+    __errno_location = &errno;
+
+    printf("starting caml\n");
+
+    /* Wait before things might hang up */
+    sleep(1);
+
+    caml_startup(argv);
+    val = caml_named_value("main");
+    if (!val) {
+        printf("Couldn't find Caml main");
+        return 1;
+    }
+    caml_callback(*val, Val_int(0));
+    printf("callback returned\n");
+    return 0;
+}
diff -r d9ac5ae2dbed xenstored/xenstored.ml
--- a/xenstored/xenstored.ml	Thu Mar 26 16:12:51 2009 +0000
+++ b/xenstored/xenstored.ml	Tue Apr 07 16:20:28 2009 +0100
@@ -220,7 +220,7 @@
 	        (fun () -> close_out channel)
 end
 
-let _ =
+let main () =
 	printf "Xen Storage Daemon, version %d.%d\n%!"
 	       Define.xenstored_major Define.xenstored_minor;
 
@@ -382,3 +382,6 @@
 	info "stopping xenstored";
 	DB.to_file store cons "/var/run/xenstored/db";
 	()
+
+let _ = main ()
+let _ = Callback.register "main" main


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-04-17 15:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-17 15:44 [PATCH 5/7] [xen-ocaml-tools.hg] get xenstored to compile under minios Alex Zeffertt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.