http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55374
--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-22 13:35:28 UTC --- Created attachment 29249 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29249 gcc48-pr55374.patch Untested fix. If -static-libasan is missing, it just moves -lasan early on ld command line (before %o, i.e. user input arguments), as we error out on -static and user -Bstatic would go after it, I think it is fine this way. For -static-libasan, we don't pass -lasan at all for -shared (we don't want many (partial) copies of libasan.a in various shared libraries plus executable), and just for executable link with -Bstatic --whole-archive -lasan --no-whole-archive -Bdynamic early on the command line.