Skip to content

Add bootstrap check snapshot tests #143316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,7 @@ impl Step for Std {
}

fn metadata(&self) -> Option<StepMetadata> {
Some(
StepMetadata::build("std", self.target)
.built_by(self.compiler)
.stage(self.compiler.stage),
)
Some(StepMetadata::build("std", self.target).built_by(self.compiler))
}
}

Expand Down Expand Up @@ -1186,11 +1182,7 @@ impl Step for Rustc {
}

fn metadata(&self) -> Option<StepMetadata> {
Some(
StepMetadata::build("rustc", self.target)
.built_by(self.build_compiler)
.stage(self.build_compiler.stage + 1),
)
Some(StepMetadata::build("rustc", self.target).built_by(self.build_compiler))
}
}

Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,6 @@ macro_rules! tool_extended {
Some(
StepMetadata::build($tool_name, self.target)
.built_by(self.compiler.with_stage(self.compiler.stage.saturating_sub(1)))
.stage(self.compiler.stage)
)
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ impl StepMetadata {
self.stage = Some(stage);
self
}

pub fn get_stage(&self) -> Option<u32> {
self.stage.or(self
.built_by
.map(|compiler| if self.name == "std" { compiler.stage } else { compiler.stage + 1 }))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: maybe explicitly spell out the core model here?

Continuing from #143048 (review),

The stage numbering here has two cases:

  1. (compiler, library) will receive the same $\mathrm{stage}$ number, because std is necessarily tightly coupled to the compiler.
  2. For all other cases, they should be considered $\mathrm{stage} + 1$.

}

pub struct RunConfig<'a> {
Expand Down
103 changes: 52 additions & 51 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ mod snapshot {
insta::assert_snapshot!(
ctx.config("build")
.path("opt-dist")
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist <host>");
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist 1 <host>");
}

#[test]
Expand All @@ -880,7 +880,7 @@ mod snapshot {
ctx.config("build")
.path("opt-dist")
.stage(1)
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist <host>");
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist 1 <host>");
}

#[test]
Expand All @@ -890,7 +890,7 @@ mod snapshot {
ctx.config("build")
.path("opt-dist")
.stage(2)
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist <host>");
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist 1 <host>");
}

#[test]
Expand Down Expand Up @@ -984,23 +984,23 @@ mod snapshot {
ctx
.config("dist")
.render_steps(), @r"
[build] rustc 0 <host> -> UnstableBookGen <host>
[build] rustc 0 <host> -> Rustbook <host>
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
[build] rustc 0 <host> -> Rustbook 1 <host>
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustdoc 1 <host>
[doc] std 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> LintDocs <host>
[build] rustc 0 <host> -> RustInstaller <host>
[build] rustc 0 <host> -> LintDocs 1 <host>
[build] rustc 0 <host> -> RustInstaller 1 <host>
[dist] docs <host>
[doc] std 2 <host>
[dist] mingw <host>
[build] rustc 0 <host> -> GenerateCopyright <host>
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
[dist] rustc <host>
[dist] rustc 1 <host> -> std <host>
[dist] rustc 1 <host> -> std 1 <host>
[dist] src <>
"
);
Expand All @@ -1014,25 +1014,25 @@ mod snapshot {
.config("dist")
.args(&["--set", "build.extended=true"])
.render_steps(), @r"
[build] rustc 0 <host> -> UnstableBookGen <host>
[build] rustc 0 <host> -> Rustbook <host>
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
[build] rustc 0 <host> -> Rustbook 1 <host>
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 0 <host> -> WasmComponentLd <host>
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> WasmComponentLd <host>
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
[build] rustdoc 1 <host>
[doc] std 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> LintDocs <host>
[build] rustc 0 <host> -> RustInstaller <host>
[build] rustc 0 <host> -> LintDocs 1 <host>
[build] rustc 0 <host> -> RustInstaller 1 <host>
[dist] docs <host>
[doc] std 2 <host>
[dist] mingw <host>
[build] rustc 0 <host> -> GenerateCopyright <host>
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
[dist] rustc <host>
[dist] rustc 1 <host> -> std <host>
[dist] rustc 1 <host> -> std 1 <host>
[dist] src <>
[build] rustc 0 <host> -> rustfmt 1 <host>
[build] rustc 0 <host> -> cargo-fmt 1 <host>
Expand All @@ -1052,8 +1052,8 @@ mod snapshot {
.hosts(&[&host_target()])
.targets(&[&host_target(), TEST_TRIPLE_1])
.render_steps(), @r"
[build] rustc 0 <host> -> UnstableBookGen <host>
[build] rustc 0 <host> -> Rustbook <host>
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
[build] rustc 0 <host> -> Rustbook 1 <host>
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
Expand All @@ -1062,19 +1062,19 @@ mod snapshot {
[doc] std 2 <host>
[doc] std 2 <target1>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> LintDocs <host>
[build] rustc 0 <host> -> RustInstaller <host>
[build] rustc 0 <host> -> LintDocs 1 <host>
[build] rustc 0 <host> -> RustInstaller 1 <host>
[dist] docs <host>
[dist] docs <target1>
[doc] std 2 <host>
[doc] std 2 <target1>
[dist] mingw <host>
[dist] mingw <target1>
[build] rustc 0 <host> -> GenerateCopyright <host>
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
[dist] rustc <host>
[dist] rustc 1 <host> -> std <host>
[dist] rustc 1 <host> -> std 1 <host>
[build] rustc 2 <host> -> std 2 <target1>
[dist] rustc 2 <host> -> std <target1>
[dist] rustc 2 <host> -> std 2 <target1>
[dist] src <>
"
);
Expand All @@ -1089,29 +1089,29 @@ mod snapshot {
.hosts(&[&host_target(), TEST_TRIPLE_1])
.targets(&[&host_target()])
.render_steps(), @r"
[build] rustc 0 <host> -> UnstableBookGen <host>
[build] rustc 0 <host> -> Rustbook <host>
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
[build] rustc 0 <host> -> Rustbook 1 <host>
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustdoc 1 <host>
[doc] std 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> LintDocs <host>
[build] rustc 0 <host> -> LintDocs 1 <host>
[build] rustc 1 <host> -> std 1 <target1>
[build] rustc 2 <host> -> std 2 <target1>
[build] rustc 0 <host> -> RustInstaller <host>
[build] rustc 0 <host> -> RustInstaller 1 <host>
[dist] docs <host>
[doc] std 2 <host>
[dist] mingw <host>
[build] rustc 0 <host> -> GenerateCopyright <host>
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
[dist] rustc <host>
[build] llvm <target1>
[build] rustc 1 <host> -> rustc 2 <target1>
[build] rustdoc 1 <target1>
[dist] rustc <target1>
[dist] rustc 1 <host> -> std <host>
[dist] rustc 1 <host> -> std 1 <host>
[dist] src <>
"
);
Expand All @@ -1126,8 +1126,8 @@ mod snapshot {
.hosts(&[&host_target(), TEST_TRIPLE_1])
.targets(&[&host_target(), TEST_TRIPLE_1])
.render_steps(), @r"
[build] rustc 0 <host> -> UnstableBookGen <host>
[build] rustc 0 <host> -> Rustbook <host>
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
[build] rustc 0 <host> -> Rustbook 1 <host>
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
Expand All @@ -1136,24 +1136,24 @@ mod snapshot {
[doc] std 2 <host>
[doc] std 2 <target1>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> LintDocs <host>
[build] rustc 0 <host> -> LintDocs 1 <host>
[build] rustc 1 <host> -> std 1 <target1>
[build] rustc 2 <host> -> std 2 <target1>
[build] rustc 0 <host> -> RustInstaller <host>
[build] rustc 0 <host> -> RustInstaller 1 <host>
[dist] docs <host>
[dist] docs <target1>
[doc] std 2 <host>
[doc] std 2 <target1>
[dist] mingw <host>
[dist] mingw <target1>
[build] rustc 0 <host> -> GenerateCopyright <host>
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
[dist] rustc <host>
[build] llvm <target1>
[build] rustc 1 <host> -> rustc 2 <target1>
[build] rustdoc 1 <target1>
[dist] rustc <target1>
[dist] rustc 1 <host> -> std <host>
[dist] rustc 1 <host> -> std <target1>
[dist] rustc 1 <host> -> std 1 <host>
[dist] rustc 1 <host> -> std 1 <target1>
[dist] src <>
"
);
Expand All @@ -1168,21 +1168,21 @@ mod snapshot {
.hosts(&[])
.targets(&[TEST_TRIPLE_1])
.render_steps(), @r"
[build] rustc 0 <host> -> UnstableBookGen <host>
[build] rustc 0 <host> -> Rustbook <host>
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
[build] rustc 0 <host> -> Rustbook 1 <host>
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustdoc 1 <host>
[doc] std 2 <target1>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 0 <host> -> RustInstaller <host>
[build] rustc 0 <host> -> RustInstaller 1 <host>
[dist] docs <target1>
[doc] std 2 <target1>
[dist] mingw <target1>
[build] rustc 2 <host> -> std 2 <target1>
[dist] rustc 2 <host> -> std <target1>
[dist] rustc 2 <host> -> std 2 <target1>
");
}

Expand All @@ -1198,31 +1198,31 @@ mod snapshot {
.targets(&[TEST_TRIPLE_1])
.args(&["--set", "rust.channel=nightly", "--set", "build.extended=true"])
.render_steps(), @r"
[build] rustc 0 <host> -> UnstableBookGen <host>
[build] rustc 0 <host> -> Rustbook <host>
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
[build] rustc 0 <host> -> Rustbook 1 <host>
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 0 <host> -> WasmComponentLd <host>
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 1 <host> -> WasmComponentLd <host>
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
[build] rustdoc 1 <host>
[doc] std 2 <target1>
[build] rustc 2 <host> -> std 2 <host>
[build] rustc 1 <host> -> std 1 <target1>
[build] rustc 2 <host> -> std 2 <target1>
[build] rustc 0 <host> -> LintDocs <host>
[build] rustc 0 <host> -> RustInstaller <host>
[build] rustc 0 <host> -> LintDocs 1 <host>
[build] rustc 0 <host> -> RustInstaller 1 <host>
[dist] docs <target1>
[doc] std 2 <target1>
[dist] mingw <target1>
[build] llvm <target1>
[build] rustc 1 <host> -> rustc 2 <target1>
[build] rustc 1 <host> -> WasmComponentLd <target1>
[build] rustc 1 <host> -> WasmComponentLd 2 <target1>
[build] rustdoc 1 <target1>
[build] rustc 0 <host> -> GenerateCopyright <host>
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
[dist] rustc <target1>
[dist] rustc 1 <host> -> std <target1>
[dist] rustc 1 <host> -> std 1 <target1>
[dist] src <>
[build] rustc 0 <host> -> rustfmt 1 <target1>
[build] rustc 0 <host> -> cargo-fmt 1 <target1>
Expand Down Expand Up @@ -1384,7 +1384,8 @@ fn render_metadata(metadata: &StepMetadata) -> String {
if let Some(compiler) = metadata.built_by {
write!(record, "{} -> ", render_compiler(compiler));
}
let stage = if let Some(stage) = metadata.stage { format!("{stage} ") } else { "".to_string() };
let stage =
if let Some(stage) = metadata.get_stage() { format!("{stage} ") } else { "".to_string() };
write!(record, "{} {stage}<{}>", metadata.name, normalize_target(metadata.target));
record
}
Expand Down