Skip to contentSkip to conversation

Fix the build of the ocaml libraries

PATCH In review Jon Ludlam 2 participants 3 messages Dec 5, 2012

lore
Share & tools
lore

Jon Ludlam

author
#0 lore raw

PATCH 1/1 Fix the build of the ocaml libraries

These were previously capturing the absolute path of the build, causing linking against the libraries to fail unless you still have the build directory around.

tools/ocaml/Makefile.rules +2 -8
diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/Makefile.rules
@@ -58,14 +58,8 @@
 
 # define a library target <name>.cmxa and <name>.cma
 define OCAML_LIBRARY_template
- $(1).cmxa: lib$(1)_stubs.a $(foreach obj,$($(1)_OBJS),$(obj).cmx)
-	$(call mk-caml-lib-native,$$@, -cclib -l$(1)_stubs $(foreach lib,$(LIBS_$(1)),-cclib $(lib)), $(foreach obj,$($(1)_OBJS),$(obj).cmx))
- $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmo)
-	$(call mk-caml-lib-bytecode,$$@, -dllib dll$(1)_stubs.so -cclib -l$(1)_stubs, $$+)
- $(1)_stubs.a: $(foreach obj,$$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-stubs,$$@, $$+)
- lib$(1)_stubs.a: $(foreach obj,$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-lib-stubs,$$@, $$+)
+  $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmx $(obj).cmo) $(foreach obj,$($(1)_C_OBJS),$(obj).o)
+	$(OCAMLMKLIB) -o $1 -oc $(1)_stubs $(foreach obj,$($(1)_OBJS),$(obj).cmx $(obj).cmo) $(foreach obj,$($(1)_C_OBJS),$(obj).o) $(foreach lib, $(LIBS_$(1)_SYSTEM), -cclib $(lib)) $(foreach arg,$(LIBS_$(1)),-ldopt $(arg))
 endef
 
 define OCAML_NOC_LIBRARY_template
tools/ocaml/libs/eventchn/Makefile +1 -0
diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/libs/eventchn/Makefile
@@ -9,6 +9,7 @@
 LIBS = xeneventchn.cma xeneventchn.cmxa
 
 LIBS_xeneventchn = $(LDLIBS_libxenctrl)
+LIBS_xeneventchn_SYSTEM = -lxenctrl
 
 all: $(INTF) $(LIBS) $(PROGRAMS)
 
tools/ocaml/libs/xc/Makefile +1 -0
diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/libs/xc/Makefile
@@ -10,6 +10,7 @@
 LIBS = xenctrl.cma xenctrl.cmxa
 
 LIBS_xenctrl = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
+LIBS_xenctrl_SYSTEM = -lxenctrl -lxenguest
 
 xenctrl_OBJS = $(OBJS)
 xenctrl_C_OBJS = xenctrl_stubs
tools/ocaml/xenstored/Makefile +3 -1
diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/xenstored/Makefile
@@ -36,7 +36,9 @@
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
-	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc
+	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc \
+	$(foreach obj, $(LDLIBS_libxenctrl), -ccopt $(obj)) \
+	$(foreach obj, $(LDLIBS_libxenguest), -ccopt $(obj)) 
 
 PROGRAMS = oxenstored
author
#1 lore raw

This is a problem that affects xen-4.2.0, so it may well be worth backporting.

Jon

Quoted 67 lines · Jon Ludlam

These were previously capturing the absolute path of the build, causing linking against the libraries to fail unless you still have the build directory around.

diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/Makefile.rules

tools/ocaml/Makefile.rules +2 -8
@@ -58,14 +58,8 @@
 
  # define a library target <name>.cmxa and <name>.cma
  define OCAML_LIBRARY_template
- $(1).cmxa: lib$(1)_stubs.a $(foreach obj,$($(1)_OBJS),$(obj).cmx)
-	$(call mk-caml-lib-native,$$@, -cclib -l$(1)_stubs $(foreach lib,$(LIBS_$(1)),-cclib $(lib)), $(foreach obj,$($(1)_OBJS),$(obj).cmx))
- $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmo)
-	$(call mk-caml-lib-bytecode,$$@, -dllib dll$(1)_stubs.so -cclib -l$(1)_stubs, $$+)
- $(1)_stubs.a: $(foreach obj,$$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-stubs,$$@, $$+)
- lib$(1)_stubs.a: $(foreach obj,$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-lib-stubs,$$@, $$+)
+  $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmx $(obj).cmo) $(foreach obj,$($(1)_C_OBJS),$(obj).o)
+	$(OCAMLMKLIB) -o $1 -oc $(1)_stubs $(foreach obj,$($(1)_OBJS),$(obj).cmx $(obj).cmo) $(foreach obj,$($(1)_C_OBJS),$(obj).o) $(foreach lib, $(LIBS_$(1)_SYSTEM), -cclib $(lib)) $(foreach arg,$(LIBS_$(1)),-ldopt $(arg))
  endef
 
  define OCAML_NOC_LIBRARY_template

diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/libs/eventchn/Makefile

