Skip to content

Commit 202d8da

Browse files
author
Robin Kruppe
committed
rustbuild: expose LLVM_PARALLEL_LINK_JOBS
This allows limiting the number of linker jobs to avoid swapping when linking LLVM with debug info.
1 parent 27918f3 commit 202d8da

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub struct Config {
5959
pub llvm_static_stdcpp: bool,
6060
pub llvm_link_shared: bool,
6161
pub llvm_targets: Option<String>,
62+
pub llvm_link_jobs: Option<u32>,
6263

6364
// rust codegen options
6465
pub rust_optimize: bool,
@@ -179,6 +180,7 @@ struct Llvm {
179180
version_check: Option<bool>,
180181
static_libstdcpp: Option<bool>,
181182
targets: Option<String>,
183+
link_jobs: Option<u32>,
182184
}
183185

184186
#[derive(RustcDecodable, Default, Clone)]
@@ -333,6 +335,7 @@ impl Config {
333335
set(&mut config.llvm_version_check, llvm.version_check);
334336
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
335337
config.llvm_targets = llvm.targets.clone();
338+
config.llvm_link_jobs = llvm.link_jobs;
336339
}
337340

338341
if let Some(ref rust) = toml.rust {

src/bootstrap/config.toml.example

+8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@
5353
# Rust team and file an issue if you need assistance in porting!
5454
#targets = "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX"
5555

56+
# Cap the number of parallel linker invocations when compiling LLVM.
57+
# This can be useful when building LLVM with debug info, which significantly
58+
# increases the size of binaries and consequently the memory required by
59+
# each linker process.
60+
# If absent or 0, linker invocations are treated like any other job and
61+
# controlled by rustbuild's -j parameter.
62+
#link-jobs = 0
63+
5664
# =============================================================================
5765
# General build configuration options
5866
# =============================================================================

src/bootstrap/native.rs

+6
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ pub fn llvm(build: &Build, target: &str) {
109109
cfg.define("LLVM_BUILD_32_BITS", "ON");
110110
}
111111

112+
if let Some(num_linkers) = build.config.llvm_link_jobs {
113+
if num_linkers > 0 {
114+
cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string());
115+
}
116+
}
117+
112118
// http://llvm.org/docs/HowToCrossCompileLLVM.html
113119
if target != build.config.build {
114120
// FIXME: if the llvm root for the build triple is overridden then we

0 commit comments

Comments
 (0)