Skip to content

Commit 7bea91f

Browse files
authored
Unrolled build for #141914
Rollup merge of #141914 - onur-ozkan:follow-ups, r=Kobzol redesign stage 0 std follow-ups Various follow-ups pointed out on Zulip during post-merge discussions of [redesign stage 0 std #119899](#119899). r? `@jieyouxu` Fixes #141902. Fixes #141905. cc `@jyn514`
2 parents aae43c4 + 59d993b commit 7bea91f

File tree

5 files changed

+56
-18
lines changed

5 files changed

+56
-18
lines changed

src/bootstrap/defaults/bootstrap.library.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# These defaults are meant for contributors to the standard library and documentation.
22
[build]
3+
bench-stage = 1
34
build-stage = 1
5+
check-stage = 1
46
test-stage = 1
5-
bench-stage = 1
67

78
[rust]
89
# This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.

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

Lines changed: 43 additions & 13 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
}
@@ -46,12 +48,19 @@ impl Step for Std {
4648
const DEFAULT: bool = true;
4749

4850
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
49-
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)
51+
let builder = run.builder;
52+
let stage = if builder.config.is_explicit_stage() || builder.top_stage >= 1 {
53+
builder.top_stage
54+
} else {
55+
1
56+
};
57+
58+
let mut run = run;
59+
for c in Std::CRATE_OR_DEPS {
60+
run = run.crate_or_deps(c);
61+
}
62+
63+
run.path("library").default_condition(stage != 0)
5564
}
5665

5766
fn make_run(run: RunConfig<'_>) {
@@ -62,10 +71,29 @@ impl Step for Std {
6271
fn run(self, builder: &Builder<'_>) {
6372
builder.require_submodule("library/stdarch", None);
6473

74+
let stage = if builder.config.is_explicit_stage() || builder.top_stage >= 1 {
75+
builder.top_stage
76+
} else {
77+
1
78+
};
79+
6580
let target = self.target;
66-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
81+
let compiler = builder.compiler(stage, builder.config.build);
82+
83+
if stage == 0 {
84+
let mut is_explicitly_called =
85+
builder.paths.iter().any(|p| p.starts_with("library") || p.starts_with("std"));
86+
87+
if !is_explicitly_called {
88+
for c in Std::CRATE_OR_DEPS {
89+
is_explicitly_called = builder.paths.iter().any(|p| p.starts_with(c));
90+
}
91+
}
92+
93+
if is_explicitly_called {
94+
eprintln!("WARNING: stage 0 std is precompiled and does nothing during `x check`.");
95+
}
6796

68-
if builder.top_stage == 0 {
6997
// Reuse the stage0 libstd
7098
builder.ensure(compile::Std::new(compiler, target));
7199
return;
@@ -93,6 +121,7 @@ impl Step for Std {
93121
let _guard = builder.msg_check(
94122
format_args!("library artifacts{}", crate_description(&self.crates)),
95123
target,
124+
Some(stage),
96125
);
97126

98127
let stamp = build_stamp::libstd_stamp(builder, compiler, target).with_prefix("check");
@@ -145,7 +174,7 @@ impl Step for Std {
145174
}
146175

147176
let stamp = build_stamp::libstd_stamp(builder, compiler, target).with_prefix("check-test");
148-
let _guard = builder.msg_check("library test/bench/example targets", target);
177+
let _guard = builder.msg_check("library test/bench/example targets", target, Some(stage));
149178
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
150179
}
151180
}
@@ -246,6 +275,7 @@ impl Step for Rustc {
246275
let _guard = builder.msg_check(
247276
format_args!("compiler artifacts{}", crate_description(&self.crates)),
248277
target,
278+
None,
249279
);
250280

251281
let stamp = build_stamp::librustc_stamp(builder, compiler, target).with_prefix("check");
@@ -306,7 +336,7 @@ impl Step for CodegenBackend {
306336
.arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));
307337
rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
308338

309-
let _guard = builder.msg_check(backend, target);
339+
let _guard = builder.msg_check(backend, target, None);
310340

311341
let stamp = build_stamp::codegen_backend_stamp(builder, compiler, target, backend)
312342
.with_prefix("check");
@@ -373,7 +403,7 @@ impl Step for RustAnalyzer {
373403
let stamp = BuildStamp::new(&builder.cargo_out(compiler, Mode::ToolRustc, target))
374404
.with_prefix("rust-analyzer-check");
375405

376-
let _guard = builder.msg_check("rust-analyzer artifacts", target);
406+
let _guard = builder.msg_check("rust-analyzer artifacts", target, None);
377407
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
378408
}
379409
}
@@ -436,7 +466,7 @@ impl Step for Compiletest {
436466
let stamp = BuildStamp::new(&builder.cargo_out(compiler, mode, self.target))
437467
.with_prefix("compiletest-check");
438468

439-
let _guard = builder.msg_check("compiletest artifacts", self.target);
469+
let _guard = builder.msg_check("compiletest artifacts", self.target, None);
440470
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
441471
}
442472
}
@@ -514,7 +544,7 @@ fn run_tool_check_step(
514544
let stamp = BuildStamp::new(&builder.cargo_out(compiler, Mode::ToolRustc, target))
515545
.with_prefix(&format!("{}-check", step_type_name.to_lowercase()));
516546

517-
let _guard = builder.msg_check(format!("{display_name} artifacts"), target);
547+
let _guard = builder.msg_check(format!("{display_name} artifacts"), target, None);
518548
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
519549
}
520550

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,9 +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 { .. } | Subcommand::Clippy { .. } | Subcommand::Fix => {
2535-
flags.stage.or(check_stage).unwrap_or(1)
2536-
}
2534+
Subcommand::Check { .. } => flags.stage.or(check_stage).unwrap_or(0),
2535+
Subcommand::Clippy { .. } | Subcommand::Fix => flags.stage.or(check_stage).unwrap_or(1),
25372536
// `download-rustc` only has a speed-up for stage2 builds. Default to stage2 unless explicitly overridden.
25382537
Subcommand::Doc { .. } => {
25392538
flags.stage.or(doc_stage).unwrap_or(if download_rustc { 2 } else { 1 })

src/bootstrap/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,15 @@ Executed at: {executed_at}"#,
11041104
&self,
11051105
what: impl Display,
11061106
target: impl Into<Option<TargetSelection>>,
1107+
custom_stage: Option<u32>,
11071108
) -> Option<gha::Group> {
1108-
self.msg(Kind::Check, self.config.stage, what, self.config.build, target)
1109+
self.msg(
1110+
Kind::Check,
1111+
custom_stage.unwrap_or(self.config.stage),
1112+
what,
1113+
self.config.build,
1114+
target,
1115+
)
11091116
}
11101117

11111118
#[must_use = "Groups should not be dropped until the Step finishes running"]

src/ci/docker/host-x86_64/mingw-check-2/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ COPY scripts/sccache.sh /scripts/
2727
RUN sh /scripts/sccache.sh
2828

2929
ENV SCRIPT \
30+
python3 ../x.py check && \
3031
python3 ../x.py clippy ci && \
3132
python3 ../x.py test --stage 1 core alloc std test proc_macro && \
3233
# Build both public and internal documentation.

0 commit comments

Comments
 (0)