[BUILD] Race condition during build/testing for check-clang/check-clang-tools
[6099/6110] Running clang_tools regression tests
llvm-lit.py: C:\_work\llvm-project\llvm-project\llvm\utils\lit\lit\llvm\config.py:57: note: using lit tools: C:\Program Files\Git\usr\bin
llvm-lit.py: C:\_work\llvm-project\llvm-project\llvm\utils\lit\lit\llvm\config.py:520: note: using clang: c:\_work\llvm-project\llvm-project\build\bin\clang.exe
llvm-lit.py: C:\_work\llvm-project\llvm-project\llvm\utils\lit\lit\llvm\config.py:312: fatal: Couldn't find the include dir for Clang ('c:\_work\llvm-project\llvm-project\build\bin\clang.exe')
c:\_work\llvm-project\llvm-project\build\bin\clang.exe
[6101/6110] Linking CXX executable bin\obj2yaml.exe
FAILED: tools/clang/tools/extra/CMakeFiles/check-clang-tools
cmd.exe /C "cd /D C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra && C:\Python39\python.exe C:/_work/llvm-project/llvm-project/build/./bin/llvm-lit.py -v --xunit-xml-output C:/_work/llvm-project/llvm-project/build/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests C:/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/include-cleaner/test C:/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/clangd/test/../unittests C:/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/clangd/test C:/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test"
[6103/6110] Linking CXX executable bin\clang.exe
It looks like we try to run the clang-tools-extra regression tests which seem to be looking for clang.exe which isn't yet built.
Some examples of this in the wild include: https://github.com/llvm/llvm-project/actions/runs/15875229617/job/44761115591?pr=145679 https://github.com/llvm/llvm-project/actions/runs/15860875108/job/44717506023?pr=143424
@llvm/issue-subscribers-infrastructure
Author: Aaron Ballman (AaronBallman)
It looks like we try to run the clang-tools-extra regression tests which seem to be looking for clang.exe which isn't yet built.
Some examples of this in the wild include: https://github.com/llvm/llvm-project/actions/runs/15875229617/job/44761115591?pr=145679 https://github.com/llvm/llvm-project/actions/runs/15860875108/job/44717506023?pr=143424
@cmtice @lnihlen Is the current on call able to investigate this? It could be relatively recent and might just be a CMake missing dependency, but impacts reliability a decent amount.
Not entirely sure it’s in scope for the rotation though given it’s not an infrastructure issue.
@Keenuts is primary this week. I'll try to take a look in a bit myself.
Looks like the issue was already existing? But since https://github.com/llvm/llvm-project/pull/144033 seems like the CI now runs this, hence the failure showing
Not sure why this is happening yet. But what the flakiness I observe, even locally on linux tells me there is some race-condition
Hi, I renamed the issuer to reflect what this is about. I haven't found the culprit, but at least we know this is not an infrastructure issue.
This can be reproduced locally on linux (if lucky since flaky) on a clean build with:
cmake -S ./llvm -B repro -D 'LLVM_ENABLE_PROJECTS=clang;clang-tools-extra;llvm' -G Ninja -D CMAKE_BUILD_TYPE=Release -D LLVM_ENABLE_ASSERTIONS=ON -D LLVM_BUILD_EXAMPLES=ON -D COMPILER_RT_BUILD_LIBFUZZER=OFF -D 'LLVM_LIT_ARGS=-v --use-unique-output-file-name --timeout=1200 --time-tests' -D COMPILER_RT_BUILD_ORC=OFF -D MLIR_ENABLE_BINDINGS_PYTHON=ON -D LLVM_PARALLEL_COMPILE_JOBS=64 -D LLVM_PARALLEL_LINK_JOBS=64 && ninja -C repro check-clang check-clang-tools
It's not actually clang.exe that's missing, it's the output of clang.exe -print-file-name=include that's empty. clang-resource-headers target is in CLANG_TOOLS_TEST_DEPS and I do see Ninja copying the headers into place in the build log so the directory should exist.
@Keenuts Do you have additional reproduction instructions on Linux? I tried doing this in the CI container on a 128-thread machine and couldn't reproduce it after ~10 attempts. It's also interesting that it seems like the only CI failures have been in Windows jobs. I think I'm going to try and reproduce it there next.
Some oddities:
check-clang-toolsdoesn't depend onclang. Runningcheck-clang-toolsby itself never buildsclang(as expected), and also runs fine. This seems to imply that we're not actually running the fault code path in the lit config logic.- The invocation of
clangin the lit config logic seems to be specific to usingclang. Given theclang-tools-extratest suite doesn't depend onclangand never usesclangand it runs fine withoutclang, it seems like the presence of the binary is somehow influencing the lit code execution path which I don't think should be happening. - This reproduces perfectly if I just run
ninja check-clang-tools, touch./bin/clangto create a dummy clang that can't actually execute anything, and thenninja check-clang-toolsagain. The second check invocation fails in this exact manner. Given this, I'm guessing the race condition is around theclangsymlink (or maybe even the binary it points to?) getting created at the same time. It's present but not executable given there's no hard dependency and thus the check fails.
Now to figure out why we would be executing that code path in the first place...
@Keenuts Do you have additional reproduction instructions on Linux? I tried doing this in the CI container on a 128-thread machine and couldn't reproduce it after ~10 attempts. It's also interesting that it seems like the only CI failures have been in Windows jobs. I think I'm going to try and reproduce it there next.
I was able to reproduce this quite often on linux, but only when doing a clean build. (128 core, cmake + ninja). But the repro you found seems way more efficient than a clean build.