about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-02-03 01:19:04 +0000
committerbors <bors@rust-lang.org>2023-02-03 01:19:04 +0000
commitf02439dea78e5c2df42198c7a03e2db6002ff263 (patch)
treeba934c044e040c794ecaf64c5d0ddea604210a5c /src
parent6c991b07403a3234dd1ec0ac973b8ef97055e605 (diff)
parent2adf26fc72f354aabd65da176eb9f8806b0d2ef2 (diff)
downloadrust-f02439dea78e5c2df42198c7a03e2db6002ff263.tar.gz
rust-f02439dea78e5c2df42198c7a03e2db6002ff263.zip
Auto merge of #107241 - clubby789:bootstrap-lto-off, r=simulacrum
Add `rust.lto=off` to bootstrap and set as compiler/library default

Closes #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
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/compile.rs10
-rw-r--r--src/bootstrap/config.rs4
-rw-r--r--src/bootstrap/defaults/config.compiler.toml2
-rw-r--r--src/bootstrap/defaults/config.library.toml2
4 files changed, 17 insertions, 1 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 68d1db0160a..07c0d2233ca 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -379,6 +379,9 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
     if stage >= 1 {
         cargo.rustflag("-Cembed-bitcode=yes");
     }
+    if builder.config.rust_lto == RustcLto::Off {
+        cargo.rustflag("-Clto=off");
+    }
 
     // By default, rustc does not include unwind tables unless they are required
     // for a particular target. They are not required by RISC-V targets, but
@@ -722,6 +725,13 @@ impl Step for Rustc {
                     cargo.rustflag("-Cembed-bitcode=yes");
                 }
                 RustcLto::ThinLocal => { /* Do nothing, this is the default */ }
+                RustcLto::Off => {
+                    cargo.rustflag("-Clto=off");
+                }
+            }
+        } else {
+            if builder.config.rust_lto == RustcLto::Off {
+                cargo.rustflag("-Clto=off");
             }
         }
 
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 165502b0a41..e5fad538969 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -333,8 +333,9 @@ impl SplitDebuginfo {
 }
 
 /// LTO mode used for compiling rustc itself.
-#[derive(Default, Clone)]
+#[derive(Default, Clone, PartialEq)]
 pub enum RustcLto {
+    Off,
     #[default]
     ThinLocal,
     Thin,
@@ -349,6 +350,7 @@ impl std::str::FromStr for RustcLto {
             "thin-local" => Ok(RustcLto::ThinLocal),
             "thin" => Ok(RustcLto::Thin),
             "fat" => Ok(RustcLto::Fat),
+            "off" => Ok(RustcLto::Off),
             _ => Err(format!("Invalid value for rustc LTO: {}", s)),
         }
     }
diff --git a/src/bootstrap/defaults/config.compiler.toml b/src/bootstrap/defaults/config.compiler.toml
index 2f4ccb825c4..b98b13119e8 100644
--- a/src/bootstrap/defaults/config.compiler.toml
+++ b/src/bootstrap/defaults/config.compiler.toml
@@ -12,6 +12,8 @@ debug-logging = true
 incremental = true
 # Print backtrace on internal compiler errors during bootstrap
 backtrace-on-ice = true
+# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
+lto = "off"
 
 [llvm]
 # Will download LLVM from CI if available on your platform.
diff --git a/src/bootstrap/defaults/config.library.toml b/src/bootstrap/defaults/config.library.toml
index 7bc054d3a49..f362c4111f1 100644
--- a/src/bootstrap/defaults/config.library.toml
+++ b/src/bootstrap/defaults/config.library.toml
@@ -8,6 +8,8 @@ bench-stage = 0
 [rust]
 # This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
 incremental = true
+# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
+lto = "off"
 
 [llvm]
 # Will download LLVM from CI if available on your platform.