Skip to content

Commit

Permalink
bootstrap: copy llvm-dwp to sysroot
Browse files Browse the repository at this point in the history
`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>
  • Loading branch information
davidtwco committed Dec 16, 2020
1 parent 6890312 commit 241160d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
20 changes: 15 additions & 5 deletions src/bootstrap/compile.rs
Expand Up @@ -969,15 +969,25 @@ impl Step for Assemble {

copy_codegen_backends_to_sysroot(builder, build_compiler, target_compiler);

// We prepend this bin directory to the user PATH when linking Rust binaries. To
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host);
let libdir_bin = libdir.parent().unwrap().join("bin");
t!(fs::create_dir_all(&libdir_bin));

if let Some(lld_install) = lld_install {
let src_exe = exe("lld", target_compiler.host);
let dst_exe = exe("rust-lld", target_compiler.host);
// we prepend this bin directory to the user PATH when linking Rust binaries. To
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
let dst = libdir.parent().unwrap().join("bin");
t!(fs::create_dir_all(&dst));
builder.copy(&lld_install.join("bin").join(&src_exe), &dst.join(&dst_exe));
builder.copy(&lld_install.join("bin").join(&src_exe), &libdir_bin.join(&dst_exe));
}

// Similarly, copy `llvm-dwp` into libdir for Split DWARF.
{
let src_exe = exe("llvm-dwp", target_compiler.host);
let dst_exe = exe("rust-llvm-dwp", target_compiler.host);
let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host });
let llvm_bin_dir = llvm_config_bin.parent().unwrap();
builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
}

// Ensure that `libLLVM.so` ends up in the newly build compiler directory,
Expand Down
15 changes: 9 additions & 6 deletions src/bootstrap/dist.rs
Expand Up @@ -523,17 +523,20 @@ impl Step for Rustc {
// component for now.
maybe_install_llvm_runtime(builder, host, image);

let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
let dst_dir = image.join("lib/rustlib").join(&*host.triple).join("bin");
t!(fs::create_dir_all(&dst_dir));

// Copy over lld if it's there
if builder.config.lld_enabled {
let exe = exe("rust-lld", compiler.host);
let src =
builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin").join(&exe);
// for the rationale about this rename check `compile::copy_lld_to_sysroot`
let dst = image.join("lib/rustlib").join(&*host.triple).join("bin").join(&exe);
t!(fs::create_dir_all(&dst.parent().unwrap()));
builder.copy(&src, &dst);
builder.copy(&src_dir.join(&exe), &dst_dir.join(&exe));
}

// Copy over llvm-dwp if it's there
let exe = exe("rust-llvm-dwp", compiler.host);
builder.copy(&src_dir.join(&exe), &dst_dir.join(&exe));

// Man pages
t!(fs::create_dir_all(image.join("share/man/man1")));
let man_src = builder.src.join("src/doc/man");
Expand Down

0 comments on commit 241160d

Please sign in to comment.