Hi,

This patch adds STATIC_LIBASAN_LIBS so that one can simply use
"gcc -faddress-sanitizer -static-libasan".  OK to install?

Thanks.


H.J.
---
2012-11-18  H.J. Lu  <hongjiu...@intel.com>

        * gcc.c (ADD_STATIC_LIBASAN_LIBS): New macro.  Defined
        with STATIC_LIBASAN_LIBS.
        (LIBASAN_SPEC): Add STATIC_LIBASAN_LIBS.
        * config/gnu-user.h (STATIC_LIBASAN_LIBS): New macro.

diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index cb45749..8c4bbc6 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -98,3 +98,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 
 #define TARGET_C99_FUNCTIONS 1
 #define TARGET_HAS_SINCOS 1
+
+/* Additional libraries needed by -static-libasan.  */
+#undef STATIC_LIBASAN_LIBS
+#define STATIC_LIBASAN_LIBS "-ldl -lpthread"
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 11279be4..5e68d71 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -545,11 +545,18 @@ proper position among the other output files.  */
 #define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}"
 
 #ifndef LIBASAN_SPEC
+#ifdef STATIC_LIBASAN_LIBS
+#define ADD_STATIC_LIBASAN_LIBS \
+  " %{static-libasan:" STATIC_LIBASAN_LIBS "}"
+#else
+#define ADD_STATIC_LIBASAN_LIBS
+#endif
 #ifdef HAVE_LD_STATIC_DYNAMIC
 #define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \
-                    "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}"
+                    "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \
+                    ADD_STATIC_LIBASAN_LIBS
 #else
-#define LIBASAN_SPEC "-lasan"
+#define LIBASAN_SPEC "-lasan" ADD_STATIC_LIBASAN_LIBS
 #endif
 #endif
 
-- 
1.7.11.7

Reply via email to