Skip to content

Commit 1b7c404

Browse files
bootstrap: Allow for setting the ThinLTO import limit used for compiler the compiler.
1 parent 766fba3 commit 1b7c404

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

config.toml.example

+7
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@
406406
# Whether to verify generated LLVM IR
407407
#verify-llvm-ir = false
408408

409+
# Compile the compiler with a non-default ThinLTO import limit. This import
410+
# limit controls the maximum size of functions imported by ThinLTO. Decreasing
411+
# will make code compile faster at the expense of lower runtime performance.
412+
# If `incremental` is set to true above, the import limit will default to 10
413+
# instead of LLVM's default of 100.
414+
#thin-lto-import-instr-limit = 100
415+
409416
# Map all debuginfo paths for libstd and crates to `/rust/$sha/$crate/...`,
410417
# generally only set for releases
411418
#remap-debuginfo = false

src/bootstrap/builder.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,21 @@ impl<'a> Builder<'a> {
11831183
rustflags.arg("-Cprefer-dynamic");
11841184
}
11851185

1186+
// When building incrementally we default to a lower ThinLTO import limit
1187+
// (unless explicitly specified otherwise). This will produce a somewhat
1188+
// slower code but give way better compile times.
1189+
{
1190+
let limit = match self.config.rust_thin_lto_import_instr_limit {
1191+
Some(limit) => Some(limit),
1192+
None if self.config.incremental => Some(10),
1193+
_ => None,
1194+
};
1195+
1196+
if let Some(limit) = limit {
1197+
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit));
1198+
}
1199+
}
1200+
11861201
Cargo { command: cargo, rustflags }
11871202
}
11881203

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub struct Config {
108108
pub rust_dist_src: bool,
109109
pub rust_codegen_backends: Vec<Interned<String>>,
110110
pub rust_verify_llvm_ir: bool,
111+
pub rust_thin_lto_import_instr_limit: Option<u32>,
111112
pub rust_remap_debuginfo: bool,
112113

113114
pub build: Interned<String>,
@@ -325,6 +326,7 @@ struct Rust {
325326
deny_warnings: Option<bool>,
326327
backtrace_on_ice: Option<bool>,
327328
verify_llvm_ir: Option<bool>,
329+
thin_lto_import_instr_limit: Option<u32>,
328330
remap_debuginfo: Option<bool>,
329331
jemalloc: Option<bool>,
330332
test_compare_mode: Option<bool>,
@@ -569,6 +571,7 @@ impl Config {
569571
set(&mut config.deny_warnings, flags.deny_warnings.or(rust.deny_warnings));
570572
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
571573
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
574+
config.rust_thin_lto_import_instr_limit = rust.thin_lto_import_instr_limit;
572575
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
573576

574577
if let Some(ref backends) = rust.codegen_backends {

0 commit comments

Comments
 (0)