]> git.lizzy.rs Git - rust.git/commitdiff
Skip LTO in stage0 (again)
authorMark Rousskov <mark.simulacrum@gmail.com>
Wed, 28 Dec 2022 20:28:09 +0000 (15:28 -0500)
committerMark Rousskov <mark.simulacrum@gmail.com>
Wed, 28 Dec 2022 20:29:21 +0000 (15:29 -0500)
src/bootstrap/compile.rs

index ae5dfdea19f289a8e386a7e2d37390a9067dc1d0..1030247b890c36c742428e10e4465a1bfc1f259a 100644 (file)
@@ -691,23 +691,27 @@ fn run(self, builder: &Builder<'_>) {
             ));
         }
 
-        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!(