Skip to content

Commit 2adf26f

Browse files
committed
Add rust.lto=off to bootstrap
1 parent 5e37043 commit 2adf26f

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
@@ -646,7 +646,8 @@ changelog-seen = 2
646646

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

652653
# =============================================================================

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
@@ -332,8 +332,9 @@ impl SplitDebuginfo {
332332
}
333333

334334
/// LTO mode used for compiling rustc itself.
335-
#[derive(Default, Clone)]
335+
#[derive(Default, Clone, PartialEq)]
336336
pub enum RustcLto {
337+
Off,
337338
#[default]
338339
ThinLocal,
339340
Thin,
@@ -348,6 +349,7 @@ impl std::str::FromStr for RustcLto {
348349
"thin-local" => Ok(RustcLto::ThinLocal),
349350
"thin" => Ok(RustcLto::Thin),
350351
"fat" => Ok(RustcLto::Fat),
352+
"off" => Ok(RustcLto::Off),
351353
_ => Err(format!("Invalid value for rustc LTO: {}", s)),
352354
}
353355
}

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)