You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 #144563 that tries to do a way more invasive change which would cause the rebuild problem.
Best reviewed commit-by-commit.
---
r? `@Kobzol`
@@ -713,18 +716,32 @@ impl Step for CompiletestTest {
713
716
}
714
717
715
718
/// Runs `cargo test` for compiletest.
719
+
#[cfg_attr(
720
+
feature = "tracing",
721
+
instrument(level = "debug", name = "CompiletestTest::run", skip_all)
722
+
)]
716
723
fnrun(self,builder:&Builder<'_>){
717
724
let host = self.host;
725
+
726
+
if builder.top_stage == 0 && !builder.config.compiletest_allow_stage0{
727
+
eprintln!("\
728
+
ERROR: `--stage 0` runs compiletest self-tests against the stage0 (precompiled) compiler, not the in-tree compiler, and will almost always cause tests to fail
729
+
NOTE: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `--set build.compiletest-allow-stage0=true`."
730
+
);
731
+
crate::exit!(1);
732
+
}
733
+
718
734
let compiler = builder.compiler(builder.top_stage, host);
735
+
debug!(?compiler);
719
736
720
737
// We need `ToolStd` for the locally-built sysroot because
721
738
// compiletest uses unstable features of the `test` crate.
722
739
builder.std(compiler, host);
723
740
letmut cargo = tool::prepare_tool_cargo(
724
741
builder,
725
742
compiler,
726
-
// compiletest uses libtest internals; make it use the in-tree std to make sure it never breaks
727
-
// when std sources change.
743
+
// compiletest uses libtest internals; make it use the in-tree std to make sure it never
744
+
// breaks when std sources change.
728
745
Mode::ToolStd,
729
746
host,
730
747
Kind::Test,
@@ -1612,12 +1629,11 @@ impl Step for Compiletest {
1612
1629
return;
1613
1630
}
1614
1631
1615
-
if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err(){
1632
+
if builder.top_stage == 0 && !builder.config.compiletest_allow_stage0{
1616
1633
eprintln!("\
1617
1634
ERROR: `--stage 0` runs compiletest on the stage0 (precompiled) compiler, not your local changes, and will almost always cause tests to fail
1618
-
HELP: to test the compiler, use `--stage 1` instead
1619
-
HELP: to test the standard library, use `--stage 0 library/std` instead
1620
-
NOTE: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`."
1635
+
HELP: to test the compiler or standard library, omit the stage or explicitly use `--stage 1` instead
1636
+
NOTE: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `--set build.compiletest-allow-stage0=true`."
summary:"Removed `rust.description` and `llvm.ccache` as it was deprecated in #137723 and #136941 long time ago.",
488
488
},
489
+
ChangeInfo{
490
+
change_id:144675,
491
+
severity:ChangeSeverity::Warning,
492
+
summary:"Added `build.compiletest-allow-stage0` flag instead of `COMPILETEST_FORCE_STAGE0` env var, and reject running `compiletest` self tests against stage 0 rustc unless explicitly allowed.",
0 commit comments