Message ID | 20121119050117.GA31538@gmail.com |
---|---|
State | New |
Headers | show |
On Sun, Nov 18, 2012 at 09:01:17PM -0800, H.J. Lu wrote: > This patch adds STATIC_LIBASAN_LIBS so that one can simply use > "gcc -faddress-sanitizer -static-libasan". OK to install? The usual way other libraries use is some special spec file generated by configure in those libraries and then sourced in. But I guess even these STATIC_LIBASAN_LIBS is ok for now. > 2012-11-18 H.J. Lu <hongjiu.lu@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. So, ok for trunk. For PR sanitizer/55379 we'll need to add %{static:%e-fsanitize=address requires dynamic linking} afterwards. Jakub
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