Skip to content

Commit

Permalink
Skip LTO in stage0 (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Dec 28, 2022
1 parent fbe0450 commit cc4e434
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit cc4e434

Please sign in to comment.