Skip to content

Commit 7c404ce

Browse files
authored
Rollup merge of #67450 - michaelwoerister:bootstrap-import-limit, r=Mark-Simulacrum
Allow for setting a ThinLTO import limit during bootstrap The benchmarks in #66625 have shown that a lower ThinLTO import limit can be a net win for bootstrap times. This PR: - exposes the setting to `config.toml`, - defaults to a lower limit if `incremental = true` in `config.toml`, and - sets a lower limit for `x86_64-gnu-llvm-7` CI image in order to make the jobs complete more quickly (which remains to be tested). This setting will affect how the compiler and it's tools are compiled. It will not affect the settings the compiler uses when compiling user code. r? @pietroalbini cc @rust-lang/infra
2 parents 0a58f58 + 6f57bad commit 7c404ce

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
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 {

src/ci/docker/x86_64-gnu-llvm-7/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ RUN sh /scripts/sccache.sh
2525
ENV RUST_CONFIGURE_ARGS \
2626
--build=x86_64-unknown-linux-gnu \
2727
--llvm-root=/usr/lib/llvm-7 \
28-
--enable-llvm-link-shared
28+
--enable-llvm-link-shared \
29+
--set rust.thin-lto-import-instr-limit=10
30+
2931
ENV SCRIPT python2.7 ../x.py test src/tools/tidy && python2.7 ../x.py test
3032

3133
# The purpose of this container isn't to test with debug assertions and

0 commit comments

Comments
 (0)