Skip to content

compiler-rt build missing library file #58680

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

Closed
liam-clink opened this issue Oct 28, 2022 · 9 comments · Fixed by #72955 or #75090
Closed

compiler-rt build missing library file #58680

liam-clink opened this issue Oct 28, 2022 · 9 comments · Fixed by #72955 or #75090
Labels

Comments

@liam-clink
Copy link

liam-clink commented Oct 28, 2022

Build for the full LLVM project (minus libc) completes, but fails tests due to a missing library file when running check-all. What could be causing this?

Error message:

********************
FAIL: ThreadSanitizer-x86_64 :: real_deadlock_detector_stress_test.cpp (63376 of 77101)
******************** TEST 'ThreadSanitizer-x86_64 :: real_deadlock_detector_stress_test.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1';      /home/liam/Downloads/llvm-project-15.0.3.src/build/./bin/clang  --driver-mode=g++ -fsanitize=thread -Wall  -m64  -msse4.2   -gline-tables-only -I/home/liam/Downloads/llvm-project-15.0.3.src/compiler-rt/test/tsan/../ -std=c++11 -I/home/liam/Downloads/llvm-project-15.0.3.src/compiler-rt/test/tsan/../ -nostdinc++ -I/home/liam/Downloads/llvm-project-15.0.3.src/build/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 -O1 /home/liam/Downloads/llvm-project-15.0.3.src/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cpp /home/liam/Downloads/llvm-project-15.0.3.src/build/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/lib/libc++.a -o /home/liam/Downloads/llvm-project-15.0.3.src/build/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/real_deadlock_detector_stress_test.cpp.tmp &&  /home/liam/Downloads/llvm-project-15.0.3.src/build/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/real_deadlock_detector_stress_test.cpp.tmp 2>&1 | FileCheck /home/liam/Downloads/llvm-project-15.0.3.src/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cpp
--
Exit Code: 1

Command Output (stderr):
--
clang-15: error: no such file or directory: '/home/liam/Downloads/llvm-project-15.0.3.src/build/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/lib/libc++.a'

--

Build command:

cmake -S ../llvm -B . -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="bolt;llvm;clang;lld;lldb;clang-tools-extra;cross-project-tests;libclc;polly;pstl" -DLLVM_ENABLE_RUNTIMES="openmp;libcxx;libcxxabi;libunwind;compiler-rt" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLIBCXX_USE_COMPILER_RT=YES -DLLVM_USE_LINKER=lld -DLIBCXXABI_USE_LLVM_UNWINDER=YES -DLLVM_INSTALL_UTILS=ON -DCMAKE_INSTALL_PREFIX=$HOME/llvm15_temp
@asb
Copy link
Contributor

asb commented Dec 21, 2022

Same issue for the following build command:

    cmake -G Ninja -DCMAKE_BUILD_TYPE="Release" \
      -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" \
      -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi" \
      -DLLVM_ENABLE_ASSERTIONS=ON \
      -DLLVM_CCACHE_BUILD=ON \
      -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
      -DLLVM_ENABLE_LLD=True \
      -DLLVM_TARGETS_TO_BUILD="all" \
      ../../llvm

Failed tests (from ninja check-all):

Failed Tests (23):
  ThreadSanitizer-x86_64 :: Linux/dlopen_static_tls.cpp
  ThreadSanitizer-x86_64 :: atexit5.cpp
  ThreadSanitizer-x86_64 :: compare_exchange.cpp
  ThreadSanitizer-x86_64 :: custom_mutex0.cpp
  ThreadSanitizer-x86_64 :: custom_mutex1.cpp
  ThreadSanitizer-x86_64 :: custom_mutex2.cpp
  ThreadSanitizer-x86_64 :: custom_mutex3.cpp
  ThreadSanitizer-x86_64 :: custom_mutex4.cpp
  ThreadSanitizer-x86_64 :: custom_mutex5.cpp
  ThreadSanitizer-x86_64 :: deadlock_detector_stress_test.cpp
  ThreadSanitizer-x86_64 :: dl_iterate_phdr.cpp
  ThreadSanitizer-x86_64 :: dlclose.cpp
  ThreadSanitizer-x86_64 :: ignore_lib0.cpp
  ThreadSanitizer-x86_64 :: ignore_lib1.cpp
  ThreadSanitizer-x86_64 :: ignore_lib2.cpp
  ThreadSanitizer-x86_64 :: ignore_lib3.cpp
  ThreadSanitizer-x86_64 :: ignore_lib4.cpp
  ThreadSanitizer-x86_64 :: ignore_lib5.cpp
  ThreadSanitizer-x86_64 :: ignore_lib6.cpp
  ThreadSanitizer-x86_64 :: ignored-interceptors-mmap.cpp
  ThreadSanitizer-x86_64 :: libcxx/std_shared_ptr.cpp
  ThreadSanitizer-x86_64 :: load_shared_lib.cpp
  ThreadSanitizer-x86_64 :: real_deadlock_detector_stress_test.cpp

