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.
This commit is contained in:
Mark Rousskov 2020-09-14 16:22:56 -04:00
parent 90b1f5ae59
commit f001a0c8dd
2 changed files with 11 additions and 0 deletions

View File

@ -129,6 +129,10 @@ impl Step for Llvm {
Err(m) => m, Err(m) => m,
}; };
if builder.config.llvm_link_shared && target.contains("windows") {
panic!("shared linking to LLVM is not currently supported on Windows");
}
builder.info(&format!("Building LLVM for {}", target)); builder.info(&format!("Building LLVM for {}", target));
t!(stamp.remove()); t!(stamp.remove());
let _time = util::timeit(&builder); let _time = util::timeit(&builder);

View File

@ -75,6 +75,13 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1"
# If we're distributing binaries, we want a shared LLVM link. We're already
# going to link LLVM to the LLVM tools dynamically, so we need to ship a
# libLLVM library anyway.
if !isWindows; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set llvm.link-shared=true"
fi
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
elif [ "$DEPLOY_ALT" != "" ]; then elif [ "$DEPLOY_ALT" != "" ]; then