From 099c8340edbae163205461f0d8c775dd8c225c69 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 10 Apr 2020 22:10:13 +0200 Subject: [PATCH] configure.ac: fix libtool issue with clang and sanitizer As pointed out at https://github.com/libexpat/libexpat/issues/312 libtool does not play nice with clang sanitizer builds at all. For those builds LD shoud be set to clang too (and LDFLAGS needs the sanitizer flags as well), because the clang compiler driver knows how linking to the sanitizer libs works, but then at a later stage libtool fails to actually produce the shared libraries and the build fails. This is fixed by this patch. Addtionally LD_LIBRARY_PATH has no effect on conftest runs during configure time, so the rpath needs to be set to the asan library path to ensure the configure run does not fail due to a missing asan library, i.e.: SANS='-fsanitize=memory -fsanitize-recover=all -shared-libsan' export CC=clang-10 ASANPATH=$(dirname `$CC -print-file-name=libclang_rt.asan-x86_64.so`) export LDFLAGS="-Wl,-rpath,$ASANPATH $SANS $LDFLAGS" Change-Id: I8ebd9c6d4efda41c7c8196f963d1f04d65160754 --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 3b4ad40e7..92457f164 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,11 @@ LT_INIT([pic-only disable-static]) AC_CONFIG_MACRO_DIR([m4]) +dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang +AS_CASE(["$LD"],[*clang*], + [AS_CASE(["${host_os}"], + [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])]) + dnl check for pkg-config dnl * If pkg-config is missing, we get a "syntax error" for PKG_CHECK_MODULES. dnl Instead, we want to say that pkg-config and pkg.m4 are missing.