llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

libcxx_tsan configure fails

Open oroppas opened this issue 12 years ago • 15 comments

Bugzilla Link 19750
Resolution FIXED
Resolved on Jul 10, 2014 18:55
Version unspecified
OS Linux
CC @KernelAddress,@kcc

Extended Description

As of 208817,

[1855/2144] Performing configure step for 'libcxx_tsan' FAILED: cd /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-build && /usr/bin/cmake -P /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-configure.cmake && /usr/bin/cmake -E touch /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-configure CMake Error at /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-configure.cmake:16 (message): Command failed: 1

'/usr/bin/cmake' '-DCMAKE_C_COMPILER=/home/ryuta/tools/llvm/src/build/./bin/clang' '-DCMAKE_CXX_COMPILER=/home/ryuta/tools/llvm/src/build/./bin/clang' '-DCMAKE_C_FLAGS= -fsanitize=thread' '-DCMAKE_CXX_FLAGS= -fsanitize=thread' '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_INSTALL_PREFIX:PATH=/home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan' '-GNinja' '/home/ryuta/tools/llvm/src/llvm/projects/libcxx'

See also

/home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-configure-*.log

[1855/2144] Performing configure step for 'libcxx_msan' -- libcxx_msan configure command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/msan/tests/../libcxx_msan/src/libcxx_msan-stamp/libcxx_msan-configure-*.log

ninja: build stopped: subcommand failed.


And here's libcxx_tsan-configure-err.log:

CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54 (message): The C++ compiler "/home/ryuta/tools/llvm/src/build/./bin/clang" is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-build/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/ninja cmTryCompileExec1135728073

[1/2] Building CXX object CMakeFiles/cmTryCompileExec1135728073.dir/testCXXCompiler.cxx.o

[2/2] Linking CXX executable cmTryCompileExec1135728073

FAILED: : && /home/ryuta/tools/llvm/src/build/./bin/clang -fsanitize=thread -Wl,-O1,--sort-common,--as-needed,-z,relro CMakeFiles/cmTryCompileExec1135728073.dir/testCXXCompiler.cxx.o -o cmTryCompileExec1135728073 -rdynamic && :

/home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:124: error: undefined reference to '__sync_lock_test_and_set_16'

/home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:124: error: undefined reference to '__sync_lock_test_and_set_16'

and undefined reference errors continue for '__sync_fetch_and_add_16', etc.

oroppas avatar May 15 '14 01:05 oroppas

I've submitted this change in r212749, thanks for noticing this!

Thanks for committing the patch! I appreciate it.

oroppas avatar Jul 11 '14 01:07 oroppas

I've submitted this change in r212749, thanks for noticing this!

llvmbot avatar Jul 10 '14 20:07 llvmbot

By the way, there's a bug in tsan/CMakeLists.txt which prevents the build process of libcxx instrumented with TSan. In fact,

llvm/projects/compiler-rt/CMakeLists.txt: set(COMPILER_RT_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)

llvm/projects/compiler-rt/CMakeLists.txt: set(COMPILER_RT_TEST_COMPILER_ID Clang)

Here's the patch

Index: llvm/projects/compiler-rt/lib/tsan/CMakeLists.txt

--- llvm/projects/compiler-rt/lib/tsan/CMakeLists.txt (revision 212678) +++ llvm/projects/compiler-rt/lib/tsan/CMakeLists.txt (working copy) @@ -104,7 +104,7 @@

Build libcxx instrumented with TSan.

if(COMPILER_RT_HAS_LIBCXX_SOURCES AND

  • COMPILER_RT_TEST_COMPILER STREQUAL "Clang")
  • COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang") set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_tsan) add_custom_libcxx(libcxx_tsan ${LIBCXX_PREFIX} DEPS ${TSAN_RUNTIME_LIBRARIES} Index: llvm/projects/compiler-rt/test/tsan/CMakeLists.txt =================================================================== --- llvm/projects/compiler-rt/test/tsan/CMakeLists.txt (revision 212678) +++ llvm/projects/compiler-rt/test/tsan/CMakeLists.txt (working copy) @@ -3,7 +3,7 @@ list(APPEND TSAN_TEST_DEPS tsan) endif() if(COMPILER_RT_HAS_LIBCXX_SOURCES AND
  • COMPILER_RT_TEST_COMPILER STREQUAL "Clang")
  • COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang") list(APPEND TSAN_TEST_DEPS libcxx_tsan) set(TSAN_HAS_LIBCXX True) else()

