Skip to content

Commit 389b7ff

Browse files
Do not link LLVM tools to LLVM dylib unless rustc is
Previously we would have some platforms where LLVM was linked to rustc statically, but to the LLVM tools dynamically. That meant we were distributing two copies of LLVM: one as a separate dylib and one statically linked in to librustc_driver.
1 parent 8e9d5db commit 389b7ff

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

src/bootstrap/dist.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,14 +2401,11 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
24012401
return;
24022402
}
24032403

2404-
// On macOS for some reason the llvm-config binary behaves differently and
2405-
// and fails on missing .a files if run without --link-shared. If run with
2406-
// that option, it still fails, but because we only ship a libLLVM.dylib
2407-
// rather than libLLVM-11-rust-....dylib file.
2408-
//
2409-
// For now just don't use llvm-config here on macOS; that will fail to
2410-
// support CI-built LLVM, but until we work out the different behavior that
2411-
// is fine as it is off by default.
2404+
// On macOS, rustc (and LLVM tools) link to an unversioned libLLVM.dylib
2405+
// instead of libLLVM-11-rust-....dylib, as on linux. It's not entirely
2406+
// clear why this is the case, though. llvm-config will emit the versioned
2407+
// paths and we don't want those in the sysroot (as we're expecting
2408+
// unversioned paths).
24122409
if target.contains("apple-darwin") {
24132410
let src_libdir = builder.llvm_out(target).join("lib");
24142411
let llvm_dylib_path = src_libdir.join("libLLVM.dylib");

src/bootstrap/native.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ impl Step for Llvm {
129129
Err(m) => m,
130130
};
131131

132-
if builder.config.llvm_link_shared && target.contains("windows") {
133-
panic!("shared linking to LLVM is not currently supported on Windows");
132+
if builder.config.llvm_link_shared
133+
&& (target.contains("windows") || target.contains("apple-darwin"))
134+
{
135+
panic!("shared linking to LLVM is not currently supported on {}", target.triple);
134136
}
135137

136138
builder.info(&format!("Building LLVM for {}", target));
@@ -209,7 +211,10 @@ impl Step for Llvm {
209211
// which saves both memory during parallel links and overall disk space
210212
// for the tools. We don't do this on every platform as it doesn't work
211213
// equally well everywhere.
212-
if builder.llvm_link_tools_dynamically(target) {
214+
//
215+
// If we're not linking rustc to a dynamic LLVM, though, then don't link
216+
// tools to it.
217+
if builder.llvm_link_tools_dynamically(target) && builder.config.llvm_link_shared {
213218
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
214219
}
215220

src/ci/run.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
7575
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
7676
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1"
7777

78-
# If we're distributing binaries, we want a shared LLVM link. We're already
79-
# going to link LLVM to the LLVM tools dynamically, so we need to ship a
80-
# libLLVM library anyway.
81-
if !isWindows; then
82-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set llvm.link-shared=true"
83-
fi
84-
8578
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
8679
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
8780
elif [ "$DEPLOY_ALT" != "" ]; then

0 commit comments

Comments
 (0)