Skip to content

Commit e186aac

Browse files
committed
handle stage0 on Std::check
Signed-off-by: onur-ozkan <[email protected]>
1 parent 5be6bb2 commit e186aac

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pub struct Std {
3131
}
3232

3333
impl Std {
34+
const CRATE_OR_DEPS: &[&str] = &["sysroot", "coretests", "alloctests"];
35+
3436
pub fn new(target: TargetSelection) -> Self {
3537
Self { target, crates: vec![], override_build_kind: None }
3638
}
@@ -47,11 +49,13 @@ impl Step for Std {
4749

4850
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
4951
let stage = run.builder.top_stage;
50-
run.crate_or_deps("sysroot")
51-
.crate_or_deps("coretests")
52-
.crate_or_deps("alloctests")
53-
.path("library")
54-
.default_condition(stage != 0)
52+
53+
let mut run = run;
54+
for c in Std::CRATE_OR_DEPS {
55+
run = run.crate_or_deps(c);
56+
}
57+
58+
run.path("library").default_condition(stage != 0)
5559
}
5660

5761
fn make_run(run: RunConfig<'_>) {
@@ -66,6 +70,19 @@ impl Step for Std {
6670
let compiler = builder.compiler(builder.top_stage, builder.config.build);
6771

6872
if builder.top_stage == 0 {
73+
let mut is_explicitly_called =
74+
builder.paths.iter().any(|p| p.starts_with("library") || p.starts_with("std"));
75+
76+
if !is_explicitly_called {
77+
for c in Std::CRATE_OR_DEPS {
78+
is_explicitly_called = builder.paths.iter().any(|p| p.starts_with(c));
79+
}
80+
}
81+
82+
if is_explicitly_called {
83+
eprintln!("WARNING: stage 0 std is precompiled and does nothing during `x check`.");
84+
}
85+
6986
// Reuse the stage0 libstd
7087
builder.ensure(compile::Std::new(compiler, target));
7188
return;

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,12 +2531,8 @@ impl Config {
25312531
|| bench_stage.is_some();
25322532
// See https://github.com/rust-lang/compiler-team/issues/326
25332533
config.stage = match config.cmd {
2534-
Subcommand::Check { .. } => {
2535-
flags.stage.or(check_stage).unwrap_or(0)
2536-
}
2537-
Subcommand::Clippy { .. } | Subcommand::Fix => {
2538-
flags.stage.or(check_stage).unwrap_or(1)
2539-
}
2534+
Subcommand::Check { .. } => flags.stage.or(check_stage).unwrap_or(0),
2535+
Subcommand::Clippy { .. } | Subcommand::Fix => flags.stage.or(check_stage).unwrap_or(1),
25402536
// `download-rustc` only has a speed-up for stage2 builds. Default to stage2 unless explicitly overridden.
25412537
Subcommand::Doc { .. } => {
25422538
flags.stage.or(doc_stage).unwrap_or(if download_rustc { 2 } else { 1 })

0 commit comments

Comments
 (0)