Skip to content

Commit 7a2c4d3

Browse files
committed
Add step metadata and a simple test for codegen backends
1 parent 91d40d2 commit 7a2c4d3

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,13 @@ impl Step for CodegenBackend {
17051705
let codegen_backend = codegen_backend.to_str().unwrap();
17061706
t!(stamp.add_stamp(codegen_backend).write());
17071707
}
1708+
1709+
fn metadata(&self) -> Option<StepMetadata> {
1710+
Some(
1711+
StepMetadata::build(&format!("rustc_codegen_{}", self.backend), self.target)
1712+
.built_by(self.compiler),
1713+
)
1714+
}
17081715
}
17091716

17101717
/// Creates the `codegen-backends` folder for a compiler that's about to be

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,26 @@ mod snapshot {
719719
");
720720
}
721721

722+
#[test]
723+
fn build_compiler_codegen_backend() {
724+
let ctx = TestCtx::new();
725+
insta::assert_snapshot!(
726+
ctx
727+
.config("build")
728+
.args(&["--set", "rust.codegen-backends=['llvm', 'cranelift']"])
729+
.render_steps(), @r"
730+
[build] llvm <host>
731+
[build] rustc 0 <host> -> rustc 1 <host>
732+
[build] rustc 0 <host> -> rustc_codegen_cranelift 1 <host>
733+
[build] rustc 1 <host> -> std 1 <host>
734+
[build] rustc 1 <host> -> std 1 <host>
735+
[build] rustc 1 <host> -> rustc 2 <host>
736+
[build] rustc 1 <host> -> rustc_codegen_cranelift 2 <host>
737+
[build] rustdoc 1 <host>
738+
"
739+
);
740+
}
741+
722742
#[test]
723743
fn build_compiler_tools() {
724744
let ctx = TestCtx::new();

0 commit comments

Comments
 (0)