Skip to content

Commit 01d7711

Browse files
committed
apply rustdoc lto in ToolBuild
Signed-off-by: onur-ozkan <[email protected]>
1 parent 4ddb1ac commit 01d7711

File tree

1 file changed

+19
-3
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+19
-3
lines changed

src/bootstrap/src/core/build_steps/tool.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::path::PathBuf;
22
use std::{env, fs};
33

4+
use self::builder::cargo_profile_var;
45
use crate::core::build_steps::toolstate::ToolState;
56
use crate::core::build_steps::{compile, llvm};
67
use crate::core::builder;
7-
use crate::core::builder::{
8-
Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step, cargo_profile_var,
9-
};
8+
use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
109
use crate::core::config::{DebuginfoLevel, RustcLto, TargetSelection};
1110
use crate::utils::channel::GitInfo;
1211
use crate::utils::exec::{BootstrapCommand, command};
@@ -101,10 +100,27 @@ impl Step for ToolBuild {
101100
self.source_type,
102101
&self.extra_features,
103102
);
103+
104104
if !self.allow_features.is_empty() {
105105
cargo.allow_features(self.allow_features);
106106
}
107+
108+
if self.path.ends_with("/rustdoc") {
109+
// rustdoc is performance sensitive, so apply LTO to it.
110+
let lto = match builder.config.rust_lto {
111+
RustcLto::Off => Some("off"),
112+
RustcLto::Thin => Some("thin"),
113+
RustcLto::Fat => Some("fat"),
114+
RustcLto::ThinLocal => None,
115+
};
116+
117+
if let Some(lto) = lto {
118+
cargo.env(cargo_profile_var("LTO", &builder.config), lto);
119+
}
120+
}
121+
107122
cargo.args(self.cargo_args);
123+
108124
let _guard = builder.msg_tool(
109125
Kind::Build,
110126
self.mode,

0 commit comments

Comments
 (0)