about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2022-12-28 15:28:09 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2022-12-28 15:29:21 -0500
commitcc4e434854a982e22ca207c298e63f88dc5128aa (patch)
treeee77275fb7ec6b4c4bb65c00949ae6f1feffccb2
parentfbe04502515c0ddadef8a6770fe9c5056caa16e1 (diff)
downloadrust-cc4e434854a982e22ca207c298e63f88dc5128aa.tar.gz
rust-cc4e434854a982e22ca207c298e63f88dc5128aa.zip
Skip LTO in stage0 (again)
-rw-r--r--src/bootstrap/compile.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index ae5dfdea19f..1030247b890 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -691,23 +691,27 @@ impl Step for Rustc {
             ));
         }
 
-        match builder.config.rust_lto {
-            RustcLto::Thin | RustcLto::Fat => {
-                // Since using LTO for optimizing dylibs is currently experimental,
-                // we need to pass -Zdylib-lto.
-                cargo.rustflag("-Zdylib-lto");
-                // Cargo by default passes `-Cembed-bitcode=no` and doesn't pass `-Clto` when
-                // compiling dylibs (and their dependencies), even when LTO is enabled for the
-                // crate. Therefore, we need to override `-Clto` and `-Cembed-bitcode` here.
-                let lto_type = match builder.config.rust_lto {
-                    RustcLto::Thin => "thin",
-                    RustcLto::Fat => "fat",
-                    _ => unreachable!(),
-                };
-                cargo.rustflag(&format!("-Clto={}", lto_type));
-                cargo.rustflag("-Cembed-bitcode=yes");
+        // We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
+        // and may just be a time sink.
+        if compiler.stage != 0 {
+            match builder.config.rust_lto {
+                RustcLto::Thin | RustcLto::Fat => {
+                    // Since using LTO for optimizing dylibs is currently experimental,
+                    // we need to pass -Zdylib-lto.
+                    cargo.rustflag("-Zdylib-lto");
+                    // Cargo by default passes `-Cembed-bitcode=no` and doesn't pass `-Clto` when
+                    // compiling dylibs (and their dependencies), even when LTO is enabled for the
+                    // crate. Therefore, we need to override `-Clto` and `-Cembed-bitcode` here.
+                    let lto_type = match builder.config.rust_lto {
+                        RustcLto::Thin => "thin",
+                        RustcLto::Fat => "fat",
+                        _ => unreachable!(),
+                    };
+                    cargo.rustflag(&format!("-Clto={}", lto_type));
+                    cargo.rustflag("-Cembed-bitcode=yes");
+                }
+                RustcLto::ThinLocal => { /* Do nothing, this is the default */ }
             }
-            RustcLto::ThinLocal => { /* Do nothing, this is the default */ }
         }
 
         builder.info(&format!(