From 1924626bf6332c34699a0ac5c861609463387aa3 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Tue, 9 Nov 2021 10:43:53 -0500 Subject: [PATCH] Fix: libnuma is prepended to LIBS MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. Simply force the define of HAVE_LIBNUMA to prevent the prepending to LIBS. [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 Signed-off-by: Jonathan Rajotte Signed-off-by: Mathieu Desnoyers Change-Id: I33221d14b96482ff71672458097423289f6b9fc2 --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e3089964..e59602ba 100644 --- a/configure.ac +++ b/configure.ac @@ -404,7 +404,9 @@ AE_IF_FEATURE_ENABLED([java-agent-all], [ # The numa integration requires libnuma AE_IF_FEATURE_ENABLED([numa], [ - AC_CHECK_LIB([numa], [numa_available], [], [ + AC_CHECK_LIB([numa], [numa_available], [ + AC_DEFINE([HAVE_LIBNUMA], [1], [Define to 1 if libnuma is available.]) + ], [ AC_MSG_ERROR([dnl libnuma is not available. Please either install it (e.g. libnuma-dev) or use [LDFLAGS]=-Ldir to specify the right location, or use --disable-numa configure -- 2.34.1