Almost all are due to missing libc++.a, but some are due to failed includes (e.g. <new>, <string>).

@pauljohnston2009
Copy link

same issue when running

./test-release.sh -release 17.0.2 -final -triple x86_64-linux-gnu -use-ninja

did you find any solution to this?

@pauljohnston2009
Copy link

I have found a few things, but still no real solution.

The missing files seem to be generated from "add_custom_libcxx"

add_custom_libcxx(libcxx_tsan_${arch} ${LIBCXX_PREFIX}

This appears to be similar to the fuzzer tests, which are working fine (and generate the needed files)

https://github.com/llvm/llvm-project/blob/3c356eef31ab309466c198de3915037b068d8861/compiler-rt/lib/fuzzer/CMakeLists.txt#L161C5-L161C22

ie.

$ ls final/Phase3/Release/llvmCore-17.0.3-final.obj/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/
src  tmp
$ ls final/Phase3/Release/llvmCore-17.0.3-final.obj/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64
bin  build.ninja  CMakeCache.txt  CMakeFiles  cmake_install.cmake  include  lib  libcxx  libcxxabi  lit.tests  llvm-lit  src  tmp

I can get the files to be generated (and the tests to pass) by doing

// wait for tests to fail
cd final/Phase3/Release/llvmCore-17.0.3-final.obj/
cmake .
ninja check-tsan 

note: The check-tsan target does not exist before running cmake ., and I have to let the tests fail first before cmake . will generate the check-tsan target.

From my understanding, cmake . should not change anything since it should use the same configuration from the cmake cache.

I also noticed that the tests compile fine without the extra args added by

config.substitutions.append(("%link_libcxx_tsan", libcxx_a))

The -nostdinc++ and explicit link of "final/Phase3/Release/llvmCore-17.0.3-final.obj/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/lib/libc++.a" is preventing it from using the libcxx from Phase3.

What is the reasoning for the custom libcxx? Is it fine to use the one from the Phase3 install directory?

Hopefully this is of some help.

@tstellar
Copy link
Collaborator

@dvyukov Do you have ideas about this? I'm seeing similar errors in the official release builds: https://github.com/llvm/llvm-project/actions/runs/6861861275/job/18658422688

@tstellar
Copy link
Collaborator

@petrhosek I know it's been a while since you worked on this, but do you have any ideas here?

@dvyukov
Copy link
Collaborator

dvyukov commented Nov 20, 2023

No, I don't have any ideas. ninja check-tsan used to pass for me.

@pauljohnston2009
Copy link

I had a look at those logs, not sure if its related, but I am also getting the file differences in hwasan too. I tried doing a phase 4 to see if it was something like #11572 (comment)

# Comparing Phase 3 and Phase 4 files
file hwasan_tag_mismatch_riscv64.S.o differs between phase 3 and phase 4
file hwasan_setjmp_riscv64.S.o differs between phase 3 and phase 4
file hwasan_tag_mismatch_aarch64.S.o differs between phase 3 and phase 4
file hwasan_setjmp_aarch64.S.o differs between phase 3 and phase 4
file hwasan_tag_mismatch_riscv64.S.o differs between phase 3 and phase 4
file hwasan_setjmp_riscv64.S.o differs between phase 3 and phase 4
file hwasan_tag_mismatch_aarch64.S.o differs between phase 3 and phase 4
file hwasan_setjmp_aarch64.S.o differs between phase 3 and phase 4
file hwasan_tag_mismatch_riscv64.S.o differs between phase 3 and phase 4
file hwasan_setjmp_riscv64.S.o differs between phase 3 and phase 4
file hwasan_tag_mismatch_aarch64.S.o differs between phase 3 and phase 4
file hwasan_setjmp_aarch64.S.o differs between phase 3 and phase 4
file hwasan_tag_mismatch_riscv64.S.o differs between phase 3 and phase 4
file hwasan_setjmp_riscv64.S.o differs between phase 3 and phase 4
file hwasan_tag_mismatch_aarch64.S.o differs between phase 3 and phase 4
file hwasan_setjmp_aarch64.S.o differs between phase 3 and phase 4

Should I open another ticket for this? Do you think its safe to use the output even with the file differences and test failures?

tstellar added a commit to tstellar/llvm-project that referenced this issue Nov 21, 2023
The test-depends target contained all the dependencies needed to run the
runtimes tests, but it was never added as a dependency of check-all.
This led to some of the tsan tests to fail, since the custom libcxx
build they were using was never built.

Fixes llvm#58680
@petrhosek
Copy link
Member

@tstellar I'll try to reproduce this locally and will report back.

@tstellar
Copy link
Collaborator

@petrhosek I have a fix here: #72955

tstellar added a commit that referenced this issue Nov 22, 2023
The test-depends target contained all the dependencies needed to run the
runtimes tests, but it was never added as a dependency of check-all.
This caused some of the tsan tests to fail, since the custom libcxx
build the tests were looking for was never built. Besides the tsan
failures, this fixes all the other test failures I was seeing with:
cmake -G Ninja -B release-build -S llvm \
        -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
        -DCMAKE_BUILD_TYPE=Release \
        -DLLVM_ENABLE_ASSERTIONS=OFF \
        -DLLVM_ENABLE_PROJECTS="clang;lld" \
        -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt"

This is the same configuration the test-release.sh script uses, so I'm
hoping this will also fix all the test failures we've been seeing when
building the releases.

Fixes #58680
tru pushed a commit that referenced this issue Nov 27, 2023
The test-depends target contained all the dependencies needed to run the
runtimes tests, but it was never added as a dependency of check-all.
This caused some of the tsan tests to fail, since the custom libcxx
build the tests were looking for was never built. Besides the tsan
failures, this fixes all the other test failures I was seeing with:
cmake -G Ninja -B release-build -S llvm \
        -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
        -DCMAKE_BUILD_TYPE=Release \
        -DLLVM_ENABLE_ASSERTIONS=OFF \
        -DLLVM_ENABLE_PROJECTS="clang;lld" \
        -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt"

This is the same configuration the test-release.sh script uses, so I'm
hoping this will also fix all the test failures we've been seeing when
building the releases.

Fixes #58680

(cherry picked from commit 7f215b1)
zmodem added a commit that referenced this issue Nov 27, 2023
This caused some runtimes builds to fail with:
error: unknown target 'runtimes-test-depends'

See comments on the PR.

> The test-depends target contained all the dependencies needed to run the
> runtimes tests, but it was never added as a dependency of check-all.
> This caused some of the tsan tests to fail, since the custom libcxx
> build the tests were looking for was never built. Besides the tsan
> failures, this fixes all the other test failures I was seeing with:
> cmake -G Ninja -B release-build -S llvm \
>         -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
>         -DCMAKE_BUILD_TYPE=Release \
>         -DLLVM_ENABLE_ASSERTIONS=OFF \
>         -DLLVM_ENABLE_PROJECTS="clang;lld" \
>         -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt"
>
> This is the same configuration the test-release.sh script uses, so I'm
> hoping this will also fix all the test failures we've been seeing when
> building the releases.
>
> Fixes #58680

This reverts commit 7f215b1.
tstellar added a commit to tstellar/llvm-project that referenced this issue Dec 11, 2023
Re-apply 7f215b1, which was reverted
in a9e3d23.

The orginal commit uncovered a bug that was fixed by
4701f77.

Fixes llvm#58680
tstellar added a commit that referenced this issue Dec 13, 2023
Re-apply 7f215b1, which was reverted in
a9e3d23.

The orginal commit uncovered a bug that was fixed by
4701f77.

Fixes #58680
MingcongBai pushed a commit to AOSC-Tracking/llvm-project that referenced this issue Mar 26, 2024
The test-depends target contained all the dependencies needed to run the
runtimes tests, but it was never added as a dependency of check-all.
This caused some of the tsan tests to fail, since the custom libcxx
build the tests were looking for was never built. Besides the tsan
failures, this fixes all the other test failures I was seeing with:
cmake -G Ninja -B release-build -S llvm \
        -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
        -DCMAKE_BUILD_TYPE=Release \
        -DLLVM_ENABLE_ASSERTIONS=OFF \
        -DLLVM_ENABLE_PROJECTS="clang;lld" \
        -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt"

This is the same configuration the test-release.sh script uses, so I'm
hoping this will also fix all the test failures we've been seeing when
building the releases.

Fixes llvm#58680

(cherry picked from commit 7f215b1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
7 participants