Skip to content

Commit

Permalink
bootstrap: include llvm-objcopy in dist
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtwco committed Nov 5, 2024
1 parent 27e38f8 commit d8ab230
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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));
}
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d8ab230

Please sign in to comment.