https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62105

            Bug ID: 62105
           Summary: sanitizer libraries in wrong command line position in
                    link spec file
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jtaylor.debian at googlemail dot com

when linking a file with -fsanitize=* the sanatizer library (e.g. -ltsan is
placed before the object on the command line:

gcc-4.10 test.c -fsanitize=thread -v -fPIC -shared 2>&1 | grep --color tsan

[...] -ltsan /tmp/cc6ovqw5.o -lgcc --as-needed -lgcc_s [...]

this is problematic on distributions like Ubuntu which add the --as-needed flag
to the beginning of the the gcc link spec. This causes the linker to drop the
-ltsan because when it has parsed the -ltsan option it determines it as not
needed and drops it. The object needing it only comes later.
The fix would be to move the library after the object needing it (like -lgcc).

In principle this is Ubuntus issue as they add the non standard as-needed flag,
but as the other libraries like -lgcc and -lc are placed correctly maybe the
-l*san can be moved too?

I used a gcc built from recent SVN head on Ubuntu 14.04 amd64.
/tmp/jtaylor $ gcc-4.10 --version
gcc (GCC) 4.10.0 20140812 (experimental)

Reply via email to