fix: don't add libelf and libdw to global LIBS
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 12 Nov 2021 20:37:17 +0000 (15:37 -0500)
committerMichael Jeanson <mjeanson@efficios.com>
Fri, 10 Dec 2021 17:11:38 +0000 (12:11 -0500)
The default behavior, for AC_CHECK_LIB when the `action-if-found` is NOT
defined, is to prepend the library to LIBS. [1]

"
If action-if-found is not specified, the default action prepends
-llibrary to LIBS and defines ‘HAVE_LIBlibrary’ (in all capitals).
"

It is important to note that the LIBS variable is used for ALL linking.

This is normally not a problem for most distribution since they force
the use of `--as-needed` at the toolchain level (gcc specs) (for example
debian [2]). One could also pass the `--as-needed` flag manually but
libtool reorganize flags in the case of shared object creation [3].

In our case, we always explicitly state the dependencies via the *_LIBADD
automake clause. We do not rely on the LIBS variable.

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Libraries.html
[2] https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/patches/gcc-as-needed.diff
[3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=347650

Change-Id: Iea7812ccabb17e976362f9ea9412e0834ce946f4
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6745
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Jonathan Rajotte Julien <jonathan.rajotte-julien@efficios.com>
configure.ac

index ca24ee79f7e25bb4c7ebb592236ac3b4691b0661..d6428ccdd0ee4901d7ddb79162c6c414f461391e 100644 (file)
@@ -564,8 +564,8 @@ AE_IF_FEATURE_ENABLED([debug-info], [
 
       # Turns out SLES12 doesn't bother shipping .pc file for libelf
       AC_MSG_WARN([Finding libelf without pkg-config.])
 
       # Turns out SLES12 doesn't bother shipping .pc file for libelf
       AC_MSG_WARN([Finding libelf without pkg-config.])
-      AC_CHECK_LIB([elf], [elf_version], [], [AC_MSG_ERROR(Missing libelf (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)])
-      AC_CHECK_LIB([dw], [dwarf_begin], [], [AC_MSG_ERROR(Missing libdw (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)])
+      AC_CHECK_LIB([elf], [elf_version], [:], [AC_MSG_ERROR(Missing libelf (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)])
+      AC_CHECK_LIB([dw], [dwarf_begin], [:], [AC_MSG_ERROR(Missing libdw (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)])
       AE_LIB_ELFUTILS([0], [154], [], [AC_MSG_ERROR(elfutils >= 0.154 is required to use the debug info feature. You can disable this feature using --disable-debug-info.)])
       ELFUTILS_LIBS="-lelf -ldw"
     ])
       AE_LIB_ELFUTILS([0], [154], [], [AC_MSG_ERROR(elfutils >= 0.154 is required to use the debug info feature. You can disable this feature using --disable-debug-info.)])
       ELFUTILS_LIBS="-lelf -ldw"
     ])
This page took 0.025276 seconds and 4 git commands to generate.