Skip to content

Commit 0cf6eb5

Browse files
committed
Introduce proper build.compiletest-allow-stage0 config option
In favor of the adhoc `COMPILETEST_FORCE_STAGE0` env var.
1 parent 919c409 commit 0cf6eb5

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

bootstrap.example.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@
465465
# What custom diff tool to use for displaying compiletest tests.
466466
#build.compiletest-diff-tool = <none>
467467

468+
# Whether to allow `compiletest` self-tests and `compiletest`-managed test
469+
# suites to be run against the stage 0 rustc. This is only intended to be used
470+
# when the stage 0 compiler is actually built from in-tree sources.
471+
#build.compiletest-allow-stage0 = false
472+
468473
# Whether to use the precompiled stage0 libtest with compiletest.
469474
#build.compiletest-use-stage0-libtest = true
470475

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ impl Step for CompiletestTest {
723723
let mut cargo = tool::prepare_tool_cargo(
724724
builder,
725725
compiler,
726-
// compiletest uses libtest internals; make it use the in-tree std to make sure it never breaks
727-
// when std sources change.
726+
// compiletest uses libtest internals; make it use the in-tree std to make sure it never
727+
// breaks when std sources change.
728728
Mode::ToolStd,
729729
host,
730730
Kind::Test,
@@ -1612,12 +1612,11 @@ impl Step for Compiletest {
16121612
return;
16131613
}
16141614

1615-
if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() {
1615+
if builder.top_stage == 0 && !builder.config.compiletest_allow_stage0 {
16161616
eprintln!("\
16171617
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`."
1618+
HELP: to test the compiler or standard library, omit the stage or explicitly use `--stage 1` instead
1619+
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`."
16211620
);
16221621
crate::exit!(1);
16231622
}

src/bootstrap/src/core/config/config.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,16 @@ pub struct Config {
298298
/// Command for visual diff display, e.g. `diff-tool --color=always`.
299299
pub compiletest_diff_tool: Option<String>,
300300

301+
/// Whether to allow running both `compiletest` self-tests and `compiletest`-managed test suites
302+
/// against the stage 0 (rustc, std).
303+
///
304+
/// This is only intended to be used when the stage 0 compiler is actually built from in-tree
305+
/// sources.
306+
pub compiletest_allow_stage0: bool,
307+
301308
/// Whether to use the precompiled stage0 libtest with compiletest.
302309
pub compiletest_use_stage0_libtest: bool,
310+
303311
/// Default value for `--extra-checks`
304312
pub tidy_extra_checks: Option<String>,
305313
pub is_running_on_ci: bool,
@@ -749,6 +757,7 @@ impl Config {
749757
optimized_compiler_builtins,
750758
jobs,
751759
compiletest_diff_tool,
760+
compiletest_allow_stage0,
752761
compiletest_use_stage0_libtest,
753762
tidy_extra_checks,
754763
ccache,
@@ -1020,8 +1029,12 @@ impl Config {
10201029

10211030
config.optimized_compiler_builtins =
10221031
optimized_compiler_builtins.unwrap_or(config.channel != "dev");
1032+
10231033
config.compiletest_diff_tool = compiletest_diff_tool;
1034+
1035+
config.compiletest_allow_stage0 = compiletest_allow_stage0.unwrap_or(false);
10241036
config.compiletest_use_stage0_libtest = compiletest_use_stage0_libtest.unwrap_or(true);
1037+
10251038
config.tidy_extra_checks = tidy_extra_checks;
10261039

10271040
let download_rustc = config.download_rustc_commit.is_some();

src/bootstrap/src/core/config/toml/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ define_config! {
6868
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
6969
jobs: Option<u32> = "jobs",
7070
compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
71+
compiletest_allow_stage0: Option<bool> = "compiletest-allow-stage0",
7172
compiletest_use_stage0_libtest: Option<bool> = "compiletest-use-stage0-libtest",
7273
tidy_extra_checks: Option<String> = "tidy-extra-checks",
7374
ccache: Option<StringOrBool> = "ccache",

0 commit comments

Comments
 (0)