Skip to content

Commit 6265106

Browse files
committed
Introduce proper bootstrap build.compiletest-force-stage0 config
Instead of the ad-hoc `COMPILETEST_FORCE_STAGE0` env var.
1 parent 919c409 commit 6265106

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

bootstrap.example.toml

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

468+
# Whether to force `compiletest` self-tests and `compiletest`-managed test
469+
# suites to be run against the stage0 rustc. Note that this configuration is
470+
# unsupported and tests will almost always fail, and is only intended to be used
471+
# by e.g. `codegen_cranelift` via `local-rebuild`.
472+
#build.compiletest-force-stage0 = false
473+
468474
# Whether to use the precompiled stage0 libtest with compiletest.
469475
#build.compiletest-use-stage0-libtest = true
470476

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_force_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-force-stage0=true`."
16211620
);
16221621
crate::exit!(1);
16231622
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,18 @@ 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 force bootstrap to run both `compiletest` self-tests and `compiletest`-managed
302+
/// test suites against the stage0 (rustc, std).
303+
///
304+
/// When using this configuration, stage0 rustc is assumed to *not* be the beta rustc, but is
305+
/// more or less the in-tree rustc, such as when using `local-rebuild`. The use case here is
306+
/// e.g. `codegen_cranelift`. Tests are *not* guaranteed to pass at all when stage0 rustc is
307+
/// forced.
308+
pub compiletest_force_stage0: bool,
309+
301310
/// Whether to use the precompiled stage0 libtest with compiletest.
302311
pub compiletest_use_stage0_libtest: bool,
312+
303313
/// Default value for `--extra-checks`
304314
pub tidy_extra_checks: Option<String>,
305315
pub is_running_on_ci: bool,
@@ -749,6 +759,7 @@ impl Config {
749759
optimized_compiler_builtins,
750760
jobs,
751761
compiletest_diff_tool,
762+
compiletest_force_stage0,
752763
compiletest_use_stage0_libtest,
753764
tidy_extra_checks,
754765
ccache,
@@ -1020,8 +1031,12 @@ impl Config {
10201031

10211032
config.optimized_compiler_builtins =
10221033
optimized_compiler_builtins.unwrap_or(config.channel != "dev");
1034+
10231035
config.compiletest_diff_tool = compiletest_diff_tool;
1036+
1037+
config.compiletest_force_stage0 = compiletest_force_stage0.unwrap_or(false);
10241038
config.compiletest_use_stage0_libtest = compiletest_use_stage0_libtest.unwrap_or(true);
1039+
10251040
config.tidy_extra_checks = tidy_extra_checks;
10261041

10271042
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_force_stage0: Option<bool> = "compiletest-force-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)