Skip to contentSkip to conversation

tools/xenstore: add libdl dependency to libxenstore

PATCH Superseded Juergen Gross 4 participants 13 messages Mar 7, 2018 – Mar 9, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/xenstore: add libdl dependency to libxenstore

Commit 448c03b3cbe14873ee63 ("tools/xenstore: try to get minimum thread stack size for watch thread") added a dependency to libdl to libxenstore.

Add the needed flags to LDLIBS_libxenstore and the pkg-config file of libxenstore.

Fixes 448c03b3cbe14873ee63
---
 tools/Rules.mk                | 3 +++
 tools/xenstore/Makefile       | 2 ++
 tools/xenstore/xenstore.pc.in | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
tools/Rules.mk +3 -0
index 61515d3063..296b722372 100644
@@ -149,6 +149,9 @@ CFLAGS_libxenstore = -I$(XEN_XENSTORE)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenstore = $(SHLIB_libxentoolcore)
 LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_XENSTORE)/libxenstore$(libextension)
 SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_XENSTORE)
+ifeq ($(CONFIG_Linux),y)
+LDLIBS_libxenstore += -ldl
+endif
 
 CFLAGS_libxenstat  = -I$(XEN_LIBXENSTAT)
 SHDEPS_libxenstat  = $(SHLIB_libxenctrl) $(SHLIB_libxenstore)
tools/xenstore/Makefile +2 -0
index 0831be0b6f..aeee819748 100644
@@ -103,6 +103,8 @@ xs.opic: CFLAGS += -DUSE_PTHREAD
 ifeq ($(CONFIG_Linux),y)
 xs.opic: CFLAGS += -DUSE_DLSYM
 libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
+else
+PKG_CONFIG_REMOVE += dl
 endif
 
 libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
tools/xenstore/xenstore.pc.in +1 -1
index 6fd72a1f17..4fc37f805b 100644
@@ -7,4 +7,4 @@ Description: The Xenstore library for Xen hypervisor
 Version: @@version@@
 Cflags: -I${includedir} @@cflagslocal@@
 Libs: @@libsflag@@${libdir} -lxenstore
-Requires.private: xenevtchn,xencontrol,xengnttab,xentoolcore
+Requires.private: xenevtchn,xencontrol,xengnttab,xentoolcore,dl
Signature · 7 lines
2.13.6


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Juergen Gross

Commit 448c03b3cbe14873ee63 ("tools/xenstore: try to get minimum thread stack size for watch thread") added a dependency to libdl to libxenstore.

Add the needed flags to LDLIBS_libxenstore and the pkg-config file of libxenstore.

Fixes 448c03b3cbe14873ee63

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Juergen Gross
Quoted 48 lines · Juergen Gross

Commit 448c03b3cbe14873ee63 ("tools/xenstore: try to get minimum thread stack size for watch thread") added a dependency to libdl to libxenstore.

Add the needed flags to LDLIBS_libxenstore and the pkg-config file of libxenstore.

Fixes 448c03b3cbe14873ee63
---
 tools/Rules.mk                | 3 +++
 tools/xenstore/Makefile       | 2 ++
 tools/xenstore/xenstore.pc.in | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
tools/Rules.mk +3 -0
index 61515d3063..296b722372 100644
@@ -149,6 +149,9 @@ CFLAGS_libxenstore = -I$(XEN_XENSTORE)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenstore = $(SHLIB_libxentoolcore)
 LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_XENSTORE)/libxenstore$(libextension)
 SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_XENSTORE)
+ifeq ($(CONFIG_Linux),y)
+LDLIBS_libxenstore += -ldl
+endif
 
 CFLAGS_libxenstat  = -I$(XEN_LIBXENSTAT)
 SHDEPS_libxenstat  = $(SHLIB_libxenctrl) $(SHLIB_libxenstore)
tools/xenstore/Makefile +2 -0
index 0831be0b6f..aeee819748 100644
@@ -103,6 +103,8 @@ xs.opic: CFLAGS += -DUSE_PTHREAD
 ifeq ($(CONFIG_Linux),y)
 xs.opic: CFLAGS += -DUSE_DLSYM
 libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
+else
+PKG_CONFIG_REMOVE += dl
 endif
 
 libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
tools/xenstore/xenstore.pc.in +0 -0
index 6fd72a1f17..4fc37f805b 100644

tools/xenstore/xenstore.pc.in Description: The Xenstore library for Xen hypervisor · line 10

