Skip to content

Commit d8ab230

Browse files
committed
bootstrap: include llvm-objcopy in dist
1 parent 27e38f8 commit d8ab230

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ impl Step for Std {
219219
.join(compiler.host)
220220
.join("bin");
221221
if src_sysroot_bin.exists() {
222-
let target_sysroot_bin =
223-
builder.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin");
222+
let target_sysroot_bin = builder.sysroot_target_bindir(compiler, target);
224223
t!(fs::create_dir_all(&target_sysroot_bin));
225224
builder.cp_link_r(&src_sysroot_bin, &target_sysroot_bin);
226225
}
@@ -1977,6 +1976,14 @@ impl Step for Assemble {
19771976
}
19781977
}
19791978

1979+
{
1980+
// `llvm-strip` is used by rustc, which is actually just a symlink to `llvm-objcopy`,
1981+
// so copy and rename `llvm-objcopy`.
1982+
let src_exe = exe("llvm-objcopy", target_compiler.host);
1983+
let dst_exe = exe("rust-objcopy", target_compiler.host);
1984+
builder.copy_link(&libdir_bin.join(src_exe), &libdir_bin.join(dst_exe));
1985+
}
1986+
19801987
// In addition to `rust-lld` also install `wasm-component-ld` when
19811988
// LLD is enabled. This is a relatively small binary that primarily
19821989
// delegates to the `rust-lld` binary for linking and then runs

src/bootstrap/src/core/build_steps/dist.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ impl Step for Rustc {
459459

460460
// Copy over lld if it's there
461461
if builder.config.lld_enabled {
462-
let src_dir =
463-
builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
462+
let src_dir = builder.sysroot_target_bindir(compiler, host);
464463
let rust_lld = exe("rust-lld", compiler.host);
465464
builder.copy_link(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
466465
let self_contained_lld_src_dir = src_dir.join("gcc-ld");
@@ -474,9 +473,16 @@ impl Step for Rustc {
474473
);
475474
}
476475
}
476+
477+
{
478+
let src_dir = builder.sysroot_target_bindir(compiler, host);
479+
let llvm_objcopy = exe("llvm-objcopy", compiler.host);
480+
let rust_objcopy = exe("rust-objcopy", compiler.host);
481+
builder.copy_link(&src_dir.join(&llvm_objcopy), &dst_dir.join(&rust_objcopy));
482+
}
483+
477484
if builder.tool_enabled("wasm-component-ld") {
478-
let src_dir =
479-
builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
485+
let src_dir = builder.sysroot_target_bindir(compiler, host);
480486
let ld = exe("wasm-component-ld", compiler.host);
481487
builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld));
482488
}

src/bootstrap/src/core/builder/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,11 @@ impl<'a> Builder<'a> {
11611161
self.ensure(compile::Sysroot::new(compiler))
11621162
}
11631163

1164+
/// Returns the bindir for a compiler's sysroot.
1165+
pub fn sysroot_target_bindir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
1166+
self.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin")
1167+
}
1168+
11641169
/// Returns the libdir where the standard library and other artifacts are
11651170
/// found for a compiler's sysroot.
11661171
pub fn sysroot_target_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {

0 commit comments

Comments
 (0)