http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55354
--- Comment #24 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-11-23 08:13:11 UTC --- When I rebuild libtsan with -fPIE instead of -fPIC in the Makefile, and g++ -shared -Wl,--whole-archive -o libtsanx.so libtsan.a -ldl -lpthread (note that .libs/*.o are still built with -fPIC because libtool overrides those flags and adds its -fPIC at the end), then this link fails with: /usr/bin/ld: libtsan.a(tsan_rtl.o): relocation R_X86_64_TPOFF32 against `_ZN6__tsan22cur_thread_placeholderE' can not be used when making a shared object; recompile with -fPIC libtsan.a(tsan_rtl.o): could not read symbols: Bad value collect2: error: ld returned 1 exit status (obviously, local-exec model would need to patch the insn at dynamic linking time, making the library DT_TEXTREL (not acceptable for SELinux, not allowed for x86_64 at all)). Yes, I see the code generation differences, but the functions are huge anyway, is it really so crucial that you'd want to make another libtsan_pie.a for it? BTW, the tsan that was added to GCC yesterday doesn't have -ftls-model=initial-exec even, so it is even slower. -ftls-model=initial-exec can only be done for *-*-linux* targets btw, I don't think other dynamic linkers support dlopening IE model shared libraries. E.g. libgomp has in its configure.tgt if test $gcc_cv_have_tls = yes ; then case "${target}" in *-*-linux*) XCFLAGS="${XCFLAGS} -ftls-model=initial-exec" ;; esac fi so libsanitizer/configure.tgt would need to add it to say TSAN_CXXFLAGS var that would be substituted by configure. Would be nice if you could check the numerous warnings from tsan build, e.g. it seems the ALWAYS_INLINE macro doesn't include the inline keyword, and you are using it on functions that don't have inline keyword, which gives a warning and if it is inlined, it is by pure luck. Either you should add inline keywords manually, or put inline keyword into ALWAYS_INLINE macro. There are other warnings...