Quoted 5 lines
tools/xenstore/xenstore.pc.in +1 -1
@@ -7,4 +7,4 @@ Description: The Xenstore library for Xen hypervisor
 Version: @@version@@
 Cflags: -I${includedir} @@cflagslocal@@
 Libs: @@libsflag@@${libdir} -lxenstore
-Requires.private: xenevtchn,xencontrol,xengnttab,xentoolcore
+Requires.private: xenevtchn,xencontrol,xengnttab,xentoolcore,dl

Uuh, this was wrong. libdl hasn't got a pkgconfig file, so we need to add -ldl to Libs.private instead. V2 coming soon...

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 43 lines · Juergen Gross
Quoted 42 lines · Juergen Gross

Commit 448c03b3cbe14873ee63 ("tools/xenstore: try to get minimum thread stack size for watch thread") added a dependency to libdl to libxenstore.

Add the needed flags to LDLIBS_libxenstore and the pkg-config file of libxenstore.

Fixes 448c03b3cbe14873ee63
---
 tools/Rules.mk                | 3 +++
 tools/xenstore/Makefile       | 2 ++
 tools/xenstore/xenstore.pc.in | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)
tools/Rules.mk +3 -0
index 61515d3063..296b722372 100644
@@ -149,6 +149,9 @@ CFLAGS_libxenstore = -I$(XEN_XENSTORE)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenstore = $(SHLIB_libxentoolcore)
 LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_XENSTORE)/libxenstore$(libextension)
 SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_XENSTORE)
+ifeq ($(CONFIG_Linux),y)
+LDLIBS_libxenstore += -ldl
+endif
 
 CFLAGS_libxenstat  = -I$(XEN_LIBXENSTAT)
 SHDEPS_libxenstat  = $(SHLIB_libxenctrl) $(SHLIB_libxenstore)
tools/xenstore/Makefile +2 -0
index 0831be0b6f..aeee819748 100644
@@ -103,6 +103,8 @@ xs.opic: CFLAGS += -DUSE_PTHREAD
 ifeq ($(CONFIG_Linux),y)
 xs.opic: CFLAGS += -DUSE_DLSYM
 libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
+else
+PKG_CONFIG_REMOVE += dl
 endif
 
Quoted 15 lines

tools/xenstore/xenstore.pc.in Description: The Xenstore library for Xen hypervisor · line 10

Quoted 11 lines
tools/xenstore/Makefile +0 -0
 libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
tools/xenstore/xenstore.pc.in +1 -1
index 6fd72a1f17..4fc37f805b 100644
@@ -7,4 +7,4 @@ Description: The Xenstore library for Xen hypervisor
 Version: @@version@@
 Cflags: -I${includedir} @@cflagslocal@@
 Libs: @@libsflag@@${libdir} -lxenstore
-Requires.private: xenevtchn,xencontrol,xengnttab,xentoolcore
+Requires.private: xenevtchn,xencontrol,xengnttab,xentoolcore,dl

Uuh, this was wrong. libdl hasn't got a pkgconfig file, so we need to add -ldl to Libs.private instead. V2 coming soon...

Luckily I haven't got around to apply it...

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

PATCH 1/1 tools/xenstore: add libdl dependency to libxenstore

In reply to Juergen Gross

Juergen Gross writes ("[PATCH] tools/xenstore: add libdl dependency to libxenstore"):

tools/xenstore/Makefile xs.opic: CFLAGS += -DUSE_PTHREAD · line 107

Quoted 3 lines

libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl

tools/xenstore/Makefile +2 -0
+else
+PKG_CONFIG_REMOVE += dl

What is this ?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 6 lines · Ian Jackson

Juergen Gross writes ("[PATCH] tools/xenstore: add libdl dependency to libxenstore"):

tools/xenstore/Makefile xs.opic: CFLAGS += -DUSE_PTHREAD · line 107

Quoted 3 lines

libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl

tools/xenstore/Makefile +2 -0
+else
+PKG_CONFIG_REMOVE += dl

What is this ?

-ldl is needed on Linux only, but I didn't want to add a Linux specific pkg-config file. So I'm removing the dependency in case we are not on Linux.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw

Juergen Gross writes ("Re: [PATCH] tools/xenstore: add libdl dependency to libxenstore"):

Quoted 11 lines · Ian Jackson
Quoted 6 lines

