Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to build llvm 19 keeps failing recently #98523

Closed
mfvalin opened this issue Jul 11, 2024 · 0 comments · Fixed by #98564
Closed

attempt to build llvm 19 keeps failing recently #98523

mfvalin opened this issue Jul 11, 2024 · 0 comments · Fixed by #98564
Assignees
Labels
build-problem compiler-rt:nsan Numerical stability sanitizer

Comments

@mfvalin
Copy link

mfvalin commented Jul 11, 2024

[8/85] Linking CXX shared library /data1/my-llvm/build-19/lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.nsan.so
FAILED: /data1/my-llvm/build-19/lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.nsan.so
: && /data1/my-llvm/build-19/./bin/clang++ --target=x86_64-unknown-linux-gnu -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werr .....
.dir/nsan_suppressions.cpp.o compiler-rt/lib/nsan/CMakeFiles/RTNsan_dynamic_version_script_dummy.x86_64.dir/dummy.cpp.o -lstdc++ -lgcc_s -lc -ldl -lrt -lm -lpthread && :
/usr/bin/ld: compiler-rt/lib/nsan/CMakeFiles/RTNsan_dynamic.x86_64.dir/nsan.cpp.o: .preinit_array section is not allowed in DSO
/usr/bin/ld: failed to set dynamic section sizes: nonrepresentable section on output
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

build attempted with clang++ 18, clang++ 19 (last successful build a few days ago), g++ 11
all attempts end with the same ld error

my cmake command was

cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release -DFLANG_ENABLE_WERROR=OFF -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DLLVM_LIT_ARGS=-v -DLLVM_ENABLE_PROJECTS="clang;mlir;lld;flang;openmp" -DLLVM_ENABLE_RUNTIMES="compiler-rt;libc;libcxx;libcxxabi;libunwind" -DLLVM_OPTIMIZED_TABLEGEN=ON

@EugeneZelenko EugeneZelenko added build-problem compiler-rt:nsan Numerical stability sanitizer and removed new issue labels Jul 11, 2024
@MaskRay MaskRay self-assigned this Jul 12, 2024
aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this issue Jul 14, 2024
llvm#94322 defines .preinit_array to initialize nsan early.
DT_PREINIT_ARRAY can only be used with the main executable. GNU ld would
complain when a DSO has .preinit_array. Therefore,
nsan_preinit.cpp cannot be linked into `libclang_rt.nsan.so` (llvm#98415).

Working with @alexander-shaposhnikov, we noticed that `Nsan-x86_64-Test
--gtest_output=json` without `.preinit_array` will sigsegv. This is
because googletest with the JSON output calls `localtime_r` , which
calls `free(0)` and fails when `REAL(free)` remains uninitialized
(nullptr). This is benign with the default output because malloc/free
are all paired and `REAL(free)(ptr)` is not called.

To fix the unittest failure, `__nsan_init` needs to be called early
(.preinit_array).
`asan/tests/CMakeLists.txt:ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS` ues
`-fsanitize=address` to ensure `asan_preinit.cpp.o` is linked into the
unittest executable. Port the approach and remove
`NSAN_TEST_RUNTIME_OBJECTS`.

Fix llvm#98523

Pull Request: llvm#98564
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-problem compiler-rt:nsan Numerical stability sanitizer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants