Skip to content

Commit 1553adf

Browse files
committed
Auto merge of #145295 - Kobzol:unify-stages, r=jieyouxu
Consolidate stage directories and group logs in bootstrap My post-stage-0-redesign bootstrap fixes aren't done yet, but I think that enough steps have been migrated to the new system that it makes sense to actually modify the directories on disk, and what gets printed when bootstrap runs, so that it actually corresponds to the new system. Before, the printed stages didn't always make sense. This PR: - Fixes the numbering of `stageN` directories in the build directory. It was not corresponding to the correct stages before; notice that I did not modify `bootstrap/README.md`, as it was essentially describing what happens after this PR (first commit). - Unifies all steps that output a build group to use the `Builder::msg` method. It's probably not the final stage, and some of the test steps might not be fully accurate yet, because I didn't fix test step numbering yet, but I think that it's a clear improvement from before, and now that everything uses the same method, we can easily make changes across the board, to ensure that it stays unified (second commit). r? `@jieyouxu` try-job: dist-x86_64-msvc try-job: dist-x86_64-linux
2 parents 8e62bfd + 4360c52 commit 1553adf

File tree

18 files changed

+241
-266
lines changed

18 files changed

+241
-266
lines changed

src/bootstrap/src/bin/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ fn main() {
258258
eprintln!("{prefix} libdir: {libdir:?}");
259259
}
260260

261-
maybe_dump(format!("stage{stage}-rustc"), &cmd);
261+
maybe_dump(format!("stage{}-rustc", stage + 1), &cmd);
262262

