about summary refs log tree commit diff
diff options
context:
space:
mode:
authoronur-ozkan <work@onurozkan.dev>2025-06-02 16:40:10 +0300
committeronur-ozkan <work@onurozkan.dev>2025-06-03 08:51:19 +0000
commitecc7dde80aeee02c6915057620739a2cea3c3e23 (patch)
treec5a1dbe3922fd89e57dfa059b27cb27798f8e173
parent8a65d9febb86539e502faee868870f0dcd444693 (diff)
downloadrust-ecc7dde80aeee02c6915057620739a2cea3c3e23.tar.gz
rust-ecc7dde80aeee02c6915057620739a2cea3c3e23.zip
handle stage0 on `Std::check`
Signed-off-by: onur-ozkan <work@onurozkan.dev>
-rw-r--r--src/bootstrap/src/core/build_steps/check.rs27
-rw-r--r--src/bootstrap/src/core/config/config.rs8
2 files changed, 24 insertions, 11 deletions
diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs
index 922578f309a..b64f0658c0e 100644
--- a/src/bootstrap/src/core/build_steps/check.rs
+++ b/src/bootstrap/src/core/build_steps/check.rs
@@ -31,6 +31,8 @@ pub struct Std {
 }
 
 impl Std {
+    const CRATE_OR_DEPS: &[&str] = &["sysroot", "coretests", "alloctests"];
+
     pub fn new(target: TargetSelection) -> Self {
         Self { target, crates: vec![], override_build_kind: None }
     }
@@ -47,11 +49,13 @@ impl Step for Std {
 
     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
         let stage = run.builder.top_stage;
-        run.crate_or_deps("sysroot")
-            .crate_or_deps("coretests")
-            .crate_or_deps("alloctests")
-            .path("library")
-            .default_condition(stage != 0)
+
+        let mut run = run;
+        for c in Std::CRATE_OR_DEPS {
+            run = run.crate_or_deps(c);
+        }
+
+        run.path("library").default_condition(stage != 0)
     }
 
     fn make_run(run: RunConfig<'_>) {
@@ -66,6 +70,19 @@ impl Step for Std {
         let compiler = builder.compiler(builder.top_stage, builder.config.build);
 
         if builder.top_stage == 0 {
+            let mut is_explicitly_called =
+                builder.paths.iter().any(|p| p.starts_with("library") || p.starts_with("std"));
+
+            if !is_explicitly_called {
+                for c in Std::CRATE_OR_DEPS {
+                    is_explicitly_called = builder.paths.iter().any(|p| p.starts_with(c));
+                }
+            }
+
+            if is_explicitly_called {
+                eprintln!("WARNING: stage 0 std is precompiled and does nothing during `x check`.");
+            }
+
             // Reuse the stage0 libstd
             builder.ensure(compile::Std::new(compiler, target));
             return;
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index 99e82ba7658..03044d4fc80 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -2531,12 +2531,8 @@ impl Config {
             || bench_stage.is_some();
         // See https://github.com/rust-lang/compiler-team/issues/326
         config.stage = match config.cmd {
-            Subcommand::Check { .. } => {
-                flags.stage.or(check_stage).unwrap_or(0)
-            }
-            Subcommand::Clippy { .. } | Subcommand::Fix => {
-                flags.stage.or(check_stage).unwrap_or(1)
-            }
+            Subcommand::Check { .. } => flags.stage.or(check_stage).unwrap_or(0),
+            Subcommand::Clippy { .. } | Subcommand::Fix => flags.stage.or(check_stage).unwrap_or(1),
             // `download-rustc` only has a speed-up for stage2 builds. Default to stage2 unless explicitly overridden.
             Subcommand::Doc { .. } => {
                 flags.stage.or(doc_stage).unwrap_or(if download_rustc { 2 } else { 1 })