oroppas avatar Jul 10 '14 06:07 oroppas

I tested against r212674 by reverting unconditional setting of __TSAN_HAS_INT128 to 0 in projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc and everything worked fine, or at least I was able to build and all the regression tests passed. Though I'm not sure what fixed the problem, I close this bug report.

oroppas avatar Jul 10 '14 05:07 oroppas

What's wrong with this condition? And how do you want to fix it?

KernelAddress avatar May 23 '14 05:05 KernelAddress

I see that we use __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 to define our custom impelementations for func_xchg and friends. Can we fix this condition somehow?

llvmbot avatar May 23 '14 00:05 llvmbot

Humm... it seems that clang (that was used to build tsan runtime) targets some old processor architecture and rejects to to emit machine code for the 16-byte atomic operations, and instead emits library call. If you can build the program w/o tsan. Then it means that the clang that you use is configured in a different way -- emits machine instructions directly. I don't know why it happens.

KernelAddress avatar May 22 '14 08:05 KernelAddress

I'm building clang, etc. by clang from svn trunk, at this moment r209388.

By unconditionally setting __TSAN_HAS_INT128 to 0 in projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc, libcxx_tsan configure succeeded:

[3/68] Building CXX object projects/compiler-rt/li..._rt.tsan-x86_64.dir/rtl/tsan_interface_atomic.cc.o /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:277:13: warning: unused function 'NoTsanAtomicLoad' [-Wunused-function] static a128 NoTsanAtomicLoad(const volatile a128 *a, morder mo) { ^ /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:305:13: warning: unused function 'NoTsanAtomicStore' [-Wunused-function] static void NoTsanAtomicStore(volatile a128 *a, a128 v, morder mo) { ^ /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:437:13: warning: unused function 'NoTsanAtomicCAS' [-Wunused-function] static bool NoTsanAtomicCAS(volatile a128 *a, a128 c, a128 v, ^ 3 warnings generated. [59/68] Performing configure step for 'libcxx_msan' -- libcxx_msan configure command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/msan/tests/../libcxx_msan/src/libcxx_msan-stamp/libcxx_msan-configure-.log

[60/68] Performing configure step for 'libcxx_msan-with-call' -- libcxx_msan-with-call configure command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/msan/tests/../libcxx_msan-with-call/src/libcxx_msan-with-call-stamp/libcxx_msan-with-call-configure-*.log

[61/68] Performing configure step for 'libcxx_tsan' -- libcxx_tsan configure command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-configure-*.log

[62/68] Performing build step for 'libcxx_tsan' -- libcxx_tsan build command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-build-*.log

[63/68] Performing install step for 'libcxx_tsan' -- libcxx_tsan install command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-install-*.log

[64/68] Performing build step for 'libcxx_msan-with-call' -- libcxx_msan-with-call build command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/msan/tests/../libcxx_msan-with-call/src/libcxx_msan-with-call-stamp/libcxx_msan-with-call-build-*.log

[65/68] Performing install step for 'libcxx_msan-with-call' -- libcxx_msan-with-call install command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/msan/tests/../libcxx_msan-with-call/src/libcxx_msan-with-call-stamp/libcxx_msan-with-call-install-*.log

[66/68] Performing build step for 'libcxx_msan' -- libcxx_msan build command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/msan/tests/../libcxx_msan/src/libcxx_msan-stamp/libcxx_msan-build-*.log

[67/68] Performing install step for 'libcxx_msan' -- libcxx_msan install command succeeded. See also /home/ryuta/tools/llvm/src/build/projects/compiler-rt/lib/msan/tests/../libcxx_msan/src/libcxx_msan-stamp/libcxx_msan-install-*.log

oroppas avatar May 22 '14 06:05 oroppas

Weird. Can your just-build Clang compile/link a program which uses __sync_lock_test_and_set compiler intrinsics? E.g. something like:

int main(void) { int i; __sync_lock_test_and_set(&i, 0); return i; }

I've got the following

ryuta@oroppas $ clang -fsanitize=thread ./sync_lock_test_and_set.c /usr/bin/ld.gold: error: cannot open /usr/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.tsan-x86_64.a: No such file or directory /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_func_entry' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_write4' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_atomic32_exchange' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_read4' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_func_exit' /tmp/sync_lock_test_and_set-f2e3cd.o(.init_array.0+0x0): error: undefined reference to '__tsan_init' clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

I'm not sure in which library these symbols reside.

No, I mean - can you build this program with just-built Clang (the one you get when you run "ninja all" in your build tree)? Can you build it with both with and without -fsanitize=thread? Also, what is your host machine?

Sorry. I messed up.

I'm able to compile without '-fsanitize=thread'

$ /home/ryuta/tools/llvm/src/build/bin/clang ./sync_lock_test_and_set.c

but I'm unable to compile with '-fsanitize=thread'

$ /home/ryuta/tools/llvm/src/build/bin/clang -v -fsanitize=thread ./sync_lock_test_and_set.c clang version 3.5.0 (209003) Target: x86_64-unknown-linux-gnu Thread model: posix Found candidate GCC installation: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0 Found candidate GCC installation: /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0 Selected GCC installation: /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/home/ryuta/tools/llvm/src/build/bin/clang-3.5" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name sync_lock_test_and_set.c -mrelocation-model pic -pic-level 2 -pie-level 2 -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -resource-dir /home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0 -internal-isystem /usr/local/include -internal-isystem /home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/ryuta/tmp -ferror-limit 19 -fmessage-length 104 -fsanitize=thread -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/sync_lock_test_and_set-efc413.o -x c ./sync_lock_test_and_set.c clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/include" #include "..." search starts here: #include <...> search starts here: /usr/local/include /home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0/include /usr/include End of search list. "/usr/bin/ld.gold" -whole-archive /home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0/lib/linux/ libclang_rt.tsan-x86_64.a -no-whole-archive -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/Scrt1.o /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/crtbeginS.o -L/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0 -L/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../.. -L/home/ryuta/tools/llvm/src/build/bin/../lib -L/lib -L/usr/lib /tmp/sync_lock_test_and_set-efc413.o -lpthread -lrt -lm -ldl --dynamic-list=/home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0/lib/ linux/libclang_rt.tsan-x86_64.a.syms -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/crtendS.o /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/crtn.o /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:124: error: undefined reference to '__sync_lock_test_and_set_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:124: error: undefined reference to '__sync_lock_test_and_set_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:131: error: undefined reference to '__sync_fetch_and_add_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:131: error: undefined reference to '__sync_fetch_and_add_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:135: error: undefined reference to '__sync_fetch_and_sub_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:135: error: undefined reference to '__sync_fetch_and_sub_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:139: error: undefined reference to '__sync_fetch_and_and_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:139: error: undefined reference to '__sync_fetch_and_and_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:143: error: undefined reference to '__sync_fetch_and_or_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:143: error: undefined reference to '__sync_fetch_and_or_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:147: error: undefined reference to '__sync_fetch_and_xor_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/ tsan_interface_atomic.cc:147: error: undefined reference to '__sync_fetch_and_xor_16' clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

My host machine is

$ uname -a Linux oroppas 3.14.4-1-ARCH #​1 SMP PREEMPT Tue May 13 16:41:39 CEST 2014 x86_64 GNU/Linux

Apparently, TSan library you build includes implementations for 128-bit atomics, but the compiler intrinsics are turned into function calls like __sync_fetch_and_xor_16 instead of sequences of native instructions (like it does on my machine). Can you check if the build succeeds by unconditionally setting __TSAN_HAS_INT128 to 0 in projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc ?

What version of clang do you use to configure/build repository (/usr/bin/clang -v)?

llvmbot avatar May 22 '14 02:05 llvmbot

Maybe related to this issue. I realized as of r209003 tsan cease to configure libcxx.

In the previous revisions I had the outputs like

/src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-configure-out.log:-- The CXX compiler identification is Clang 3.5.0 ./src/build/projects/compiler-rt/lib/tsan/libcxx_tsan/src/libcxx_tsan-stamp/libcxx_tsan-configure-out.log:-- The C compiler identification is Clang 3.5.0

./src/build/projects/compiler-rt/lib/msan/libcxx_msan/src/libcxx_msan-stamp/libcxx_msan-configure-out.log:-- The CXX compiler identification is Clang ./src/build/projects/compiler-rt/lib/msan/libcxx_msan/src/libcxx_msan-stamp/libcxx_msan-configure-out.log:-- The C compiler identification is Clang

Now only msan configures libcxx.

oroppas avatar May 20 '14 11:05 oroppas

Weird. Can your just-build Clang compile/link a program which uses __sync_lock_test_and_set compiler intrinsics? E.g. something like:

int main(void) { int i; __sync_lock_test_and_set(&i, 0); return i; }

I've got the following

ryuta@oroppas $ clang -fsanitize=thread ./sync_lock_test_and_set.c /usr/bin/ld.gold: error: cannot open /usr/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.tsan-x86_64.a: No such file or directory /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_func_entry' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_write4' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_atomic32_exchange' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_read4' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_func_exit' /tmp/sync_lock_test_and_set-f2e3cd.o(.init_array.0+0x0): error: undefined reference to '__tsan_init' clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

I'm not sure in which library these symbols reside.

No, I mean - can you build this program with just-built Clang (the one you get when you run "ninja all" in your build tree)? Can you build it with both with and without -fsanitize=thread? Also, what is your host machine?

Sorry. I messed up.

I'm able to compile without '-fsanitize=thread'

$ /home/ryuta/tools/llvm/src/build/bin/clang ./sync_lock_test_and_set.c

but I'm unable to compile with '-fsanitize=thread'

$ /home/ryuta/tools/llvm/src/build/bin/clang -v -fsanitize=thread ./sync_lock_test_and_set.c clang version 3.5.0 (209003) Target: x86_64-unknown-linux-gnu Thread model: posix Found candidate GCC installation: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0 Found candidate GCC installation: /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0 Selected GCC installation: /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/home/ryuta/tools/llvm/src/build/bin/clang-3.5" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name sync_lock_test_and_set.c -mrelocation-model pic -pic-level 2 -pie-level 2 -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -resource-dir /home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0 -internal-isystem /usr/local/include -internal-isystem /home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/ryuta/tmp -ferror-limit 19 -fmessage-length 104 -fsanitize=thread -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/sync_lock_test_and_set-efc413.o -x c ./sync_lock_test_and_set.c clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/include" #include "..." search starts here: #include <...> search starts here: /usr/local/include /home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0/include /usr/include End of search list. "/usr/bin/ld.gold" -whole-archive /home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.tsan-x86_64.a -no-whole-archive -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/Scrt1.o /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/crtbeginS.o -L/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0 -L/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../.. -L/home/ryuta/tools/llvm/src/build/bin/../lib -L/lib -L/usr/lib /tmp/sync_lock_test_and_set-efc413.o -lpthread -lrt -lm -ldl --dynamic-list=/home/ryuta/tools/llvm/src/build/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.tsan-x86_64.a.syms -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/crtendS.o /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/crtn.o /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:124: error: undefined reference to '__sync_lock_test_and_set_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:124: error: undefined reference to '__sync_lock_test_and_set_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:131: error: undefined reference to '__sync_fetch_and_add_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:131: error: undefined reference to '__sync_fetch_and_add_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:135: error: undefined reference to '__sync_fetch_and_sub_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:135: error: undefined reference to '__sync_fetch_and_sub_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:139: error: undefined reference to '__sync_fetch_and_and_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:139: error: undefined reference to '__sync_fetch_and_and_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:143: error: undefined reference to '__sync_fetch_and_or_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:143: error: undefined reference to '__sync_fetch_and_or_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:147: error: undefined reference to '__sync_fetch_and_xor_16' /home/ryuta/tools/llvm/src/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:147: error: undefined reference to '__sync_fetch_and_xor_16' clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

My host machine is

$ uname -a Linux oroppas 3.14.4-1-ARCH #​1 SMP PREEMPT Tue May 13 16:41:39 CEST 2014 x86_64 GNU/Linux

oroppas avatar May 20 '14 08:05 oroppas

Weird. Can your just-build Clang compile/link a program which uses __sync_lock_test_and_set compiler intrinsics? E.g. something like:

int main(void) { int i; __sync_lock_test_and_set(&i, 0); return i; }

I've got the following

ryuta@oroppas $ clang -fsanitize=thread ./sync_lock_test_and_set.c /usr/bin/ld.gold: error: cannot open /usr/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.tsan-x86_64.a: No such file or directory /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_func_entry' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_write4' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_atomic32_exchange' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_read4' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_func_exit' /tmp/sync_lock_test_and_set-f2e3cd.o(.init_array.0+0x0): error: undefined reference to '__tsan_init' clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

I'm not sure in which library these symbols reside.

No, I mean - can you build this program with just-built Clang (the one you get when you run "ninja all" in your build tree)? Can you build it with both with and without -fsanitize=thread? Also, what is your host machine?

llvmbot avatar May 19 '14 21:05 llvmbot

FYI, here's how I configured

CC=/usr/bin/clang
CXX=/usr/bin/clang++
cmake -G Ninja
-DCMAKE_INSTALL_PREFIX:PATH=/usr
-DCMAKE_BUILD_TYPE:STRING="Release"
-DBUILD_SHARED_LIBS:BOOL=ON
-DLLVM_TARGETS_TO_BUILD:STRING="X86;NVPTX"
-DLLVM_BINUTILS_INCDIR:PATH=/usr/include
-DLLVM_BUILD_TESTS:BOOL=ON
-DLLVM_BUILD_TOOLS:BOOL=ON
-DLLVM_INCLUDE_TESTS:BOOL=ON
-DLLVM_INCLUDE_TOOLS:BOOL=ON
-DLLVM_ENABLE_CXX1Y:BOOL=OFF
-DLLVM_ENABLE_LIBCXX:BOOL=ON
-DLLVM_ENABLE_THREADS:BOOL=ON
-DLLVM_ENABLE_FFI:BOOL=ON
-DLLVM_ENABLE_ASSERTIONS:BOOL=OFF
-DLLVM_ENABLE_WARNINGS:BOOL=ON
-DLLVM_ENABLE_WERROR:BOOL=OFF
-DLLVM_ENABLE_ZLIB:BOOL=ON
-DCLANG_INCLUDE_TESTS:BOOL=ON
-DLIBCLANG_BUILD_STATIC:BOOL=OFF
-DCOMPILER_RT_BUILD_SHARED_ASAN:BOOL=ON
-DCOMPILER_RT_CAN_EXECUTE_TESTS:BOOL=ON
-DCOMPILER_RT_INCLUDE_TESTS:BOOL=ON
-DLIBCXX_CXX_ABI:STRING="libcxxabi"
-DLIBCXX_LIBCXXABI_INCLUDE_PATHS:PATH=$HOME/tools/libc++abi/libcxxabi/include
-DLIBCXX_ENABLE_SHARED:BOOL=ON
-DLIBCXX_ENABLE_CXX0X:BOOL=OFF
-DLIBCXX_ENABLE_ASSERTIONS:BOOL=OFF
-DFFI_INCLUDE_DIR:PATH=pkg-config --variable=includedir libffi
-DFFI_LIBRARY_DIR:PATH=pkg-config --variable=libdir libffi
-DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
../llvm

oroppas avatar May 17 '14 08:05 oroppas

Weird. Can your just-build Clang compile/link a program which uses __sync_lock_test_and_set compiler intrinsics? E.g. something like:

int main(void) { int i; __sync_lock_test_and_set(&i, 0); return i; }

I've got the following

ryuta@oroppas $ clang -fsanitize=thread ./sync_lock_test_and_set.c /usr/bin/ld.gold: error: cannot open /usr/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.tsan-x86_64.a: No such file or directory /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_func_entry' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_write4' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_atomic32_exchange' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_read4' /tmp/sync_lock_test_and_set-f2e3cd.o:./sync_lock_test_and_set.c:function main: error: undefined reference to '__tsan_func_exit' /tmp/sync_lock_test_and_set-f2e3cd.o(.init_array.0+0x0): error: undefined reference to '__tsan_init' clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

I'm not sure in which library these symbols reside.

oroppas avatar May 17 '14 08:05 oroppas

Weird. Can your just-build Clang compile/link a program which uses __sync_lock_test_and_set compiler intrinsics? E.g. something like:

int main(void) { int i; __sync_lock_test_and_set(&i, 0); return i; }

llvmbot avatar May 16 '14 01:05 llvmbot