Juergen Gross writes ("[PATCH] tools/xenstore: add libdl dependency to libxenstore"):

tools/xenstore/Makefile xs.opic: CFLAGS += -DUSE_PTHREAD · line 107

Quoted 3 lines

libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl

tools/xenstore/Makefile +2 -0
+else
+PKG_CONFIG_REMOVE += dl

What is this ?

-ldl is needed on Linux only, but I didn't want to add a Linux specific pkg-config file. So I'm removing the dependency in case we are not on Linux.

Sorry, I was grepping an older xen tree, so I didn't see where this variable was honoured.

Will this work, though, when what has to be done is to remove -ldl from Libs, rather than from Requires ?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw
Quoted 13 lines · On 07/03/18 13:06, [email protected] wrote:

Juergen Gross writes ("Re: [PATCH] tools/xenstore: add libdl dependency to libxenstore"):

Quoted 11 lines · Ian Jackson
Quoted 6 lines

Juergen Gross writes ("[PATCH] tools/xenstore: add libdl dependency to libxenstore"):

tools/xenstore/Makefile xs.opic: CFLAGS += -DUSE_PTHREAD · line 107

Quoted 3 lines

libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl

tools/xenstore/Makefile +2 -0
+else
+PKG_CONFIG_REMOVE += dl

What is this ?

-ldl is needed on Linux only, but I didn't want to add a Linux specific pkg-config file. So I'm removing the dependency in case we are not on Linux.

Quoted 5 lines

Sorry, I was grepping an older xen tree, so I didn't see where this variable was honoured.

Will this work, though, when what has to be done is to remove -ldl from Libs, rather than from Requires ?

Yes, I've tested it to work (in V2 we have: PKG_CONFIG_REMOVE += -ldl)

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw
Quoted 8 lines · Juergen Gross
Quoted 7 lines · On 07/03/18 13:06, [email protected] wrote:

Juergen Gross writes ("Re: [PATCH] tools/xenstore: add libdl dependency to libxenstore"):

Quoted 6 lines · Ian Jackson
Quoted 5 lines

Juergen Gross writes ("[PATCH] tools/xenstore: add libdl dependency to libxenstore"):

tools/xenstore/Makefile xs.opic: CFLAGS += -DUSE_PTHREAD · line 107

Quoted 3 lines

libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl

tools/xenstore/Makefile +2 -0
+else
+PKG_CONFIG_REMOVE += dl

What is this ?

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

-ldl is needed on Linux only, but I didn't want to add a Linux specific pkg-config file. So I'm removing the dependency in case we are not on Linux.

Sorry, I was grepping an older xen tree, so I didn't see where this variable was honoured.
Will this work, though, when what has to be done is to remove -ldl from Libs, rather than from Requires ?

Yes, I've tested it to work (in V2 we have: PKG_CONFIG_REMOVE += -ldl)

This breaks libvirt.
m4/virt-driver-xen.m4 tries to use just '-lxenstore' and the test fails with missing 'dlsym'. If I adjust this .m4 file to use pkgconfig it still fails. Only appending '-ldl' to XEN_LIBS will help. So to me it looks like -ldl is now a hard requirement when linking to libxenstore.so. I used 20180307T163340.c9bd8a7365 for testing.

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#9 lore raw
Quoted 17 lines · Olaf Hering
Quoted 15 lines · Juergen Gross
Quoted 14 lines · On 07/03/18 13:06, [email protected] wrote:

Juergen Gross writes ("Re: [PATCH] tools/xenstore: add libdl dependency to libxenstore"):

Quoted 9 lines · Ian Jackson
Quoted 5 lines

Juergen Gross writes ("[PATCH] tools/xenstore: add libdl dependency to libxenstore"):

tools/xenstore/Makefile xs.opic: CFLAGS += -DUSE_PTHREAD · line 107

Quoted 3 lines

libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl

tools/xenstore/Makefile +2 -0
+else
+PKG_CONFIG_REMOVE += dl

What is this ?

-ldl is needed on Linux only, but I didn't want to add a Linux specific pkg-config file. So I'm removing the dependency in case we are not on Linux.

Sorry, I was grepping an older xen tree, so I didn't see where this variable was honoured.
Will this work, though, when what has to be done is to remove -ldl from Libs, rather than from Requires ?

Quoted 8 lines
Quoted 1 line

Yes, I've tested it to work (in V2 we have: PKG_CONFIG_REMOVE += -ldl)

