Forwarding to the patches list, since I got no feedback on the generic one.

---------- Forwarded message ----------
Date: Sat, 14 Jan 2017 01:38:07 +0100 (CET)
From: Dimitrios Apostolou <ji...@gmx.net>
To: libt...@gnu.org
Subject: Support for -static-libasan

Hello list,

I was getting the following error message after building with
CFLAGS='-fsanitize=address -static-libasan' LDFLAGS=-static-libasan
and trying to run the generated executable.

==5331==Your application is linked against incompatible ASan runtimes.


Please note that the project also contains a shared library, which libtool was always linking while ignoring the "-static-libasan" flag. So the library was linking to "libasan.so" while the binaries were linked with the static runtime.

The attached patch on the generated libtool script solved the issue to me. Feel free to use it upstream, if it makes sense.

Thanks,
Dimitris
--- libtool.orig	2017-01-14 01:23:44.996640378 +0100
+++ libtool	2017-01-14 01:25:59.264414122 +0100
@@ -7766,24 +7766,25 @@
       # -F/path              path to uninstalled frameworks, gcc on darwin
       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
       # -fstack-protector*   stack protector flags for GCC
       # @file                GCC response files
       # -tp=*                Portland pgcc target processor selection
       # --sysroot=*          for sysroot support
       # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
       # -specs=*             GCC specs files
       # -stdlib=*            select c++ std lib with clang
       # -fsanitize=*         Clang/GCC memory and address sanitizer
+      # -static-lib*san      Do not require libasan.so in runtime, link statically instead
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
       -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
-      -specs=*|-fsanitize=*)
+      -specs=*|-fsanitize=*|-static-lib*san)
         func_quote_for_eval "$arg"
 	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"
         func_append finalize_command " $arg"
         func_append compiler_flags " $arg"
         continue
         ;;
 
       -Z*)
         if test os2 = "`expr $host : '.*\(os2\)'`"; then

Reply via email to