Skip to content

Commit ff1135b

Browse files
committed
Auto merge of #43577 - cuviper:link-llvm-dylib, r=sanxiyn
Link LLVM tools dynamically Set `LLVM_LINK_LLVM_DYLIB=ON` -- "If enabled, tools will be linked with the libLLVM shared library." Rust doesn't ship any of the LLVM tools, and only needs a few at all for some test cases, so statically linking the tools is just a waste of space. I've also had memory issues on slower machines with LLVM debuginfo enabled, when several tools start linking in parallel consuming several GBs each. With the default configuration, `build/x86_64-unknown-linux-gnu/llvm` was 1.5GB before, now down to 731MB. The difference is more drastic with `--enable-llvm-release-debuginfo`, from 28GB to "only" 13GB. This does not change the linking behavior of `rustc_llvm`.
2 parents dae8864 + 6c46f4f commit ff1135b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bootstrap/native.rs

+9
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ impl Step for Llvm {
129129
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
130130
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
131131

132+
133+
// This setting makes the LLVM tools link to the dynamic LLVM library,
134+
// which saves both memory during parallel links and overall disk space
135+
// for the tools. We don't distribute any of those tools, so this is
136+
// just a local concern. However, it doesn't work well everywhere.
137+
if target.contains("linux-gnu") || target.contains("apple-darwin") {
138+
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
139+
}
140+
132141
if target.contains("msvc") {
133142
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
134143
cfg.define("LLVM_USE_CRT_RELEASE", "MT");

0 commit comments

Comments
 (0)