Skip to content

Commit 95ab30f

Browse files
authored
Rollup merge of rust-lang#40277 - rkruppe:llvm-parallel-link-jobs, r=alexcrichton
rustbuild: expose LLVM_PARALLEL_LINK_JOBS This allows limiting the number of linker jobs to avoid swapping when linking LLVM with debug info.
2 parents 1aa32bc + 202d8da commit 95ab30f

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/bootstrap/config.rs

Lines changed: 3 additions & 0 deletions
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,
@@ -180,6 +181,7 @@ struct Llvm {
180181
version_check: Option<bool>,
181182
static_libstdcpp: Option<bool>,
182183
targets: Option<String>,
184+
link_jobs: Option<u32>,
183185
}
184186

185187
#[derive(RustcDecodable, Default, Clone)]
@@ -335,6 +337,7 @@ impl Config {
335337
set(&mut config.llvm_version_check, llvm.version_check);
336338
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
337339
config.llvm_targets = llvm.targets.clone();
340+
config.llvm_link_jobs = llvm.link_jobs;
338341
}
339342

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

src/bootstrap/config.toml.example

Lines changed: 8 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ pub fn llvm(build: &Build, target: &str) {
115115
cfg.define("LLVM_BUILD_32_BITS", "ON");
116116
}
117117

118+
if let Some(num_linkers) = build.config.llvm_link_jobs {
119+
if num_linkers > 0 {
120+
cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string());
121+
}
122+
}
123+
118124
// http://llvm.org/docs/HowToCrossCompileLLVM.html
119125
if target != build.config.build {
120126
// FIXME: if the llvm root for the build triple is overridden then we

0 commit comments

Comments
 (0)