Skip to contentSkip to conversation

get xenstored to compile under minios

PATCH In review Alex Zeffertt 1 participant 1 message Apr 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 5/7 get xenstored to compile under minios

* 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

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)

bottom.make +0 -3
diff -r d9ac5ae2dbed bottom.make
@@ -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
common.make +16 -10
diff -r d9ac5ae2dbed common.make
@@ -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= >[email protected] && mv -f [email protected] $@
libs/eventchn/Makefile +2 -2
diff -r d9ac5ae2dbed libs/eventchn/Makefile
@@ -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
 
libs/log/Makefile +2 -2
diff -r d9ac5ae2dbed libs/log/Makefile
@@ -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
 
libs/log/syslog_stubs.c +16 -0
diff -r d9ac5ae2dbed libs/log/syslog_stubs.c
@@ -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__ */
libs/mmap/Makefile +2 -2
diff -r d9ac5ae2dbed libs/mmap/Makefile
@@ -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
 
libs/stdext/Makefile +3 -15
diff -r d9ac5ae2dbed libs/stdext/Makefile
@@ -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
 
libs/uuid/Makefile +2 -2
diff -r d9ac5ae2dbed libs/uuid/Makefile
@@ -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
 
libs/xb/Makefile +2 -2
diff -r d9ac5ae2dbed libs/xb/Makefile
@@ -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
libs/xc/Makefile +2 -2
diff -r d9ac5ae2dbed libs/xc/Makefile
@@ -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
libs/xc/xc_stubs.c +3 -6
diff -r d9ac5ae2dbed libs/xc/xc_stubs.c
@@ -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);
libs/xs/Makefile +2 -2
diff -r d9ac5ae2dbed libs/xs/Makefile
@@ -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
 
xenstored/Makefile +17 -3
diff -r d9ac5ae2dbed xenstored/Makefile
@@ -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
xenstored/main-caml.c new file +42 -0

42 lines not on this page · raw message

xenstored/xenstored.ml +4 -1
diff -r d9ac5ae2dbed xenstored/xenstored.ml
@@ -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

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel