Skip to content

Commit 046385b

Browse files
committed
Only apply LTO to rustdoc at stage 2
It doesn't make much sense at stage 1, and it was broken anyway.
1 parent 820bfff commit 046385b

File tree

1 file changed

+13
-8
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+13
-8
lines changed

Diff for: src/bootstrap/src/core/build_steps/tool.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -660,14 +660,19 @@ impl Step for Rustdoc {
660660
);
661661

662662
// rustdoc is performance sensitive, so apply LTO to it.
663-
let lto = match builder.config.rust_lto {
664-
RustcLto::Off => Some("off"),
665-
RustcLto::Thin => Some("thin"),
666-
RustcLto::Fat => Some("fat"),
667-
RustcLto::ThinLocal => None,
668-
};
669-
if let Some(lto) = lto {
670-
cargo.env(cargo_profile_var("LTO", &builder.config), lto);
663+
// The compiler shared libraries (librustc_driver.so) don't use LTO on stages
664+
// lower than stage 1, as it's not worth it.
665+
// So we also need to only do this at stage 2+, to avoid missing LTO bitcode errors.
666+
if build_compiler.stage != 0 {
667+
let lto = match builder.config.rust_lto {
668+
RustcLto::Off => Some("off"),
669+
RustcLto::Thin => Some("thin"),
670+
RustcLto::Fat => Some("fat"),
671+
RustcLto::ThinLocal => None,
672+
};
673+
if let Some(lto) = lto {
674+
cargo.env(cargo_profile_var("LTO", &builder.config), lto);
675+
}
671676
}
672677

673678
let _guard = builder.msg_tool(

0 commit comments

Comments
 (0)