compiletest: Locally running clang-based tests assumes a hard-coded path to clang
@jieyouxu is already working on this.
Since Sep 11, 2026.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
When trying to run clang-based run-make tests locally, it doesn't seem to be possible to easily change or specify the path to a custom clang. For example, if I run:
RUSTBUILD_FORCE_CLANG_BASED_TESTS=1 ./x test tests/run-make/pointer-auth-link-with-c-lto-clang
Then the rmake build will be invoked with
CLANG="~/rust/rust/build/aarch64-unknown-linux-gnu/llvm/bin/clang"
LLVM_BIN_DIR="~/llvm/rust-llvm/build/bin"
LLVM_BIN_DIR is set from config.toml and that's correct. CLANG, on the other hand, is hard-coded by bootstrap to be overwritten to where the CI puts it. Setting the envvar manually does not work and the test keeps crashing unless I symlink the clang binary to where it points it to or modify the bootstrap source.
Compiletest has an option to specify the clang path, so the test could be invoked as follows:
RUSTBUILD_FORCE_CLANG_BASED_TESTS=1 ./x test tests/run-make/pointer-auth-link-with-c-lto-clang -- --run-clang-based-tests-with ~/llvm/rust-llvm/build/bin/clang
But bootstrap already passes that flag to it so no luck, still complains:
Testing stage1 compiletest suite=run-make mode=run-make (aarch64-unknown-linux-gnu)
thread 'main' panicked at src/tools/compiletest/src/lib.rs:198:19:
OptionDuplicated("run-clang-based-tests-with")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:01
I think the easiest solution here would be to just make it so that compiletest lets you override this option by just taking whichever one comes last. A cleaner solution would be removing the assumption on the path to the clang binary and making it configurable.
cc @jieyouxu
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.