Skip to content

Commit 3c391a6

Browse files
committed
Automatically derive stage in step metadata where possible
1 parent f51c987 commit 3c391a6

File tree

4 files changed

+60
-62
lines changed

4 files changed

+60
-62
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,7 @@ impl Step for Std {
306306
}
307307

308308
fn metadata(&self) -> Option<StepMetadata> {
309-
Some(
310-
StepMetadata::build("std", self.target)
311-
.built_by(self.compiler)
312-
.stage(self.compiler.stage),
313-
)
309+
Some(StepMetadata::build("std", self.target).built_by(self.compiler))
314310
}
315311
}
316312

@@ -1186,11 +1182,7 @@ impl Step for Rustc {
11861182
}
11871183

11881184
fn metadata(&self) -> Option<StepMetadata> {
1189-
Some(
1190-
StepMetadata::build("rustc", self.target)
1191-
.built_by(self.build_compiler)
1192-
.stage(self.build_compiler.stage + 1),
1193-
)
1185+
Some(StepMetadata::build("rustc", self.target).built_by(self.build_compiler))
11941186
}
11951187
}
11961188

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,6 @@ macro_rules! tool_extended {
11951195
Some(
11961196
StepMetadata::build($tool_name, self.target)
11971197
.built_by(self.compiler.with_stage(self.compiler.stage.saturating_sub(1)))
1198-
.stage(self.compiler.stage)
11991198
)
12001199
}
12011200
}

src/bootstrap/src/core/builder/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ impl StepMetadata {
178178
self.stage = Some(stage);
179179
self
180180
}
181+
182+
pub fn get_stage(&self) -> Option<u32> {
183+
self.stage.or(self
184+
.built_by
185+
.map(|compiler| if self.name == "std" { compiler.stage } else { compiler.stage + 1 }))
186+
}
181187
}
182188

183189
pub struct RunConfig<'a> {

src/bootstrap/src/core/builder/tests.rs

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ mod snapshot {
863863
insta::assert_snapshot!(
864864
ctx.config("build")
865865
.path("opt-dist")
866-
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist <host>");
866+
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist 1 <host>");
867867
}
868868

869869
#[test]
@@ -880,7 +880,7 @@ mod snapshot {
880880
ctx.config("build")
881881
.path("opt-dist")
882882
.stage(1)
883-
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist <host>");
883+
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist 1 <host>");
884884
}
885885

886886
#[test]
@@ -890,7 +890,7 @@ mod snapshot {
890890
ctx.config("build")
891891
.path("opt-dist")
892892
.stage(2)
893-
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist <host>");
893+
.render_steps(), @"[build] rustc 0 <host> -> OptimizedDist 1 <host>");
894894
}
895895

