Skip to content

Commit d2192a1

Browse files
committed
Auto merge of #47834 - Mark-Simulacrum:no-cgu-release, r=<try>
Do not enable ThinLTO on stable, beta, or nightly builds. Developers testing locally (-dev profile) may want faster builds for slightly slower compilers (~5%) whereas 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 stable, beta, or nightly channels. Fixes #45444
2 parents 616b66d + bbb9860 commit d2192a1

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

config.toml.example

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

Lines changed: 2 additions & 2 deletions
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.enable_thinlto {
691691
cargo.env("RUSTC_THINLTO", "1");
692692
}
693693
}

src/bootstrap/config.rs

Lines changed: 2 additions & 0 deletions
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,
@@ -466,6 +467,7 @@ impl Config {
466467
set(&mut config.quiet_tests, rust.quiet_tests);
467468
set(&mut config.test_miri, rust.test_miri);
468469
set(&mut config.wasm_syscall, rust.wasm_syscall);
470+
config.rust_thinlto = rust_thinlto.unwrap_or(true);
469471
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
470472
config.rustc_default_linker = rust.default_linker.clone();
471473
config.musl_root = rust.musl_root.clone().map(PathBuf::from);

src/bootstrap/configure.py

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)