This breaks libvirt.
m4/virt-driver-xen.m4 tries to use just '-lxenstore' and the test fails with missing 'dlsym'. If I adjust this .m4 file to use pkgconfig it still fails. Only appending '-ldl' to XEN_LIBS will help. So to me it looks like -ldl is now a hard requirement when linking to libxenstore.so. I used 20180307T163340.c9bd8a7365 for testing.

It seems as if some information in libxenstore.so is missing.

E.g. libpython2.7.so is linked against libdl.so. It is possible to just link any program with libpython2.7.so without having to specify -ldl:

$ gcc -o cpuid cpuid.c -lpython2.7
$ ldd cpuid
        linux-vdso.so.1 (0x00007fffbe9bf000)
        libpython2.7.so.1.0 => /usr/lib64/libpython2.7.so.1.0
(0x00007f70bd560000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f70bd1bb000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f70bcf9e000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f70bcd9a000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007f70bcb97000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f70bc89a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f70bd96e000)
$ cat /usr/lib64/pkgconfig/python-2.7.pc
prefix=/usr
exec_prefix=/usr
libdir=/usr/lib64
includedir=/usr/include

Name: Python
Description: Python library
Requires:
Version: 2.7
Libs.private: -lpthread -ldl -lutil
Libs: -L${libdir} -lpython2.7
Cflags: -I${includedir}/python2.7

So how does this work?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#10 lore raw
Quoted 1 line · Juergen Gross

So how does this work?

No idea, at least this output differs:

abuild@latitude:~> readelf -Wa /usr/lib64/libpython2.7.so | grep dlsym
00000000003e5e08 000000d900000007 R_X86_64_JUMP_SLOT 0000000000000000 dlsym@GLIBC_2.2.5 + 0
217: 0000000000000000 0 FUNC GLOBAL DEFAULT UND dlsym@GLIBC_2.2.5 (10)
abuild@latitude:~> readelf -Wa /usr/lib64/libxenstore.so | grep dlsym
00000000002071b0 0000002b00000007 R_X86_64_JUMP_SLOT 0000000000000000 dlsym + 0

    43: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND dlsym

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#11 lore raw
Quoted 6 lines · Olaf Hering

abuild@latitude:~> readelf -Wa /usr/lib64/libpython2.7.so | grep dlsym
00000000003e5e08 000000d900000007 R_X86_64_JUMP_SLOT 0000000000000000 dlsym@GLIBC_2.2.5 + 0
217: 0000000000000000 0 FUNC GLOBAL DEFAULT UND dlsym@GLIBC_2.2.5 (10)
abuild@latitude:~> readelf -Wa /usr/lib64/libxenstore.so | grep dlsym
00000000002071b0 0000002b00000007 R_X86_64_JUMP_SLOT 0000000000000000 dlsym + 0

    43: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND dlsym

The difference is SUSE_ASNEEDED=1 in environment.
If it is set, libxenstore.so will not link to libdl.so.
If it is not, libxenstore.so will link to libdl.so.
Since package building exports SUSE_ASNEEDED=1 usage of -lxenstore will fail. Not sure how all the other packages use dlsym(), clearly xenstore does something different.

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#12 lore raw
Quoted 9 lines · Olaf Hering
Quoted 6 lines · Olaf Hering

abuild@latitude:~> readelf -Wa /usr/lib64/libpython2.7.so | grep dlsym
00000000003e5e08 000000d900000007 R_X86_64_JUMP_SLOT 0000000000000000 dlsym@GLIBC_2.2.5 + 0
217: 0000000000000000 0 FUNC GLOBAL DEFAULT UND dlsym@GLIBC_2.2.5 (10)
abuild@latitude:~> readelf -Wa /usr/lib64/libxenstore.so | grep dlsym
00000000002071b0 0000002b00000007 R_X86_64_JUMP_SLOT 0000000000000000 dlsym + 0

    43: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND dlsym
Quoted 6 lines

The difference is SUSE_ASNEEDED=1 in environment.
If it is set, libxenstore.so will not link to libdl.so.
If it is not, libxenstore.so will link to libdl.so.
Since package building exports SUSE_ASNEEDED=1 usage of -lxenstore will fail. Not sure how all the other packages use dlsym(), clearly xenstore does something different.

I'm not sure what to make of this. I'm not sure what SUSE_ASNEEDED is for. I guess I will leave this to you SuSE experts to sort out. :-)

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel