llvm / llvm/llvm-project

[llvm-lit] 20 second delay before any tests are ran

Open
#186,165 0 comments 0 reactions 0 assignees View on GitHub
tools:llvm-lit
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I have been hitting this for about a month and tracked it down to the `clang-repl --cuda` run in `clang/test/lit.cfg.py`, specifically `have_host_clang_repl_cuda()`.
On my machine, any `llvm-lit` run that loads the `clang` test suite pays about 20 seconds during startup before test discovery/execution. The expensive step is the `clang-repl --cuda` probe used to determine whether `host-supports-cuda` should be added.
I ran the same command that `have_host_clang_repl_cuda()` runs and got the following errors:
```text
module flag identifiers must be unique (or of 'require' type)
!"wchar_size"
module flag identifiers must be unique (or of 'require' type)
!"nvvm-reflect-ftz"
module flag identifiers must be unique (or of 'require' type)
!"frame-pointer"
fatal error: error in backend: Broken module found, compilation aborted!
```

FYI it also has this 20 second delay

bash repro

```bash
printf '%s\n' \
'__global__ void test_func() {}' \
'test_func<<<1,1>>>();' \
'extern "C" int puts(const char *s);' \
'puts(cudaGetLastError() ? "failure" : "success");' \
'%quit' \
| build_Debug/bin/clang-repl --cuda
```

Lets ignore the fact that i have CUDA installed and an NVIDIA GPU, but llvm-lit still ends up marking the CUDA interpreter tests as unsupported (this is not in the scope of this issue).

The `have_host_clang_repl_cuda()` probe is run from the global `clang/test/lit.cfg.py`, so unrelated llvm-lit runs pay the startup cost even though the result is only used by `clang/test/Interpreter/CUDA`.

Even if the `clang-repl --cuda` failure is the deeper bug (though I'm not sure if it is), it seems like this probe should not run before general clang test discovery. It would be better if it were limited to the CUDA interpreter test subtree.

Contributor guide

Open the contributing guide

Research direction

Start in clang/test/lit.cfg.py at have_host_clang_repl_cuda() and compare how the clang/test/Interpreter/CUDA subtree configures its tests. Verify with an llvm-lit run that unrelated clang test discovery no longer waits for the clang-repl --cuda probe, while the CUDA interpreter tests still receive the appropriate capability result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.