tools/ocaml/libs/eventchn/Makefile +1 -0
@@ -9,6 +9,7 @@
  LIBS = xeneventchn.cma xeneventchn.cmxa
 
  LIBS_xeneventchn = $(LDLIBS_libxenctrl)
+LIBS_xeneventchn_SYSTEM = -lxenctrl
 
  all: $(INTF) $(LIBS) $(PROGRAMS)
 

diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/libs/xc/Makefile

tools/ocaml/libs/xc/Makefile +1 -0
@@ -10,6 +10,7 @@
  LIBS = xenctrl.cma xenctrl.cmxa
 
  LIBS_xenctrl = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
+LIBS_xenctrl_SYSTEM = -lxenctrl -lxenguest
 
  xenctrl_OBJS = $(OBJS)
  xenctrl_C_OBJS = xenctrl_stubs

diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/xenstored/Makefile

tools/ocaml/xenstored/Makefile +3 -1
@@ -36,7 +36,9 @@
  	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
  	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \
  	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
-	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc
+	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc \
+	$(foreach obj, $(LDLIBS_libxenctrl), -ccopt $(obj)) \
+	$(foreach obj, $(LDLIBS_libxenguest), -ccopt $(obj))
 
  PROGRAMS = oxenstored
 

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

#2 lore raw
In reply to Jon Ludlam
Quoted 3 lines · Jon Ludlam

These were previously capturing the absolute path of the build, causing linking against the libraries to fail unless you still have the build directory around.

Good catch, thanks.

tools/ocaml/Makefile.rules line 59

Quoted 8 lines

diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/Makefile.rules

tools/ocaml/Makefile.rules +0 -0
@@ -58,14 +58,8 @@
 
 # define a library target <name>.cmxa and <name>.cma

This no longer produces a foo.cmxa, is that deliberate?

Likewise the foo_stubs.a and libfoo_stubs.a.

tools/ocaml/Makefile.rules line 62

Quoted 11 lines
tools/ocaml/Makefile.rules +2 -8
 define OCAML_LIBRARY_template
- $(1).cmxa: lib$(1)_stubs.a $(foreach obj,$($(1)_OBJS),$(obj).cmx)
-	$(call mk-caml-lib-native,$$@, -cclib -l$(1)_stubs $(foreach lib,$(LIBS_$(1)),-cclib $(lib)), $(foreach obj,$($(1)_OBJS),$(obj).cmx))
- $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmo)
-	$(call mk-caml-lib-bytecode,$$@, -dllib dll$(1)_stubs.so -cclib -l$(1)_stubs, $$+)
- $(1)_stubs.a: $(foreach obj,$$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-stubs,$$@, $$+)
- lib$(1)_stubs.a: $(foreach obj,$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-lib-stubs,$$@, $$+)
+  $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmx $(obj).cmo) $(foreach obj,$($(1)_C_OBJS),$(obj).o)
+	$(OCAMLMKLIB) -o $1 -oc $(1)_stubs $(foreach obj,$($(1)_OBJS),$(obj).cmx $(obj).cmo) $(foreach obj,$($(1)_C_OBJS),$(obj).o) $(foreach lib, $(LIBS_$(1)_SYSTEM), -cclib $(lib)) $(foreach arg,$(LIBS_$(1)),-ldopt $(arg))

Can this change be made part of mk-caml-lib-bytecode ?

I don't much like it but the existing caml build stuff uses that quiet-command stuff so I think this new command will end up standing out like a sore thumb. If you want to fix this by nuking all that stuff then that is fine by me ;-)

Quoted 44 lines
tools/ocaml/Makefile.rules +0 -0
 endef
 
 define OCAML_NOC_LIBRARY_template

diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/libs/eventchn/Makefile

tools/ocaml/libs/eventchn/Makefile +1 -0
@@ -9,6 +9,7 @@
 LIBS = xeneventchn.cma xeneventchn.cmxa
 
 LIBS_xeneventchn = $(LDLIBS_libxenctrl)
+LIBS_xeneventchn_SYSTEM = -lxenctrl
 
 all: $(INTF) $(LIBS) $(PROGRAMS)
 

diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/libs/xc/Makefile

tools/ocaml/libs/xc/Makefile +1 -0
@@ -10,6 +10,7 @@
 LIBS = xenctrl.cma xenctrl.cmxa
 
 LIBS_xenctrl = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest)
+LIBS_xenctrl_SYSTEM = -lxenctrl -lxenguest
 
 xenctrl_OBJS = $(OBJS)
 xenctrl_C_OBJS = xenctrl_stubs

diff -r 29247e44df47 -r 575e649ad4dc tools/ocaml/xenstored/Makefile

tools/ocaml/xenstored/Makefile +3 -1
@@ -36,7 +36,9 @@
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
-	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc
+	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc \
+	$(foreach obj, $(LDLIBS_libxenctrl), -ccopt $(obj)) \
+	$(foreach obj, $(LDLIBS_libxenguest), -ccopt $(obj)) 
 
 PROGRAMS = oxenstored
 

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

Signature · 1 line
Ian Campbell