Skip to content

Commit a14270f

Browse files
Rollup merge of #144675 - jieyouxu:compiletest-staging, r=Kobzol
Reject running `compiletest` self-tests against stage 0 rustc unless explicitly allowed Currently, in `pr-check-1`, we run `python3 ../x.py test --stage 0 src/tools/compiletest`, which is `compiletest` self-tests against stage 0 rustc. This makes it very annoying for PRs wanting to change target spec JSON format, which `compiletest` depends on for target information, as otherwise `compiletest` would have to know how to handle 2 different target spec JSON formats and know when to pick which. Instead of doing that, we change `compiletest` self-tests to reject running against stage 0 `rustc` *unless* explicitly allowed with `build.compiletest-allow-stage0=true`. `build.compiletest-allow-stage0` is a proper bootstrap config option in favor of the ad-hoc `COMPILETEST_FORCE_STAGE0` env var. This means that: - `./x test src/tools/compiletest --stage=0` is not allowed, unless `build.compiletest-allow-stage0=true` is set. In this scenario, `compiletest` self-tests should be expected to fail unless the stage 0 `rustc` as provided is like codegen_cranelift where it's *actually* built from in-tree `rustc` sources. - In CI, we change `./x test src/tools/compiletest --stage=0` to `./x test src/tools/compiletest --stage=1`, and move it to `pr-check-2`. Yes, this involves building the stage 1 compiler, but `pr-check-2` already has to build stage 1 compiler to test stage 1 library crates. - Crucially, this means that **`compiletest` is only intended to support one target spec JSON format**, namely the one corresponding to the in-tree `rustc`. - This should preserve the `compiletest-use-stage0-libtest` UX optimization where changing `compiler/` tree should still not require rebuilding `compiletest` as long as `build.compiletest-use-stage0-libtest=true`, as that should remain orthogonal. This is completely unlike my previous attempt at rust-lang/rust#144563 that tries to do a way more invasive change which would cause the rebuild problem. Best reviewed commit-by-commit. --- r? `@Kobzol`
2 parents 77b922e + 5804f2b commit a14270f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

build_system/src/test.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,6 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
561561
// FIXME: create a function "display_if_not_quiet" or something along the line.
562562
println!("[TEST] rustc asm test suite");
563563

564-
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
565-
566564
let codegen_backend_path = format!(
567565
"{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}",
568566
pwd = std::env::current_dir()
@@ -588,6 +586,8 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
588586
&"always",
589587
&"--stage",
590588
&"0",
589+
&"--set",
590+
&"build.compiletest-allow-stage0=true",
591591
&"tests/assembly-llvm/asm",
592592
&"--compiletest-rustc-args",
593593
&rustc_args,
@@ -1047,7 +1047,6 @@ where
10471047

10481048
// FIXME: create a function "display_if_not_quiet" or something along the line.
10491049
println!("[TEST] rustc {test_type} test suite");
1050-
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
10511050

10521051
let extra =
10531052
if args.is_using_gcc_master_branch() { "" } else { " -Csymbol-mangling-version=v0" };
@@ -1070,6 +1069,8 @@ where
10701069
&"always",
10711070
&"--stage",
10721071
&"0",
1072+
&"--set",
1073+
&"build.compiletest-allow-stage0=true",
10731074
&format!("tests/{test_type}"),
10741075
&"--compiletest-rustc-args",
10751076
&rustc_args,

0 commit comments

Comments
 (0)