about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2025-07-22 13:45:33 +0200
committerJakub Beránek <berykubik@gmail.com>2025-08-01 15:44:53 +0200
commit7a2c4d312276bec98e4182099d0f8b8b09d55fa3 (patch)
tree18470e6f5217c0944ef91ad9b252d2518ad59328
parent91d40d270d66baa374169be662c403993f5a6591 (diff)
downloadrust-7a2c4d312276bec98e4182099d0f8b8b09d55fa3.tar.gz
rust-7a2c4d312276bec98e4182099d0f8b8b09d55fa3.zip
Add step metadata and a simple test for codegen backends
-rw-r--r--src/bootstrap/src/core/build_steps/compile.rs7
-rw-r--r--src/bootstrap/src/core/builder/tests.rs20
2 files changed, 27 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index 488217549d9..2c54a31ecbe 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -1705,6 +1705,13 @@ impl Step for CodegenBackend {
         let codegen_backend = codegen_backend.to_str().unwrap();
         t!(stamp.add_stamp(codegen_backend).write());
     }
+
+    fn metadata(&self) -> Option<StepMetadata> {
+        Some(
+            StepMetadata::build(&format!("rustc_codegen_{}", self.backend), self.target)
+                .built_by(self.compiler),
+        )
+    }
 }
 
 /// Creates the `codegen-backends` folder for a compiler that's about to be
diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs
index 26158abf4bd..8d458c74cf5 100644
--- a/src/bootstrap/src/core/builder/tests.rs
+++ b/src/bootstrap/src/core/builder/tests.rs
@@ -720,6 +720,26 @@ mod snapshot {
     }
 
     #[test]
+    fn build_compiler_codegen_backend() {
+        let ctx = TestCtx::new();
+        insta::assert_snapshot!(
+            ctx
+                .config("build")
+                .args(&["--set", "rust.codegen-backends=['llvm', 'cranelift']"])
+                .render_steps(), @r"
+        [build] llvm <host>
+        [build] rustc 0 <host> -> rustc 1 <host>
+        [build] rustc 0 <host> -> rustc_codegen_cranelift 1 <host>
+        [build] rustc 1 <host> -> std 1 <host>
+        [build] rustc 1 <host> -> std 1 <host>
+        [build] rustc 1 <host> -> rustc 2 <host>
+        [build] rustc 1 <host> -> rustc_codegen_cranelift 2 <host>
+        [build] rustdoc 1 <host>
+        "
+        );
+    }
+
+    #[test]
     fn build_compiler_tools() {
         let ctx = TestCtx::new();
         insta::assert_snapshot!(