Skip to content

Commit cc4e434

Browse files
Skip LTO in stage0 (again)
1 parent fbe0450 commit cc4e434

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/bootstrap/compile.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -691,23 +691,27 @@ impl Step for Rustc {
691691
));
692692
}
693693

694-
match builder.config.rust_lto {
695-
RustcLto::Thin | RustcLto::Fat => {
696-
// Since using LTO for optimizing dylibs is currently experimental,
697-
// we need to pass -Zdylib-lto.
698-
cargo.rustflag("-Zdylib-lto");
699-
// Cargo by default passes `-Cembed-bitcode=no` and doesn't pass `-Clto` when
700-
// compiling dylibs (and their dependencies), even when LTO is enabled for the
701-
// crate. Therefore, we need to override `-Clto` and `-Cembed-bitcode` here.
702-
let lto_type = match builder.config.rust_lto {
703-
RustcLto::Thin => "thin",
704-
RustcLto::Fat => "fat",
705-
_ => unreachable!(),
706-
};
707-
cargo.rustflag(&format!("-Clto={}", lto_type));
708-
cargo.rustflag("-Cembed-bitcode=yes");
694+
// We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
695+
// and may just be a time sink.
696+
if compiler.stage != 0 {
697+
match builder.config.rust_lto {
698+
RustcLto::Thin | RustcLto::Fat => {
699+
// Since using LTO for optimizing dylibs is currently experimental,
700+
// we need to pass -Zdylib-lto.
701+
cargo.rustflag("-Zdylib-lto");
702+
// Cargo by default passes `-Cembed-bitcode=no` and doesn't pass `-Clto` when
703+
// compiling dylibs (and their dependencies), even when LTO is enabled for the
704+
// crate. Therefore, we need to override `-Clto` and `-Cembed-bitcode` here.
705+
let lto_type = match builder.config.rust_lto {
706+
RustcLto::Thin => "thin",
707+
RustcLto::Fat => "fat",
708+
_ => unreachable!(),
709+
};
710+
cargo.rustflag(&format!("-Clto={}", lto_type));
711+
cargo.rustflag("-Cembed-bitcode=yes");
712+
}
713+
RustcLto::ThinLocal => { /* Do nothing, this is the default */ }
709714
}
710-
RustcLto::ThinLocal => { /* Do nothing, this is the default */ }
711715
}
712716

713717
builder.info(&format!(

0 commit comments

Comments
 (0)