Skip to content

Commit 241160d

Browse files
committed
bootstrap: copy llvm-dwp to sysroot
`llvm-dwp` is required for linking the DWARF objects into DWARF packages when using Split DWARF, especially given that rustc produces multiple DWARF objects (one for each codegen unit). Signed-off-by: David Wood <david@davidtw.co>
1 parent 6890312 commit 241160d

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

src/bootstrap/compile.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -969,15 +969,25 @@ impl Step for Assemble {
969969

970970
copy_codegen_backends_to_sysroot(builder, build_compiler, target_compiler);
971971

972+
// We prepend this bin directory to the user PATH when linking Rust binaries. To
973+
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
972974
let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host);
975+
let libdir_bin = libdir.parent().unwrap().join("bin");
976+
t!(fs::create_dir_all(&libdir_bin));
977+
973978
if let Some(lld_install) = lld_install {
974979
let src_exe = exe("lld", target_compiler.host);
975980
let dst_exe = exe("rust-lld", target_compiler.host);
976-
// we prepend this bin directory to the user PATH when linking Rust binaries. To
977-
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
978-
let dst = libdir.parent().unwrap().join("bin");
979-
t!(fs::create_dir_all(&dst));
980-
builder.copy(&lld_install.join("bin").join(&src_exe), &dst.join(&dst_exe));
981+
builder.copy(&lld_install.join("bin").join(&src_exe), &libdir_bin.join(&dst_exe));
982+
}
983+
984+
// Similarly, copy `llvm-dwp` into libdir for Split DWARF.
985+
{
986+
let src_exe = exe("llvm-dwp", target_compiler.host);
987+
let dst_exe = exe("rust-llvm-dwp", target_compiler.host);
988+
let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host });
989+
let llvm_bin_dir = llvm_config_bin.parent().unwrap();
990+
builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
981991
}
982992

983993
// Ensure that `libLLVM.so` ends up in the newly build compiler directory,

src/bootstrap/dist.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -523,17 +523,20 @@ impl Step for Rustc {
523523
// component for now.
524524
maybe_install_llvm_runtime(builder, host, image);
525525

526+
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
527+
let dst_dir = image.join("lib/rustlib").join(&*host.triple).join("bin");
528+
t!(fs::create_dir_all(&dst_dir));
529+
526530
// Copy over lld if it's there
527531
if builder.config.lld_enabled {
528532
let exe = exe("rust-lld", compiler.host);
529-
let src =
530-
builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin").join(&exe);
531-
// for the rationale about this rename check `compile::copy_lld_to_sysroot`
532-
let dst = image.join("lib/rustlib").join(&*host.triple).join("bin").join(&exe);
533-
t!(fs::create_dir_all(&dst.parent().unwrap()));
534-
builder.copy(&src, &dst);
533+
builder.copy(&src_dir.join(&exe), &dst_dir.join(&exe));
535534
}
536535

536+
// Copy over llvm-dwp if it's there
537+
let exe = exe("rust-llvm-dwp", compiler.host);
538+
builder.copy(&src_dir.join(&exe), &dst_dir.join(&exe));
539+
537540
// Man pages
538541
t!(fs::create_dir_all(image.join("share/man/man1")));
539542
let man_src = builder.src.join("src/doc/man");

0 commit comments

Comments
 (0)