Skip to content

Commit f001a0c

Browse files
Enable shared linking to LLVM on non-Windows
Windows doesn't quite support dynamic linking to LLVM yet, but on other platforms we do. In #76708, it was discovered that we dynamically link to LLVM from the LLVM tools (e.g., rust-lld), so we need the shared LLVM library to link against. That means that if we do not have a shared link to LLVM, and want LLVM tools to work, we'd be shipping two copies of LLVM on all of these platforms: one in librustc_driver and one in libLLVM. Also introduce an error into rustbuild if we do end up configured for shared linking on Windows.
1 parent 90b1f5a commit f001a0c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/bootstrap/native.rs

+4
Original file line numberDiff line numberDiff line change
@@ -129,6 +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");
134+
}
135+
132136
builder.info(&format!("Building LLVM for {}", target));
133137
t!(stamp.remove());
134138
let _time = util::timeit(&builder);

src/ci/run.sh

+7
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ 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+
7885
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
7986
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
8087
elif [ "$DEPLOY_ALT" != "" ]; then

0 commit comments

Comments
 (0)