263263
let start = Instant::now();
264264
let (child, status) = {

src/bootstrap/src/bin/rustdoc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ fn main() {
5656
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
5757
// We also declare that the flag is expected, which we need to do to not
5858
// get warnings about it being unexpected.
59-
if stage == "0" {
59+
if stage == 0 {
6060
cmd.arg("--cfg=bootstrap");
6161
}
6262

63-
maybe_dump(format!("stage{stage}-rustdoc"), &cmd);
63+
maybe_dump(format!("stage{}-rustdoc", stage + 1), &cmd);
6464

6565
if verbose > 1 {
6666
eprintln!(

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

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ impl Step for Std {
7272

7373
fn run(self, builder: &Builder<'_>) {
7474
let build_compiler = self.build_compiler;
75-
let stage = build_compiler.stage;
7675
let target = self.target;
7776

7877
let mut cargo = builder::Cargo::new(
@@ -94,10 +93,12 @@ impl Step for Std {
9493
cargo.arg("-p").arg(krate);
9594
}
9695

97-
let _guard = builder.msg_check(
96+
let _guard = builder.msg(
97+
Kind::Check,
9898
format_args!("library artifacts{}", crate_description(&self.crates)),
99+
Mode::Std,
100+
self.build_compiler,
99101
target,
100-
Some(stage),
101102
);
102103

103104
let stamp = build_stamp::libstd_stamp(builder, build_compiler, target).with_prefix("check");
@@ -136,7 +137,13 @@ impl Step for Std {
136137

137138
let stamp =
138139
build_stamp::libstd_stamp(builder, build_compiler, target).with_prefix("check-test");
139-
let _guard = builder.msg_check("library test/bench/example targets", target, Some(stage));
140+
let _guard = builder.msg(
141+
Kind::Check,
142+
"library test/bench/example targets",
143+
Mode::Std,
144+
self.build_compiler,
145+
target,
146+
);
140147
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
141148
}
142149

@@ -227,10 +234,12 @@ impl Step for Rustc {
227234
cargo.arg("-p").arg(krate);
228235
}
229236

230-
let _guard = builder.msg_check(
237+
let _guard = builder.msg(
238+
Kind::Check,
231239
format_args!("compiler artifacts{}", crate_description(&self.crates)),
240+
Mode::Rustc,
241+
self.build_compiler,
232242
target,
233-
None,
234243
);
235244

236245
let stamp =
@@ -357,7 +366,13 @@ impl Step for CodegenBackend {
357366
.arg(builder.src.join(format!("compiler/{}/Cargo.toml", backend.crate_name())));
358367
rustc_cargo_env(builder, &mut cargo, target);
359368

360-
let _guard = builder.msg_check(backend.crate_name(), target, None);
369+
let _guard = builder.msg(
370+
Kind::Check,
371+
backend.crate_name(),
372+
Mode::Codegen,
373+
self.build_compiler,
374+
target,
375+
);
361376

362377
let stamp = build_stamp::codegen_backend_stamp(builder, build_compiler, target, &backend)
363378
.with_prefix("check");
@@ -482,14 +497,7 @@ fn run_tool_check_step(
482497
let stamp = BuildStamp::new(&builder.cargo_out(build_compiler, mode, target))
483498
.with_prefix(&format!("{display_name}-check"));
484499

485-
let stage = match mode {
486-
// Mode::ToolRustc is included here because of how msg_sysroot_tool prints stages
487-
Mode::Std | Mode::ToolRustc => build_compiler.stage,
488-
_ => build_compiler.stage + 1,
489-
};
490-
491-
let _guard =
492-
builder.msg_tool(builder.kind, mode, display_name, stage, &build_compiler.host, &target);
500+
let _guard = builder.msg(builder.kind, display_name, mode, build_compiler, target);
493501
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
494502
}
495503

src/bootstrap/src/core/build_steps/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn clean_specific_stage(build: &Build, stage: u32) {
129129

130130
for entry in entries {
131131
let entry = t!(entry);
132-
let stage_prefix = format!("stage{stage}");
132+
let stage_prefix = format!("stage{}", stage + 1);
133133

134134
// if current entry is not related with the target stage, continue
135135
if !entry.file_name().to_str().unwrap_or("").contains(&stage_prefix) {

src/bootstrap/src/core/build_steps/clippy.rs

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ impl Step for Std {
143143

144144
fn run(self, builder: &Builder<'_>) {
145145
let target = self.target;
146-
let compiler = builder.compiler(builder.top_stage, builder.config.host_target);
146+
let build_compiler = builder.compiler(builder.top_stage, builder.config.host_target);
147147

148148
let mut cargo = builder::Cargo::new(
149149
builder,
150-
compiler,
150+
build_compiler,
151151
Mode::Std,
152152
SourceType::InTree,
153153
target,
@@ -160,14 +160,19 @@ impl Step for Std {
160160
cargo.arg("-p").arg(krate);
161161
}
162162

163-
let _guard =
164-
builder.msg_clippy(format_args!("library{}", crate_description(&self.crates)), target);
163+
let _guard = builder.msg(
164+
Kind::Clippy,
165+
format_args!("library{}", crate_description(&self.crates)),
166+
Mode::Std,
167+
build_compiler,
168+
target,
169+
);
165170

166171
run_cargo(
167172
builder,
168173
cargo,
169174
lint_args(builder, &self.config, IGNORED_RULES_FOR_STD_AND_RUSTC),
170-
&build_stamp::libstd_stamp(builder, compiler, target),
175+
&build_stamp::libstd_stamp(builder, build_compiler, target),
171176
vec![],
172177
true,
173178
false,
@@ -203,33 +208,33 @@ impl Step for Rustc {
203208
/// This will lint the compiler for a particular stage of the build using
204209
/// the `compiler` targeting the `target` architecture.
205210
fn run(self, builder: &Builder<'_>) {
206-
let compiler = builder.compiler(builder.top_stage, builder.config.host_target);
211+
let build_compiler = builder.compiler(builder.top_stage, builder.config.host_target);
207212
let target = self.target;
208213

209214
if !builder.download_rustc() {
210-
if compiler.stage != 0 {
215+
if build_compiler.stage != 0 {
211216
// If we're not in stage 0, then we won't have a std from the beta
212217
// compiler around. That means we need to make sure there's one in
213218
// the sysroot for the compiler to find. Otherwise, we're going to
214219
// fail when building crates that need to generate code (e.g., build
215220
// scripts and their dependencies).
216-
builder.std(compiler, compiler.host);
217-
builder.std(compiler, target);
221+
builder.std(build_compiler, build_compiler.host);
222+
builder.std(build_compiler, target);
218223
} else {
219-
builder.ensure(check::Std::new(compiler, target));
224+
builder.ensure(check::Std::new(build_compiler, target));
220225
}
221226
}
222227

223228
let mut cargo = builder::Cargo::new(
224229
builder,
225-
compiler,
230+
build_compiler,
226231
Mode::Rustc,
227232
SourceType::InTree,
228233
target,
229234
Kind::Clippy,
230235
);
231236

232-
rustc_cargo(builder, &mut cargo, target, &compiler, &self.crates);
237+
rustc_cargo(builder, &mut cargo, target, &build_compiler, &self.crates);
233238

234239
// Explicitly pass -p for all compiler crates -- this will force cargo
235240
// to also lint the tests/benches/examples for these crates, rather
@@ -238,14 +243,19 @@ impl Step for Rustc {
238243
cargo.arg("-p").arg(krate);
239244
}
240245

241-
let _guard =
242-
builder.msg_clippy(format_args!("compiler{}", crate_description(&self.crates)), target);
246+
let _guard = builder.msg(
247+
Kind::Clippy,
248+
format_args!("compiler{}", crate_description(&self.crates)),
249+
Mode::Rustc,
250+
build_compiler,
251+
target,
252+
);
243253

244254
run_cargo(
245255
builder,
246256
cargo,
247257
lint_args(builder, &self.config, IGNORED_RULES_FOR_STD_AND_RUSTC),
248-
&build_stamp::librustc_stamp(builder, compiler, target),
258+
&build_stamp::librustc_stamp(builder, build_compiler, target),
249259
vec![],
250260
true,
251261
false,
@@ -284,16 +294,16 @@ macro_rules! lint_any {
284294
}
285295

286296
fn run(self, builder: &Builder<'_>) -> Self::Output {
287-
let compiler = builder.compiler(builder.top_stage, builder.config.host_target);
297+
let build_compiler = builder.compiler(builder.top_stage, builder.config.host_target);
288298
let target = self.target;
289299

290300
if !builder.download_rustc() {
291-
builder.ensure(check::Rustc::new(builder, compiler, target));
301+
builder.ensure(check::Rustc::new(builder, build_compiler, target));
292302
};
293303

294304
let cargo = prepare_tool_cargo(
295305
builder,
296-
compiler,
306+
build_compiler,
297307
Mode::ToolRustc,
298308
target,
299309
Kind::Clippy,
@@ -302,17 +312,16 @@ macro_rules! lint_any {
302312
&[],
303313
);
304314

305-
let _guard = builder.msg_tool(
315+
let _guard = builder.msg(
306316
Kind::Clippy,
307-
Mode::ToolRustc,
308317
$readable_name,
309-
compiler.stage,
310-
&compiler.host,
311-
&target,
318+
Mode::ToolRustc,
319+
build_compiler,
320+
target,
312321
);
313322

314323
let stringified_name = stringify!($name).to_lowercase();
315-
let stamp = BuildStamp::new(&builder.cargo_out(compiler, Mode::ToolRustc, target))
324+
let stamp = BuildStamp::new(&builder.cargo_out(build_compiler, Mode::ToolRustc, target))
316325
.with_prefix(&format!("{}-check", stringified_name));
317326

318327
run_cargo(

0 commit comments

Comments
 (0)