Skip to content

Commit

Permalink
rustbuild: Tweak LLVM distribution layout
Browse files Browse the repository at this point in the history
This commit tweaks the layout of a few components that we distribute to
hopefully fix across all platforms the recent issues with LLD being unable to
find the LLVM shared object. In #53245 we switched to building LLVM as a dynamic
library, which means that LLVM tools by default link to LLVM dynamically rather
than statically. This in turn means that the tools, at runtime, need to find the
LLVM shared library.

LLVM's shared library is currently distributed as part of the rustc component.
This library is located, however, at `$sysroot/lib`. The LLVM tools we ship are
in two locations:

* LLD is shipped at `$sysroot/lib/rustlib/$host/bin/rust-lld`
* Other LLVM tools are shipped at `$sysroot/bin`

Each LLVM tool has an embedded rpath directive indicating where it will search
for dynamic libraries. This currently points to `../lib` and is presumably
inserted by LLVM's build system. Unfortunately, though, this directive is only
correct for the LLVM tools at `$sysroot/bin`, not LLD!

This commit is targeted at fixing this situation by making two changes:

* LLVM tools other than LLD are moved in the distribution to
  `$sysroot/lib/rustlib/$host/bin`. This moves them next to LLD and should
  position them for...
* The LLVM shared object is moved to `$sysroot/lib/rustlib/$host/lib`

Together this means that all tools should natively be able to find the shared
object and the shared object should be installed all the time for the various
tools. Overall this should...

Closes #53813
  • Loading branch information
alexcrichton committed Sep 4, 2018
1 parent 1c2e17f commit ace1929
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,8 @@ fn maybe_install_llvm_dylib(builder: &Builder,
image: &Path) {
let src_libdir = builder
.llvm_out(target)
.join("lib/rustlib")
.join(&*target)
.join("lib");

// Usually libLLVM.so is a symlink to something like libLLVM-6.0.so.
Expand Down Expand Up @@ -1967,7 +1969,9 @@ impl Step for LlvmTools {
let src_bindir = builder
.llvm_out(target)
.join("bin");
let dst_bindir = image.join("bin");
let dst_bindir = image.join("lib/rustlib")
.join(&*target)
.join("bin");
t!(fs::create_dir_all(&dst_bindir));
for tool in LLVM_TOOLS {
let exe = src_bindir.join(exe(tool, &target));
Expand Down

0 comments on commit ace1929

Please sign in to comment.