Skip to content

Commit 694a8aa

Browse files
committed
handle stage0 on Std::check
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent b7591fb commit 694a8aa

File tree

1 file changed

+29
-5
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+29
-5
lines changed

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

Lines changed: 29 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,26 @@ 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+
if builder.config.explicit_stage_from_cli {
86+
eprintln!(
87+
"ERROR: Cannot call `x check` on the library tree explicitly with the `--stage 0` flag."
88+
);
89+
std::process::exit(1);
90+
}
91+
}
92+
6993
// Reuse the stage0 libstd
7094
builder.ensure(compile::Std::new(compiler, target));
7195
return;

0 commit comments

Comments
 (0)