bootstrap: include llvm-objcopy in dist

This commit is contained in:
David Wood 2024-10-08 15:19:37 +01:00
parent 27e38f8fc7
commit d8ab230e73
No known key found for this signature in database
3 changed files with 24 additions and 6 deletions

View File

@ -219,8 +219,7 @@ fn run(self, builder: &Builder<'_>) {
.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 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
}
}
{
// `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

View File

@ -459,8 +459,7 @@ fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
// 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 @@ fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
);
}
}
{
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));
}

View File

@ -1161,6 +1161,11 @@ pub fn sysroot(&self, compiler: Compiler) -> PathBuf {
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 {