about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Wood <david.wood2@arm.com>2024-10-08 15:19:37 +0100
committerDavid Wood <david.wood2@arm.com>2024-11-05 11:49:03 +0000
commitd8ab230e731ea0bcaf299b86e82558f354f8e2b0 (patch)
tree3eeb28d199330836761235c9c921500ab4b03463
parent27e38f8fc7efc57b75e9a763d7a0ee44822cd5f7 (diff)
downloadrust-d8ab230e731ea0bcaf299b86e82558f354f8e2b0.tar.gz
rust-d8ab230e731ea0bcaf299b86e82558f354f8e2b0.zip
bootstrap: include `llvm-objcopy` in dist
-rw-r--r--src/bootstrap/src/core/build_steps/compile.rs11
-rw-r--r--src/bootstrap/src/core/build_steps/dist.rs14
-rw-r--r--src/bootstrap/src/core/builder/mod.rs5
3 files changed, 24 insertions, 6 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index 9ddcde7eb2c..3394f2a84a0 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -219,8 +219,7 @@ impl Step for Std {
                 .join(compiler.host)
                 .join("bin");
             if src_sysroot_bin.exists() {
-                let target_sysroot_bin =
-                    builder.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin");
+                let target_sysroot_bin = builder.sysroot_target_bindir(compiler, target);
                 t!(fs::create_dir_all(&target_sysroot_bin));
                 builder.cp_link_r(&src_sysroot_bin, &target_sysroot_bin);
             }
@@ -1977,6 +1976,14 @@ impl Step for Assemble {
             }
         }
 
+        {
+            // `llvm-strip` is used by rustc, which is actually just a symlink to `llvm-objcopy`,
+            // so copy and rename `llvm-objcopy`.
+            let src_exe = exe("llvm-objcopy", target_compiler.host);
+            let dst_exe = exe("rust-objcopy", target_compiler.host);
+            builder.copy_link(&libdir_bin.join(src_exe), &libdir_bin.join(dst_exe));
+        }
+
         // In addition to `rust-lld` also install `wasm-component-ld` when
         // LLD is enabled. This is a relatively small binary that primarily
         // delegates to the `rust-lld` binary for linking and then runs
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index 759e720c208..c022285211f 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -459,8 +459,7 @@ impl Step for Rustc {
 
             // Copy over lld if it's there
             if builder.config.lld_enabled {
-                let src_dir =
-                    builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
+                let src_dir = builder.sysroot_target_bindir(compiler, host);
                 let rust_lld = exe("rust-lld", compiler.host);
                 builder.copy_link(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
                 let self_contained_lld_src_dir = src_dir.join("gcc-ld");
@@ -474,9 +473,16 @@ impl Step for Rustc {
                     );
                 }
             }
+
+            {
+                let src_dir = builder.sysroot_target_bindir(compiler, host);
+                let llvm_objcopy = exe("llvm-objcopy", compiler.host);
+                let rust_objcopy = exe("rust-objcopy", compiler.host);
+                builder.copy_link(&src_dir.join(&llvm_objcopy), &dst_dir.join(&rust_objcopy));
+            }
+
             if builder.tool_enabled("wasm-component-ld") {
-                let src_dir =
-                    builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
+                let src_dir = builder.sysroot_target_bindir(compiler, host);
                 let ld = exe("wasm-component-ld", compiler.host);
                 builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld));
             }
diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs
index 19472bac4af..f1b3cf6da13 100644
--- a/src/bootstrap/src/core/builder/mod.rs
+++ b/src/bootstrap/src/core/builder/mod.rs
@@ -1161,6 +1161,11 @@ impl<'a> Builder<'a> {
         self.ensure(compile::Sysroot::new(compiler))
     }
 
+    /// Returns the bindir for a compiler's sysroot.
+    pub fn sysroot_target_bindir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
+        self.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin")
+    }
+
     /// Returns the libdir where the standard library and other artifacts are
     /// found for a compiler's sysroot.
     pub fn sysroot_target_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {