Skip to content

Commit 6b0c8c3

Browse files
committed
Deny compiletest self-tests being run against stage 0 rustc unless forced
Otherwise, `compiletest` would have to know e.g. how to parse two different target spec, if target spec format was changed between beta `rustc` and in-tree `rustc`. Even when forced, neither `compiletest` nor `compiletest` self-tests are expected to pass against a non-in-tree `rustc`, such as if the stage 0 `rustc` happens to be a beta `rustc`.
1 parent 2c18c49 commit 6b0c8c3

File tree

1 file changed

+18
-1
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+18
-1
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use std::ffi::{OsStr, OsString};
88
use std::path::{Path, PathBuf};
99
use std::{env, fs, iter};
1010

11+
#[cfg(feature = "tracing")]
12+
use tracing::instrument;
13+
1114
use crate::core::build_steps::compile::{Std, run_cargo};
1215
use crate::core::build_steps::doc::DocumentationFormat;
1316
use crate::core::build_steps::gcc::{Gcc, add_cg_gcc_cargo_flags};
@@ -30,7 +33,7 @@ use crate::utils::helpers::{
3033
linker_flags, t, target_supports_cranelift_backend, up_to_date,
3134
};
3235
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
33-
use crate::{CLang, DocTests, GitRepo, Mode, PathSet, envify};
36+
use crate::{CLang, DocTests, GitRepo, Mode, PathSet, debug, envify};
3437

3538
const ADB_TEST_DIR: &str = "/data/local/tmp/work";
3639

@@ -713,9 +716,23 @@ impl Step for CompiletestTest {
713716
}
714717

715718
/// Runs `cargo test` for compiletest.
719+
#[cfg_attr(
720+
feature = "tracing",
721+
instrument(level = "debug", name = "CompiletestTest::run", skip_all)
722+
)]
716723
fn run(self, builder: &Builder<'_>) {
717724
let host = self.host;
725+
726+
if builder.top_stage == 0 && !builder.config.compiletest_force_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-force-stage0=true`."
730+
);
731+
crate::exit!(1);
732+
}
733+
718734
let compiler = builder.compiler(builder.top_stage, host);
735+
debug!(?compiler);
719736

720737
// We need `ToolStd` for the locally-built sysroot because
721738
// compiletest uses unstable features of the `test` crate.

0 commit comments

Comments
 (0)