about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-08-04 17:36:10 +0000
committerbors <bors@rust-lang.org>2017-08-04 17:36:10 +0000
commitff1135b224baac6bfc14970cb5d74dd66680e5e2 (patch)
treee4740c4cd0e05cdd2086564742ed1223805b09fe /src/bootstrap
parentdae8864dbe1b81e4cd3b2a6b046a95db337b3098 (diff)
parent6c46f4f11cdd56fcd12c86d121259c738b7a8376 (diff)
downloadrust-ff1135b224baac6bfc14970cb5d74dd66680e5e2.tar.gz
rust-ff1135b224baac6bfc14970cb5d74dd66680e5e2.zip
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`.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/native.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index cfd20b02aaf..ee0eca5d482 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -129,6 +129,15 @@ impl Step for Llvm {
            .define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
            .define("LLVM_DEFAULT_TARGET_TRIPLE", target);
 
+
+        // This setting makes the LLVM tools link to the dynamic LLVM library,
+        // which saves both memory during parallel links and overall disk space
+        // for the tools.  We don't distribute any of those tools, so this is
+        // just a local concern.  However, it doesn't work well everywhere.
+        if target.contains("linux-gnu") || target.contains("apple-darwin") {
+           cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
+        }
+
         if target.contains("msvc") {
             cfg.define("LLVM_USE_CRT_DEBUG", "MT");
             cfg.define("LLVM_USE_CRT_RELEASE", "MT");