Message ID | 1480716293-13606-1-git-send-email-wtc@google.com |
---|---|
State | Accepted |
Commit | f22da2cdf90dc892d483e2d4003cffc0500816f6 |
Headers | show |
2016-12-02 23:04 GMT+01:00 Wan-Teh Chang <wtc-at-google.com@ffmpeg.org>: > -pie was added to C flags for ThreadSanitizer in commit > 19f251a2882a8d0779b432e63bf282e4d9c443bb. Under clang 3.8.0, the -pie > flag causes a compiler warning and a linker error when running configure > --toolchain=clang-tsan. Does the patch have any effect when using gcc? Carl Eugen
On Mon, Dec 12, 2016 at 6:42 AM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote: > 2016-12-02 23:04 GMT+01:00 Wan-Teh Chang <wtc-at-google.com@ffmpeg.org>: >> -pie was added to C flags for ThreadSanitizer in commit >> 19f251a2882a8d0779b432e63bf282e4d9c443bb. Under clang 3.8.0, the -pie >> flag causes a compiler warning and a linker error when running configure >> --toolchain=clang-tsan. > > Does the patch have any effect when using gcc? Hi Carl, Yes, the patch modifies the code shared by --toolchain=clang-tsan and --toolchain=gcc-tsan. I am using Ubuntu 14.04 LTS, which comes with gcc 4.8.4. gcc 4.8.4 does NOT work with and without my patch. I got an error in config.log like this: ========== check_cc BEGIN /tmp/ffconf.jceENASz.c 1 int main(void){ return 0; } END /tmp/ffconf.jceENASz.c gcc -fsanitize=thread -fPIE -fPIC -c -o /tmp/ffconf.LuPWPOJB.o /tmp/ffconf.jceENASz.c gcc -fsanitize=thread -pie -fPIC -o /tmp/ffconf.03RtebJv /tmp/ffconf.LuPWPOJB.o /tmp/ffconf.LuPWPOJB.o: In function `_GLOBAL__sub_I_00099_0_ffconf.jceENASz.c': ffconf.jceENASz.c:(.text+0x10): undefined reference to `__tsan_init' collect2: error: ld returned 1 exit status C compiler test failed. ========== This looks like the gcc 4.9.2 bug described in https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1413474. Unfortunately, I can't fix the undefined reference to __tsan_init even if I add -ltsan to the linker flags. I then built gcc 6.2.0 from sources and tested it. gcc 6.2.0 works with and without my patch. So I consider my patch safe for gcc. If there is any other gcc version I should test my patch with, please let me know. Thanks, Wan-Teh Chang
2016-12-12 20:55 GMT+01:00 Wan-Teh Chang <wtc-at-google.com@ffmpeg.org>:
> gcc 6.2.0 works with and without my patch.
Thank you.
Carl Eugen
On Fri, Dec 02, 2016 at 02:04:53PM -0800, Wan-Teh Chang wrote: > -pie was added to C flags for ThreadSanitizer in commit > 19f251a2882a8d0779b432e63bf282e4d9c443bb. Under clang 3.8.0, the -pie > flag causes a compiler warning and a linker error when running configure > --toolchain=clang-tsan. Here is an excerpt from config.log: > > clang ... -fsanitize=thread -pie -std=c11 -fomit-frame-pointer -pthread -c -o /tmp/ffconf.hL61stP9.o /tmp/ffconf.YO6ZaSFG.c > clang: warning: argument unused during compilation: '-pie' > clang -fsanitize=thread -pie -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.W5c2e41l /tmp/ffconf.hL61stP9.o -lbz2 -pthread > /usr/bin/ld: /tmp/ffconf.hL61stP9.o: relocation R_X86_64_PC32 against undefined symbol `atan2f@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC > /usr/bin/ld: final link failed: Bad value > clang: error: linker command failed with exit code 1 (use -v to see invocation) > > To be conservative, I changed -pie to -fPIE. But the documentation seems > to imply just -fsanitize=thread is enough: > > http://clang.llvm.org/docs/ThreadSanitizer.html > https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual > > Signed-off-by: Wan-Teh Chang <wtc@google.com> > --- > configure | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) applied thx [...]
diff --git a/configure b/configure index ee473b9..0e1ae61 100755 --- a/configure +++ b/configure @@ -3523,7 +3523,7 @@ case "$toolchain" in ;; *-tsan) cc_default="${toolchain%-tsan}" - add_cflags -fsanitize=thread -pie + add_cflags -fsanitize=thread -fPIE add_ldflags -fsanitize=thread -pie case "$toolchain" in gcc-tsan)
-pie was added to C flags for ThreadSanitizer in commit 19f251a2882a8d0779b432e63bf282e4d9c443bb. Under clang 3.8.0, the -pie flag causes a compiler warning and a linker error when running configure --toolchain=clang-tsan. Here is an excerpt from config.log: clang ... -fsanitize=thread -pie -std=c11 -fomit-frame-pointer -pthread -c -o /tmp/ffconf.hL61stP9.o /tmp/ffconf.YO6ZaSFG.c clang: warning: argument unused during compilation: '-pie' clang -fsanitize=thread -pie -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.W5c2e41l /tmp/ffconf.hL61stP9.o -lbz2 -pthread /usr/bin/ld: /tmp/ffconf.hL61stP9.o: relocation R_X86_64_PC32 against undefined symbol `atan2f@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value clang: error: linker command failed with exit code 1 (use -v to see invocation) To be conservative, I changed -pie to -fPIE. But the documentation seems to imply just -fsanitize=thread is enough: http://clang.llvm.org/docs/ThreadSanitizer.html https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual Signed-off-by: Wan-Teh Chang <wtc@google.com> --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)