896896
#[test]
@@ -984,23 +984,23 @@ mod snapshot {
984984
ctx
985985
.config("dist")
986986
.render_steps(), @r"
987-
[build] rustc 0 <host> -> UnstableBookGen <host>
988-
[build] rustc 0 <host> -> Rustbook <host>
987+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
988+
[build] rustc 0 <host> -> Rustbook 1 <host>
989989
[build] llvm <host>
990990
[build] rustc 0 <host> -> rustc 1 <host>
991991
[build] rustc 1 <host> -> std 1 <host>
992992
[build] rustc 1 <host> -> rustc 2 <host>
993993
[build] rustdoc 1 <host>
994994
[doc] std 2 <host>
995995
[build] rustc 2 <host> -> std 2 <host>
996-
[build] rustc 0 <host> -> LintDocs <host>
997-
[build] rustc 0 <host> -> RustInstaller <host>
996+
[build] rustc 0 <host> -> LintDocs 1 <host>
997+
[build] rustc 0 <host> -> RustInstaller 1 <host>
998998
[dist] docs <host>
999999
[doc] std 2 <host>
10001000
[dist] mingw <host>
1001-
[build] rustc 0 <host> -> GenerateCopyright <host>
1001+
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
10021002
[dist] rustc <host>
1003-
[dist] rustc 1 <host> -> std <host>
1003+
[dist] rustc 1 <host> -> std 1 <host>
10041004
[dist] src <>
10051005
"
10061006
);
@@ -1014,25 +1014,25 @@ mod snapshot {
10141014
.config("dist")
10151015
.args(&["--set", "build.extended=true"])
10161016
.render_steps(), @r"
1017-
[build] rustc 0 <host> -> UnstableBookGen <host>
1018-
[build] rustc 0 <host> -> Rustbook <host>
1017+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1018+
[build] rustc 0 <host> -> Rustbook 1 <host>
10191019
[build] llvm <host>
10201020
[build] rustc 0 <host> -> rustc 1 <host>
1021-
[build] rustc 0 <host> -> WasmComponentLd <host>
1021+
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
10221022
[build] rustc 1 <host> -> std 1 <host>
10231023
[build] rustc 1 <host> -> rustc 2 <host>
1024-
[build] rustc 1 <host> -> WasmComponentLd <host>
1024+
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
10251025
[build] rustdoc 1 <host>
10261026
[doc] std 2 <host>
10271027
[build] rustc 2 <host> -> std 2 <host>
1028-
[build] rustc 0 <host> -> LintDocs <host>
1029-
[build] rustc 0 <host> -> RustInstaller <host>
1028+
[build] rustc 0 <host> -> LintDocs 1 <host>
1029+
[build] rustc 0 <host> -> RustInstaller 1 <host>
10301030
[dist] docs <host>
10311031
[doc] std 2 <host>
10321032
[dist] mingw <host>
1033-
[build] rustc 0 <host> -> GenerateCopyright <host>
1033+
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
10341034
[dist] rustc <host>
1035-
[dist] rustc 1 <host> -> std <host>
1035+
[dist] rustc 1 <host> -> std 1 <host>
10361036
[dist] src <>
10371037
[build] rustc 0 <host> -> rustfmt 1 <host>
10381038
[build] rustc 0 <host> -> cargo-fmt 1 <host>
@@ -1052,8 +1052,8 @@ mod snapshot {
10521052
.hosts(&[&host_target()])
10531053
.targets(&[&host_target(), TEST_TRIPLE_1])
10541054
.render_steps(), @r"
1055-
[build] rustc 0 <host> -> UnstableBookGen <host>
1056-
[build] rustc 0 <host> -> Rustbook <host>
1055+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1056+
[build] rustc 0 <host> -> Rustbook 1 <host>
10571057
[build] llvm <host>
10581058
[build] rustc 0 <host> -> rustc 1 <host>
10591059
[build] rustc 1 <host> -> std 1 <host>
@@ -1062,19 +1062,19 @@ mod snapshot {
10621062
[doc] std 2 <host>
10631063
[doc] std 2 <target1>
10641064
[build] rustc 2 <host> -> std 2 <host>
1065-
[build] rustc 0 <host> -> LintDocs <host>
1066-
[build] rustc 0 <host> -> RustInstaller <host>
1065+
[build] rustc 0 <host> -> LintDocs 1 <host>
1066+
[build] rustc 0 <host> -> RustInstaller 1 <host>
10671067
[dist] docs <host>
10681068
[dist] docs <target1>
10691069
[doc] std 2 <host>
10701070
[doc] std 2 <target1>
10711071
[dist] mingw <host>
10721072
[dist] mingw <target1>
1073-
[build] rustc 0 <host> -> GenerateCopyright <host>
1073+
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
10741074
[dist] rustc <host>
1075-
[dist] rustc 1 <host> -> std <host>
1075+
[dist] rustc 1 <host> -> std 1 <host>
10761076
[build] rustc 2 <host> -> std 2 <target1>
1077-
[dist] rustc 2 <host> -> std <target1>
1077+
[dist] rustc 2 <host> -> std 2 <target1>
10781078
[dist] src <>
10791079
"
10801080
);
@@ -1089,29 +1089,29 @@ mod snapshot {
10891089
.hosts(&[&host_target(), TEST_TRIPLE_1])
10901090
.targets(&[&host_target()])
10911091
.render_steps(), @r"
1092-
[build] rustc 0 <host> -> UnstableBookGen <host>
1093-
[build] rustc 0 <host> -> Rustbook <host>
1092+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1093+
[build] rustc 0 <host> -> Rustbook 1 <host>
10941094
[build] llvm <host>
10951095
[build] rustc 0 <host> -> rustc 1 <host>
10961096
[build] rustc 1 <host> -> std 1 <host>
10971097
[build] rustc 1 <host> -> rustc 2 <host>
10981098
[build] rustdoc 1 <host>
10991099
[doc] std 2 <host>
11001100
[build] rustc 2 <host> -> std 2 <host>
1101-
[build] rustc 0 <host> -> LintDocs <host>
1101+
[build] rustc 0 <host> -> LintDocs 1 <host>
11021102
[build] rustc 1 <host> -> std 1 <target1>
11031103
[build] rustc 2 <host> -> std 2 <target1>
1104-
[build] rustc 0 <host> -> RustInstaller <host>
1104+
[build] rustc 0 <host> -> RustInstaller 1 <host>
11051105
[dist] docs <host>
11061106
[doc] std 2 <host>
11071107
[dist] mingw <host>
1108-
[build] rustc 0 <host> -> GenerateCopyright <host>
1108+
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
11091109
[dist] rustc <host>
11101110
[build] llvm <target1>
11111111
[build] rustc 1 <host> -> rustc 2 <target1>
11121112
[build] rustdoc 1 <target1>
11131113
[dist] rustc <target1>
1114-
[dist] rustc 1 <host> -> std <host>
1114+
[dist] rustc 1 <host> -> std 1 <host>
11151115
[dist] src <>
11161116
"
11171117
);
@@ -1126,8 +1126,8 @@ mod snapshot {
11261126
.hosts(&[&host_target(), TEST_TRIPLE_1])
11271127
.targets(&[&host_target(), TEST_TRIPLE_1])
11281128
.render_steps(), @r"
1129-
[build] rustc 0 <host> -> UnstableBookGen <host>
1130-
[build] rustc 0 <host> -> Rustbook <host>
1129+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1130+
[build] rustc 0 <host> -> Rustbook 1 <host>
11311131
[build] llvm <host>
11321132
[build] rustc 0 <host> -> rustc 1 <host>
11331133
[build] rustc 1 <host> -> std 1 <host>
@@ -1136,24 +1136,24 @@ mod snapshot {
11361136
[doc] std 2 <host>
11371137
[doc] std 2 <target1>
11381138
[build] rustc 2 <host> -> std 2 <host>
1139-
[build] rustc 0 <host> -> LintDocs <host>
1139+
[build] rustc 0 <host> -> LintDocs 1 <host>
11401140
[build] rustc 1 <host> -> std 1 <target1>
11411141
[build] rustc 2 <host> -> std 2 <target1>
1142-
[build] rustc 0 <host> -> RustInstaller <host>
1142+
[build] rustc 0 <host> -> RustInstaller 1 <host>
11431143
[dist] docs <host>
11441144
[dist] docs <target1>
11451145
[doc] std 2 <host>
11461146
[doc] std 2 <target1>
11471147
[dist] mingw <host>
11481148
[dist] mingw <target1>
1149-
[build] rustc 0 <host> -> GenerateCopyright <host>
1149+
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
11501150
[dist] rustc <host>
11511151
[build] llvm <target1>
11521152
[build] rustc 1 <host> -> rustc 2 <target1>
11531153
[build] rustdoc 1 <target1>
11541154
[dist] rustc <target1>
1155-
[dist] rustc 1 <host> -> std <host>
1156-
[dist] rustc 1 <host> -> std <target1>
1155+
[dist] rustc 1 <host> -> std 1 <host>
1156+
[dist] rustc 1 <host> -> std 1 <target1>
11571157
[dist] src <>
11581158
"
11591159
);
@@ -1168,21 +1168,21 @@ mod snapshot {
11681168
.hosts(&[])
11691169
.targets(&[TEST_TRIPLE_1])
11701170
.render_steps(), @r"
1171-
[build] rustc 0 <host> -> UnstableBookGen <host>
1172-
[build] rustc 0 <host> -> Rustbook <host>
1171+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1172+
[build] rustc 0 <host> -> Rustbook 1 <host>
11731173
[build] llvm <host>
11741174
[build] rustc 0 <host> -> rustc 1 <host>
11751175
[build] rustc 1 <host> -> std 1 <host>
11761176
[build] rustc 1 <host> -> rustc 2 <host>
11771177
[build] rustdoc 1 <host>
11781178
[doc] std 2 <target1>
11791179
[build] rustc 2 <host> -> std 2 <host>
1180-
[build] rustc 0 <host> -> RustInstaller <host>
1180+
[build] rustc 0 <host> -> RustInstaller 1 <host>
11811181
[dist] docs <target1>
11821182
[doc] std 2 <target1>
11831183
[dist] mingw <target1>
11841184
[build] rustc 2 <host> -> std 2 <target1>
1185-
[dist] rustc 2 <host> -> std <target1>
1185+
[dist] rustc 2 <host> -> std 2 <target1>
11861186
");
11871187
}
11881188

@@ -1198,31 +1198,31 @@ mod snapshot {
11981198
.targets(&[TEST_TRIPLE_1])
11991199
.args(&["--set", "rust.channel=nightly", "--set", "build.extended=true"])
12001200
.render_steps(), @r"
1201-
[build] rustc 0 <host> -> UnstableBookGen <host>
1202-
[build] rustc 0 <host> -> Rustbook <host>
1201+
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
1202+
[build] rustc 0 <host> -> Rustbook 1 <host>
12031203
[build] llvm <host>
12041204
[build] rustc 0 <host> -> rustc 1 <host>
1205-
[build] rustc 0 <host> -> WasmComponentLd <host>
1205+
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
12061206
[build] rustc 1 <host> -> std 1 <host>
12071207
[build] rustc 1 <host> -> rustc 2 <host>
1208-
[build] rustc 1 <host> -> WasmComponentLd <host>
1208+
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
12091209
[build] rustdoc 1 <host>
12101210
[doc] std 2 <target1>
12111211
[build] rustc 2 <host> -> std 2 <host>
12121212
[build] rustc 1 <host> -> std 1 <target1>
12131213
[build] rustc 2 <host> -> std 2 <target1>
1214-
[build] rustc 0 <host> -> LintDocs <host>
1215-
[build] rustc 0 <host> -> RustInstaller <host>
1214+
[build] rustc 0 <host> -> LintDocs 1 <host>
1215+
[build] rustc 0 <host> -> RustInstaller 1 <host>
12161216
[dist] docs <target1>
12171217
[doc] std 2 <target1>
12181218
[dist] mingw <target1>
12191219
[build] llvm <target1>
12201220
[build] rustc 1 <host> -> rustc 2 <target1>
1221-
[build] rustc 1 <host> -> WasmComponentLd <target1>
1221+
[build] rustc 1 <host> -> WasmComponentLd 2 <target1>
12221222
[build] rustdoc 1 <target1>
1223-
[build] rustc 0 <host> -> GenerateCopyright <host>
1223+
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
12241224
[dist] rustc <target1>
1225-
[dist] rustc 1 <host> -> std <target1>
1225+
[dist] rustc 1 <host> -> std 1 <target1>
12261226
[dist] src <>
12271227
[build] rustc 0 <host> -> rustfmt 1 <target1>
12281228
[build] rustc 0 <host> -> cargo-fmt 1 <target1>
@@ -1384,7 +1384,8 @@ fn render_metadata(metadata: &StepMetadata) -> String {
13841384
if let Some(compiler) = metadata.built_by {
13851385
write!(record, "{} -> ", render_compiler(compiler));
13861386
}
1387-
let stage = if let Some(stage) = metadata.stage { format!("{stage} ") } else { "".to_string() };
1387+
let stage =
1388+
if let Some(stage) = metadata.get_stage() { format!("{stage} ") } else { "".to_string() };
13881389
write!(record, "{} {stage}<{}>", metadata.name, normalize_target(metadata.target));
13891390
record
13901391
}

0 commit comments

Comments
 (0)