ThreadSanitizer linker flags

357 views
Skip to first unread message

Neven Sajko

unread,
Nov 17, 2014, 8:08:42 PM11/17/14
to thread-s...@googlegroups.com
Hi,

this would be the first time I use ThreadSanitizer!

When I try to build something with gcc 4.9.2 and tsan,
I get an error like this:

 /usr/bin/cc -march=native -O2 -pipe -fstack-protector-strong
  --param=ssp-buffer-size=4 -fpie -ggdb3 -fvar-tracking-assignments -Wall
  -Wextra -fsanitize=thread -ggdb3 -fvar-tracking-assignments -Wall -Wextra
  -fsanitize=thread -Wl,-pie
  CMakeFiles/cmTryCompileExec1917069538.dir/testCCompiler.c.o -o
  cmTryCompileExec1917069538 -rdynamic

  cc: error: -fsanitize=thread linking must be done with -pie or -shared

Notice that the -pie option is given with -Wl.
But, when -pie option is given without -Wl, no error happens!

Could this be a bug?

Alexey Samsonov

unread,
Nov 17, 2014, 8:30:42 PM11/17/14
to thread-s...@googlegroups.com
Hi,

I wouldn't call it a bug. GCC driver enforces that user explicitly passes "-pie" at link step. Otherwise, TSan wouldn't
work. Looks like GCC just doesn't respect -Wl flags, only passes them directly to linker.

Passing "-pie" to GCC instead of passing it directly to linker makes more sense - in this case GCC driver might
want to adjust all kinds of related flags (for instance, -ftls-model) accordingly. I think you should just do that.
 

--
You received this message because you are subscribed to the Google Groups "thread-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thread-sanitiz...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alexey Samsonov, Mountain View, CA

Neven Sajko

unread,
Nov 17, 2014, 8:45:14 PM11/17/14
to thread-s...@googlegroups.com
OK Alexey,
Thank you!

On 18 November 2014 02:30, 'Alexey Samsonov' via thread-sanitizer
<thread-s...@googlegroups.com> wrote:
> Hi,
>
> I wouldn't call it a bug. GCC driver enforces that user explicitly passes
> "-pie" at link step. Otherwise, TSan wouldn't
> work. Looks like GCC just doesn't respect -Wl flags, only passes them
> directly to linker.
>
> Passing "-pie" to GCC instead of passing it directly to linker makes more
> sense - in this case GCC driver might
> want to adjust all kinds of related flags (for instance, -ftls-model)
> accordingly. I think you should just do that.
>
>
>
> --
> Alexey Samsonov, Mountain View, CA
>
> --
Reply all
Reply to author
Forward
0 new messages