build: Add -ldl to LIBS as needed.
PATCH 1/1 build: Add -ldl to LIBS as needed.
ELL requires the libdl library but does not add it to the LIBS build variable. Add it to LIBS, as needed, so that the libdl dependency will be embedded into the libell shared library binary:
Pre-change:
$ ldd ell/.libs/libell.so.0.0.2
linux-vdso.so.1 (0x00007ffec6fd2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb7db3bf000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb7db9f5000)Post-change:
$ ldd ell/.libs/libell.so.0.0.2
linux-vdso.so.1 (0x00007fffb95d1000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f02bef2f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f02beb3e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f02bf378000)This also obviates the need to explicitly add libdl to LDFLAGS for the ELL plugin unit test.
Lastly, only add "-ldl" to the library flags in ELL's pkg-config file (ell.pc) when necessary.
--- Makefile.am | 2 +- configure.ac | 2 +- ell/ell.pc.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Makefile.am +1 -1
@@ -215,7 +215,7 @@ unit_test_io_LDADD = ell/libell-private.la unit_test_ringbuf_LDADD = ell/libell-private.la unit_test_plugin_LDFLAGS = -Wl,-export-dynamic -unit_test_plugin_LDADD = ell/libell-private.la -ldl +unit_test_plugin_LDADD = ell/libell-private.la unit_test_checksum_LDADD = ell/libell-private.la
configure.ac +1 -1
@@ -106,7 +106,7 @@ AC_CHECK_FUNC(timerfd_create, dummy=yes, AC_CHECK_FUNC(epoll_create, dummy=yes, AC_MSG_ERROR(epoll support is required)) -AC_CHECK_LIB(dl, dlopen, dummy=yes, +AC_SEARCH_LIBS(dlopen, dl, dummy=yes, AC_MSG_ERROR(dynamic linking loader is required)) AC_CHECK_HEADERS(linux/types.h linux/if_alg.h)
ell/ell.pc.in +1 -1
@@ -6,5 +6,5 @@ includedir=@includedir@ Name: ELL Description: Embedded Linux library Version: @VERSION@ -Libs: -L${libdir} -lell -ldl +Libs: -L${libdir} -lell @LIBS@ Cflags: -I${includedir}
Signature · 1 line
2.17.1
Quoted 12 lines · Ossama Othman
Lastly, only add "-ldl" to the library flags in ELL's pkg-config file (ell.pc) when necessary.
index 4fc933b..65ea88e 100644ell/ell.pc.in +0
-0@@ -6,5 +6,5 @@ includedir=@includedir@Name: ELL
Description: Embedded Linux library
Version: @VERSION@ell/ell.pc.in +1
-1-Libs: -L${libdir} -lell -ldl +Libs: -L${libdir} -lell @LIBS@
Quoted 1 line
Cflags: -I${includedir}
The change does not correspond to the claim. "-ldl" will still always end up in the .pc (on Linux/glibc), even though it's already recorded in the .so file.
This ought to be
Libs.private: @LIBS@
instead.
Othman
Hi Jan,
Quoted 19 lines · Jan Engelhardt
Quoted 12 lines · Ossama Othman
Lastly, only add "-ldl" to the library flags in ELL's pkg-config file (ell.pc) when necessary.
index 4fc933b..65ea88e 100644ell/ell.pc.in +0
-0@@ -6,5 +6,5 @@ includedir=@includedir@Name: ELL
Description: Embedded Linux library
Version: @VERSION@ell/ell.pc.in +1
-1-Libs: -L${libdir} -lell -ldl +Libs: -L${libdir} -lell @LIBS@Quoted 1 line
Cflags: -I${includedir}
The change does not correspond to the claim. "-ldl" will still always end up in the .pc (on Linux/glibc), even though it's already recorded in the .so file.
Quoted 5 lines
This ought to be
Libs.private: @LIBS@
instead.
By "when necessary" I was referring to the AC_SEARCH_LIBS macro behavior of not adding the library in question to LIBS if the function can be resolved at link-time without the library, e.g. if dlopen() can be resolved without explicitly linking "-ldl". However, you make a good point. I'll submit a revised patch with a clarification, as well as your suggested change. Thanks for the tip!
-Ossama
PATCH v2 1/1 build: Add -ldl to LIBS as needed.
In reply to Ossama OthmanELL requires the libdl library but does not add it to the LIBS build variable. Add it to LIBS only if it is required to resolve dlopen() and related functions at link-time so that the libdl dependency will be embedded into the libell shared library binary:
Pre-change:
$ ldd ell/.libs/libell.so.0.0.2
linux-vdso.so.1 (0x00007ffec6fd2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb7db3bf000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb7db9f5000)Post-change:
$ ldd ell/.libs/libell.so.0.0.2
linux-vdso.so.1 (0x00007fffb95d1000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f02bef2f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f02beb3e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f02bf378000)This also obviates the need to explicitly add libdl to LDFLAGS for the ELL plugin unit test.
Lastly, only add "-ldl" to the private library flags in ELL's pkg-config file (ell.pc) since it is an ELL dependency that is only exposed to the user if the platform in question doesn't support inter-library dependencies, or when linking against the static ELL library, e.g.:
$ pkg-config --libs ell -L/usr/local/lib -lell
$ pkg-config --static --libs ell -L/usr/local/lib -lell -ldl --- Makefile.am | 2 +- configure.ac | 2 +- ell/ell.pc.in | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Makefile.am +1 -1
@@ -215,7 +215,7 @@ unit_test_io_LDADD = ell/libell-private.la unit_test_ringbuf_LDADD = ell/libell-private.la unit_test_plugin_LDFLAGS = -Wl,-export-dynamic -unit_test_plugin_LDADD = ell/libell-private.la -ldl +unit_test_plugin_LDADD = ell/libell-private.la unit_test_checksum_LDADD = ell/libell-private.la
configure.ac +1 -1
@@ -106,7 +106,7 @@ AC_CHECK_FUNC(timerfd_create, dummy=yes, AC_CHECK_FUNC(epoll_create, dummy=yes, AC_MSG_ERROR(epoll support is required)) -AC_CHECK_LIB(dl, dlopen, dummy=yes, +AC_SEARCH_LIBS(dlopen, dl, dummy=yes, AC_MSG_ERROR(dynamic linking loader is required)) AC_CHECK_HEADERS(linux/types.h linux/if_alg.h)
ell/ell.pc.in +2 -1
@@ -6,5 +6,6 @@ includedir=@includedir@ Name: ELL Description: Embedded Linux library Version: @VERSION@ -Libs: -L${libdir} -lell -ldl +Libs: -L${libdir} -lell +Libs.private: @LIBS@ Cflags: -I${includedir}
Signature · 1 line
2.17.1