rust-lang / rust-lang/rust

compiletest: Locally running clang-based tests assumes a hard-coded path to clang

Open
#133,072 0 comments 1 reaction 1 assignee View on GitHub

@jieyouxu is already working on this.

Since Sep 11, 2026.

A-compiletest C-bug T-bootstrap
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.