From 1636a2cf41d79630ecc94f9a8b6d9e8bb501b048 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 31 Jul 2017 15:34:05 -0700 Subject: [PATCH 1/3] 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`. --- src/bootstrap/native.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index cfd20b02aaf..595f90be1dd 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -125,6 +125,7 @@ impl Step for Llvm { .define("WITH_POLLY", "OFF") .define("LLVM_ENABLE_TERMINFO", "OFF") .define("LLVM_ENABLE_LIBEDIT", "OFF") + .define("LLVM_LINK_LLVM_DYLIB", "ON") .define("LLVM_PARALLEL_COMPILE_JOBS", build.jobs().to_string()) .define("LLVM_TARGET_ARCH", target.split('-').next().unwrap()) .define("LLVM_DEFAULT_TARGET_TRIPLE", target); From ced1fda5659d324c9f4f98968de2bc893c456aa4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 3 Aug 2017 15:42:05 -0700 Subject: [PATCH 2/3] Exclude Windows from LLVM_LINK_LLVM_DYLIB --- src/bootstrap/native.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 595f90be1dd..ce0052a5fb6 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -125,11 +125,19 @@ impl Step for Llvm { .define("WITH_POLLY", "OFF") .define("LLVM_ENABLE_TERMINFO", "OFF") .define("LLVM_ENABLE_LIBEDIT", "OFF") - .define("LLVM_LINK_LLVM_DYLIB", "ON") .define("LLVM_PARALLEL_COMPILE_JOBS", build.jobs().to_string()) .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, this doesn't seem to work on Windows. + if !target.contains("windows") { + 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"); From 6c46f4f11cdd56fcd12c86d121259c738b7a8376 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 4 Aug 2017 00:13:11 -0700 Subject: [PATCH 3/3] Use LLVM_LINK_LLVM_DYLIB only on linux-gnu and apple-darwin --- src/bootstrap/native.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index ce0052a5fb6..ee0eca5d482 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -133,8 +133,8 @@ impl Step for Llvm { // 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, this doesn't seem to work on Windows. - if !target.contains("windows") { + // 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"); }