Dmitry Vyukov wrote:
Apologies for what may be a second thread - I can only reply in-thread
if I log into Google Groups; I emailed the original question, but
received no email when you replied. I've used the same subject, in the
hope it will be appended to the thread.
> -fsanitize=thread is a driver flag, not linker.
Okay. I've just googled about driver flags; I'd never heard of the
compiler driver before. I presume it is a flag which directs a range of
related behaviours.
> Why do you link with ld? This looks wrong. You need to use 'gcc
> -shared' to link shared libraries.
I just always have... ld does linking, you link to produce shared
libraries. It works when not using tsan, so it's been okay for some years.
> p.s. archives can contain PIC code. In fact tsan runtime clang is a
> static library (.a) built with -fPIC.
Right. It made no sense to me that it would not be possible.
> p.s. I believe executables can be built with both -fPIE and -fPIC.
> -fPIC will lead to slightly slower code, but both should work.
Yes. This I thought also, from what I'd read about TLS. I begin to
suspect there's a good deal of incorrect information out on the net, in
this matter.
Thankyou for you reply.
However, I'm still not clear about what to do :-)
I've just found a little bit more information, from the clang docs for
AddressSanitizer. They say;
"Simply compile and link your program with -fsanitize=address flag. The
AddressSanitizer run-time library should be linked to the final
executable, so make sure to use clang (not ld) for the final link step.
When linking shared libraries, the AddressSanitizer run-time is not
linked, so -Wl,-z,defs may cause link errors (don’t use it with
AddressSanitizer)."
This indicates I do *nothing* different with my library; I only need to
build the final executable with the necessary thread sanitizer flags.