Skip to content

Commit 08159e9

Browse files
Disable ThinLTO for dist builds.
Dist builds should always be as fast as we can make them, and since those run on CI we don't care quite as much for the build being somewhat slower. As such, we don't automatically enable ThinLTO on builds for the dist builders.
1 parent 616b66d commit 08159e9

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

config.toml.example

+5
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@
235235
# compiler.
236236
#codegen-units = 1
237237

238+
# Whether to enable ThinLTO (and increase the codegen units to either a default
239+
# or the configured value). On by default. If we want the fastest possible
240+
# compiler, we should disable this.
241+
#thinlto = true
242+
238243
# Whether or not debug assertions are enabled for the compiler and standard
239244
# library. Also enables compilation of debug! and trace! logging macros.
240245
#debug-assertions = false

src/bootstrap/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ impl<'a> Builder<'a> {
686686
}
687687

688688
if self.config.rust_codegen_units.is_none() &&
689-
self.build.is_rust_llvm(compiler.host)
690-
{
689+
self.build.is_rust_llvm(compiler.host) &&
690+
self.config.rust_thinlto {
691691
cargo.env("RUSTC_THINLTO", "1");
692692
}
693693
}

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub struct Config {
8181
// rust codegen options
8282
pub rust_optimize: bool,
8383
pub rust_codegen_units: Option<u32>,
84+
pub rust_thinlto: bool,
8485
pub rust_debug_assertions: bool,
8586
pub rust_debuginfo: bool,
8687
pub rust_debuginfo_lines: bool,
@@ -261,6 +262,7 @@ impl Default for StringOrBool {
261262
struct Rust {
262263
optimize: Option<bool>,
263264
codegen_units: Option<u32>,
265+
thinlto: Option<bool>,
264266
debug_assertions: Option<bool>,
265267
debuginfo: Option<bool>,
266268
debuginfo_lines: Option<bool>,
@@ -466,6 +468,7 @@ impl Config {
466468
set(&mut config.quiet_tests, rust.quiet_tests);
467469
set(&mut config.test_miri, rust.test_miri);
468470
set(&mut config.wasm_syscall, rust.wasm_syscall);
471+
config.rust_thinlto = rust.thinlto.unwrap_or(true);
469472
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
470473
config.rustc_default_linker = rust.default_linker.clone();
471474
config.musl_root = rust.musl_root.clone().map(PathBuf::from);

src/bootstrap/configure.py

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def v(*args):
7070
# Optimization and debugging options. These may be overridden by the release
7171
# channel, etc.
7272
o("optimize", "rust.optimize", "build optimized rust code")
73+
o("thinlto", "rust.thinlto", "build Rust with ThinLTO enabled")
7374
o("optimize-llvm", "llvm.optimize", "build optimized LLVM")
7475
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
7576
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions")

src/ci/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export RUST_RELEASE_CHANNEL=nightly
4646
if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
4747
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
4848
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
49+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-thinlto"
4950

5051
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
5152
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"

0 commit comments

Comments
 (0)