Skip to content

Commit f02439d

Browse files
committed
Auto merge of rust-lang#107241 - clubby789:bootstrap-lto-off, r=simulacrum
Add `rust.lto=off` to bootstrap and set as compiler/library default Closes rust-lang#107202 The issue mentions `embed-bitcode=on`, but here https://github.com/rust-lang/rust/blob/c8e6a9e8b6251bbc8276cb78cabe1998deecbed7/src/bootstrap/compile.rs#L379-L381 it appears that this is always set for std stage 1+, so I'm unsure if changes are needed here. `@rustbot` label +A-bootstrap
2 parents 6c991b0 + 2adf26f commit f02439d

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

config.toml.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,8 @@ changelog-seen = 2
662662

663663
# Select LTO mode that will be used for compiling rustc. By default, thin local LTO
664664
# (LTO within a single crate) is used (like for any Rust crate). You can also select
665-
# "thin" or "fat" to apply Thin/Fat LTO to the `rustc_driver` dylib.
665+
# "thin" or "fat" to apply Thin/Fat LTO to the `rustc_driver` dylib, or "off" to disable
666+
# LTO entirely.
666667
#lto = "thin-local"
667668

668669
# =============================================================================

src/bootstrap/compile.rs

+10
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
379379
if stage >= 1 {
380380
cargo.rustflag("-Cembed-bitcode=yes");
381381
}
382+
if builder.config.rust_lto == RustcLto::Off {
383+
cargo.rustflag("-Clto=off");
384+
}
382385

383386
// By default, rustc does not include unwind tables unless they are required
384387
// for a particular target. They are not required by RISC-V targets, but
@@ -722,6 +725,13 @@ impl Step for Rustc {
722725
cargo.rustflag("-Cembed-bitcode=yes");
723726
}
724727
RustcLto::ThinLocal => { /* Do nothing, this is the default */ }
728+
RustcLto::Off => {
729+
cargo.rustflag("-Clto=off");
730+
}
731+
}
732+
} else {
733+
if builder.config.rust_lto == RustcLto::Off {
734+
cargo.rustflag("-Clto=off");
725735
}
726736
}
727737

src/bootstrap/config.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ impl SplitDebuginfo {
333333
}
334334

335335
/// LTO mode used for compiling rustc itself.
336-
#[derive(Default, Clone)]
336+
#[derive(Default, Clone, PartialEq)]
337337
pub enum RustcLto {
338+
Off,
338339
#[default]
339340
ThinLocal,
340341
Thin,
@@ -349,6 +350,7 @@ impl std::str::FromStr for RustcLto {
349350
"thin-local" => Ok(RustcLto::ThinLocal),
350351
"thin" => Ok(RustcLto::Thin),
351352
"fat" => Ok(RustcLto::Fat),
353+
"off" => Ok(RustcLto::Off),
352354
_ => Err(format!("Invalid value for rustc LTO: {}", s)),
353355
}
354356
}

src/bootstrap/defaults/config.compiler.toml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ debug-logging = true
1212
incremental = true
1313
# Print backtrace on internal compiler errors during bootstrap
1414
backtrace-on-ice = true
15+
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
16+
lto = "off"
1517

1618
[llvm]
1719
# Will download LLVM from CI if available on your platform.

src/bootstrap/defaults/config.library.toml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ bench-stage = 0
88
[rust]
99
# This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
1010
incremental = true
11+
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
12+
lto = "off"
1113

1214
[llvm]
1315
# Will download LLVM from CI if available on your platform.

0 commit comments

Comments
 (0)