4

I am trying to hunt down some deadlock in multi-threaded code which uses a condition variable. Somebody advised using thread sanitizer. So I compiled LLVM from source and enabled thread sanitizer

LLVM CMake configuration

LLVM built fine, but when I try to build my project I run into a lot of warnings of this kind:

: && /home/dzenan/LLVM-rel/bin/clang++  -fsanitize=thread  -Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winvalid-pch -Wno-format-nonliteral -Wpointer-arith -Wshadow -Wunused -Wwrite-strings -funit-at-a-time -Wno-strict-overflow -Wno-deprecated -Wno-invalid-offsetof -Wno-undefined-var-template -Woverloaded-virtual  -w  -O2 -g -DNDEBUG  -fsanitize=thread Modules/ThirdParty/VNL/src/vxl/v3p/netlib/tests/CMakeFiles/netlib_lsmrTest2.dir/lsmrTest2.cxx.o  -o bin/netlib_lsmrTest2  -Wl,-rpath,/home/dzenan/ITK-git-clang/lib lib/libitkv3p_netlib-5.0.so.1 -lm && :
/usr/bin/ld: cannot find /home/dzenan/LLVM-rel/lib/clang/7.0.0/lib/linux/libclang_rt.tsan-x86_64.a: No such file or directory
/usr/bin/ld: cannot find /home/dzenan/LLVM-rel/lib/clang/7.0.0/lib/linux/libclang_rt.tsan_cxx-x86_64.a: No such file or directory
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
[1507/5739] Building C object Modules/ThirdParty/VNL/src/vxl/v3p/netlib/CMakeFiles/itknetlib.dir/triangle.c.o
FAILED: bin/netlib_lsqrTest1

What am I doing wrong and how to fix it?

Dženan
  • 3,329
  • 3
  • 31
  • 44

1 Answers1

0

I had this problem too. In my case, although these libraries were present in the system, they were not in a place where the linker could find them.

I solved that problem in a one-shot way by running this in the terminal I was using for compilation (replace the path with your local equivalent): export LD_LIBRARY_PATH=/lib64/clang/14.0.3/lib/linux/

It is only applied to the current terminal though. You may need to repeat that process each time, or use some persistent way of setting this for it to work everywhere.

graslany
  • 1
  • 1