]> git.lizzy.rs Git - rust.git/commitdiff
Add `rust.lto=off` to bootstrap
authorclubby789 <jamie@hill-daniel.co.uk>
Mon, 23 Jan 2023 21:21:35 +0000 (21:21 +0000)
committerclubby789 <jamie@hill-daniel.co.uk>
Thu, 26 Jan 2023 12:24:48 +0000 (12:24 +0000)
config.toml.example
src/bootstrap/compile.rs
src/bootstrap/config.rs
src/bootstrap/defaults/config.compiler.toml
src/bootstrap/defaults/config.library.toml

index 5e1d2f2e314ff904173d04c224797cd2b017b5f2..e0f02eac9c34b774c898ac3b2f1f8c8dcaf741d3 100644 (file)
@@ -646,7 +646,8 @@ changelog-seen = 2
 
 # Select LTO mode that will be used for compiling rustc. By default, thin local LTO
 # (LTO within a single crate) is used (like for any Rust crate). You can also select
-# "thin" or "fat" to apply Thin/Fat LTO to the `rustc_driver` dylib.
+# "thin" or "fat" to apply Thin/Fat LTO to the `rustc_driver` dylib, or "off" to disable
+# LTO entirely.
 #lto = "thin-local"
 
 # =============================================================================
index 68d1db0160a2e7cd0872fd56dd6003245f9acc7d..07c0d2233caeb29f8a74d03a5963e25dafdcc8c0 100644 (file)
@@ -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 @@ fn run(self, builder: &Builder<'_>) {
                     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");
             }
         }
 
index b41d60d51a8b5972f75ea63e518d68e461f7df0e..a28fe612deb7a7043676d2a0b8e80aeab44d134b 100644 (file)
@@ -332,8 +332,9 @@ fn default_for_platform(target: &str) -> Self {
 }
 
 /// LTO mode used for compiling rustc itself.
-#[derive(Default, Clone)]
+#[derive(Default, Clone, PartialEq)]
 pub enum RustcLto {
+    Off,
     #[default]
     ThinLocal,
     Thin,
@@ -348,6 +349,7 @@ fn from_str(s: &str) -> Result<Self, Self::Err> {
             "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)),
         }
     }
index 2f4ccb825c4d8738199976676b69195e5345a445..b98b13119e8ad56b8c44c73ba4c5e26020ebff20 100644 (file)
@@ -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.
index 7bc054d3a49fc97a4be9c0fced37855268f1728a..f362c4111f107f99c8d6ee14b2dd559d4e11a6a0 100644 (file)
@@ -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.