Issue 86901
Summary clang can't build libc++ with thread sanitizer support
Labels clang, libc++
Assignees
Reporter sogartar
    Configure command
```
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

BUILD_TYPE=Debug
SRC_DIR=$SCRIPT_DIR/repo/runtimes
BUILD_DIR=$SCRIPT_DIR/build/libc++/$BUILD_TYPE

cmake \
  -G Ninja \
  -B "$BUILD_DIR" \
  -S "$SRC_DIR" \
 -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
  -DCMAKE_C_COMPILER=clang-17 \
 -DCMAKE_CXX_COMPILER=clang++-17 \
  -DLLVM_USE_LINKER=lld-17 \
 -DCMAKE_CXX_FLAGS="-fsanitize=thread" \
 -DCMAKE_C_FLAGS="-fsanitize=thread" \
 -DCMAKE_STATIC_LINKER_FLAGS="-fsanitize=thread" \
 -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=thread" \
 -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread" \
 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"
```

Build command:
```
cmake --build "$BUILD_DIR" \
  --target cxx cxx_experimental
```

Error:
```
FAILED: lib/libunwind.so.1.0 
: && /usr/bin/clang-17 -fPIC -fsanitize=thread -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -fsanitize=thread -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld-17 -Wl,--color-diagnostics -shared -Wl,-soname,libunwind.so.1 -o lib/libunwind.so.1.0 libunwind/src/CMakeFiles/unwind_shared_objects.dir/libunwind.cpp.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/Unwind-EHABI.cpp.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/Unwind-seh.cpp.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/UnwindLevel1.c.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/UnwindLevel1-gcc-ext.c.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/Unwind-sjlj.c.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/Unwind-wasm.c.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/UnwindRegistersRestore.S.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/UnwindRegistersSave.S.o -lgcc_s  -lgcc  -lc  -ldl  -lpthread && :
ld.lld-17: error: undefined symbol: __tsan_func_entry
>>> referenced by libunwind.cpp:0 (/home/bpetkant/ws/llvm/repo/libunwind/src/libunwind.cpp:0)
>>> libunwind/src/CMakeFiles/unwind_shared_objects.dir/libunwind.cpp.o:(__unw_init_local)
```

I am using `clang-17` from the Ubuntu 22.04 package as described here https://apt.llvm.org/.
Trying to build on commit 14ba782a87e16e9e15460a51f50e67e2744c26d9.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to