Skip to contentSkip to conversation

oxenstored: link in the systemd system library

PATCH Superseded Jonathan Creekmore 3 participants 8 messages Jul 22, 2015 – Jul 24, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oxenstored: link in the systemd system library

If systemd is configured for use AND you are building oxenstored, the C systemd library must be linked in to the oxenstored binary instead of just into the static ocaml stub.

---
 tools/ocaml/xenstored/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/ocaml/xenstored/Makefile +3 -1
index d861f11..38ca347 100644
@@ -64,9 +64,11 @@ XENSTOREDLIBS = \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
 	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc
 
+XENSTORED_LDFLAGS-$(CONFIG_SYSTEMD) += -cclib $(SYSTEMD_LIBS)
+
 PROGRAMS = oxenstored
 
-oxenstored_LIBS = $(XENSTOREDLIBS)
+oxenstored_LIBS = $(XENSTOREDLIBS) $(XENSTORED_LDFLAGS-y)
 oxenstored_OBJS = $(OBJS)
 
 OCAML_PROGRAM = oxenstored
Signature · 1 line
2.1.4
#1 lore raw
Quoted 4 lines · Jonathan Creekmore

If systemd is configured for use AND you are building oxenstored, the C
systemd library must be linked in to the oxenstored binary instead of just into the static ocaml stub.

I can't see where it is linked into the static ocaml stub at all, compared with tools/ocaml/libs/* there is no LIBS_systemd declared in tools/ocaml/xenstore/Makefile. AIUI this is supposed to cause the underlying library to be referenced by the cxma such that you don't need it at application link time.

It's also the case that we don't seem to link xenstored against any other libraries in this way, they get picked up via the cxma.

So I think the right fix is probably to set LIBS_systemd, or otherwise arrange for this argument to be used when creating the systemd.cxma.

Ian.

Quoted 25 lines
---
 tools/ocaml/xenstored/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/ocaml/xenstored/Makefile +3 -1
index d861f11..38ca347 100644
@@ -64,9 +64,11 @@ XENSTOREDLIBS = \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb 
 $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
 	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc
 
+XENSTORED_LDFLAGS-$(CONFIG_SYSTEMD) += -cclib $(SYSTEMD_LIBS)
+
 PROGRAMS = oxenstored
 
-oxenstored_LIBS = $(XENSTOREDLIBS)
+oxenstored_LIBS = $(XENSTOREDLIBS) $(XENSTORED_LDFLAGS-y)
 oxenstored_OBJS = $(OBJS)
 

OCAML_PROGRAM = oxenstored

#2 lore raw

PATCH v2 1/1 oxenstored: link in the systemd system library

If systemd is configured for use AND you are building oxenstored, the C systemd library must be linked in to the systemd.cxma library.

---
Changed since v1:
* Link the systemd library in to the systemd.cxma instead of the final binary.

---
 tools/ocaml/xenstored/Makefile | 2 ++
 1 file changed, 2 insertions(+)
tools/ocaml/xenstored/Makefile +2 -0
index d861f11..59875f7 100644
@@ -30,6 +30,8 @@ systemd_OBJS = systemd
 systemd_C_OBJS = systemd_stubs
 OCAML_LIBRARY += systemd
 
+LIBS_systemd += $(LDFLAGS-y)
+
 OBJS = define \
 	stdext \
 	trie \
Signature · 1 line
2.1.4
Acked-by on v2 1/1
#3 lore raw
Quoted 5 lines · Jonathan Creekmore

If systemd is configured for use AND you are building oxenstored, the C
systemd library must be linked in to the systemd.cxma library.

OOI what was the failure mode for you without this? Runtime rather than build time I suspect?

Quoted 23 lines

---
Changed since v1:
* Link the systemd library in to the systemd.cxma instead of the
final
binary.

---
 tools/ocaml/xenstored/Makefile | 2 ++
 1 file changed, 2 insertions(+)
tools/ocaml/xenstored/Makefile +2 -0
index d861f11..59875f7 100644
@@ -30,6 +30,8 @@ systemd_OBJS = systemd
 systemd_C_OBJS = systemd_stubs
 OCAML_LIBRARY += systemd
 
+LIBS_systemd += $(LDFLAGS-y)
+
 OBJS = define \
 	stdext \
 	trie \
#4 lore raw
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Jonathan Creekmore

If systemd is configured for use AND you are building oxenstored, the C
systemd library must be linked in to the systemd.cxma library.

Quoted 6 lines
Quoted 1 line

OOI what was the failure mode for you without this? Runtime rather than build time I suspect?

No, it was build-time. It failed to link the oxenstored binary due to missing symbols.

#5 lore raw
Quoted 12 lines · Jonathan Creekmore
Quoted 12 lines

On Jul 23, 2015, at 9:00 AM, Ian Campbell <[email protected]> wrote:

Quoted 6 lines · Jonathan Creekmore

If systemd is configured for use AND you are building oxenstored, the
C
systemd library must be linked in to the systemd.cxma library.

Quoted 8 lines
Quoted 5 lines

OOI what was the failure mode for you without this? Runtime rather than
build time I suspect?

No, it was build-time. It failed to link the oxenstored binary due to missing symbols.

Interesting, that (surprisingly) works for me. I suspect differing toolchain versions then!

Ian.

Acked-by on v1 1/1
#7 lore raw
In reply to Jonathan Creekmore
Quoted 6 lines · Jonathan Creekmore

If systemd is configured for use AND you are building oxenstored, the C systemd library must be linked in to the oxenstored binary instead of just into the static ocaml stub.

This sounds sensible to me,

Quoted 26 lines

---
tools/ocaml/xenstored/Makefile | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
tools/ocaml/xenstored/Makefile +2 -0
index d861f11..38ca347 100644
@@ -64,9 +64,11 @@ XENSTOREDLIBS = \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
 	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc
 
+XENSTORED_LDFLAGS-$(CONFIG_SYSTEMD) += -cclib $(SYSTEMD_LIBS)
+

PROGRAMS = oxenstored

tools/ocaml/xenstored/Makefile +1 -1
-oxenstored_LIBS = $(XENSTOREDLIBS)
+oxenstored_LIBS = $(XENSTOREDLIBS) $(XENSTORED_LDFLAGS-y)

oxenstored_OBJS = $(OBJS)

OCAML_PROGRAM = oxenstored

Signature · 1 line
2.1.4