Skip to content

Commit ace1929

Browse files
committed
rustbuild: Tweak LLVM distribution layout
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
1 parent 1c2e17f commit ace1929

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/bootstrap/dist.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,8 @@ fn maybe_install_llvm_dylib(builder: &Builder,
19011901
image: &Path) {
19021902
let src_libdir = builder
19031903
.llvm_out(target)
1904+
.join("lib/rustlib")
1905+
.join(&*target)
19041906
.join("lib");
19051907

19061908
// Usually libLLVM.so is a symlink to something like libLLVM-6.0.so.
@@ -1967,7 +1969,9 @@ impl Step for LlvmTools {
19671969
let src_bindir = builder
19681970
.llvm_out(target)
19691971
.join("bin");
1970-
let dst_bindir = image.join("bin");
1972+
let dst_bindir = image.join("lib/rustlib")
1973+
.join(&*target)
1974+
.join("bin");
19711975
t!(fs::create_dir_all(&dst_bindir));
19721976
for tool in LLVM_TOOLS {
19731977
let exe = src_bindir.join(exe(tool, &target));

0 commit comments

Comments
 (0)