[Bug sanitizer/55374] [asan] -static-libasan -static-libstdc++ doesn't work
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 22 10:34:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55374
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-22 10:33:53 UTC ---
The patch isn't sufficient. For both -static-libasan -fsanitize=address
and just -fsanitize=address, we want -Bstatic -lasan -Bdynamic resp. -lasan
to go before all occurrences of the -lstdc++ or -lpthread or -lc, whether those
come from user command line options or language specific driver hacks or specs
expansion. For dynamic -lasan it is obviously enough if it goes before the
first occurrence of -lstdc++, -lpthread or -lc, whatever is first, so in theory
we could just add it as the very first (or one of the first) ld/collect2
command line options. libasan unfortunately crashes badly (without giving
useful messages) if e.g. -lpthread comes before -lasan. And -lpthread can
either come from -pthread on the command line, or -lpthread, similarly -lstdc++
from just linking with g++, or from -lstdc++ on the command line.
Unfortunately, -Wl,-Bstatic resp. -Wl,-Bdynamic might be passed directly on the
command line too, at random positions, so adding blindly -Bstatic -lasan
-Bdynamic isn't very good idea either, especially because those options aren't
counted, -Bstatic -Bstatic -lasan -Bdynamic will result in -Bdynamic after it.
More information about the Gcc-bugs
mailing list