about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-10-28 19:11:51 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-10-28 19:12:44 +0000
commitaefd7ace91b58eb8cf00817de24a42ae2b3956d3 (patch)
tree16e2e9d762c633dda33c87cea5ea46ed146bbe59 /src/bootstrap
parent794bf8a850b3e83705845de398b51547d5366bb1 (diff)
downloadrust-aefd7ace91b58eb8cf00817de24a42ae2b3956d3.tar.gz
rust-aefd7ace91b58eb8cf00817de24a42ae2b3956d3.zip
Ensure the rustc-codegen-cranelift-preview component is never empty
Either generate it with the actual codegen backend dylib or omit it
entirely when the cranelift backend is disabled for this build.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/core/build_steps/dist.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index b578c5ec295..197ce78d885 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -1305,6 +1305,10 @@ impl Step for CodegenBackend {
             return None;
         }
 
+        if !builder.config.rust_codegen_backends.contains(&self.backend) {
+            return None;
+        }
+
         if self.backend == "cranelift" {
             if !target_supports_cranelift_backend(self.compiler.host) {
                 builder.info("target not supported by rustc_codegen_cranelift. skipping");
@@ -1343,12 +1347,15 @@ impl Step for CodegenBackend {
         let backends_dst = PathBuf::from("lib").join(&backends_rel);
 
         let backend_name = format!("rustc_codegen_{}", backend);
+        let mut found_backend = false;
         for backend in fs::read_dir(&backends_src).unwrap() {
             let file_name = backend.unwrap().file_name();
             if file_name.to_str().unwrap().contains(&backend_name) {
                 tarball.add_file(backends_src.join(file_name), &backends_dst, 0o644);
+                found_backend = true;
             }
         }
+        assert!(found_backend);
 
         Some(tarball.generate())
     }