From d8ab230e731ea0bcaf299b86e82558f354f8e2b0 Mon Sep 17 00:00:00 2001 From: David Wood Date: Tue, 8 Oct 2024 15:19:37 +0100 Subject: [PATCH] bootstrap: include `llvm-objcopy` in dist --- src/bootstrap/src/core/build_steps/compile.rs | 11 +++++++++-- src/bootstrap/src/core/build_steps/dist.rs | 14 ++++++++++---- src/bootstrap/src/core/builder/mod.rs | 5 +++++ 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 9ddcde7eb2cfc..3394f2a84a047 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 759e720c208d8..c022285211fab 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 19472bac4af85..f1b3cf6da13ec 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 {