|
1 | 1 | use std::path::PathBuf;
|
2 | 2 | use std::{env, fs};
|
3 | 3 |
|
| 4 | +use self::builder::cargo_profile_var; |
4 | 5 | use crate::core::build_steps::toolstate::ToolState;
|
5 | 6 | use crate::core::build_steps::{compile, llvm};
|
6 | 7 | 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}; |
10 | 9 | use crate::core::config::{DebuginfoLevel, RustcLto, TargetSelection};
|
11 | 10 | use crate::utils::channel::GitInfo;
|
12 | 11 | use crate::utils::exec::{BootstrapCommand, command};
|
@@ -101,10 +100,27 @@ impl Step for ToolBuild {
|
101 | 100 | self.source_type,
|
102 | 101 | &self.extra_features,
|
103 | 102 | );
|
| 103 | + |
104 | 104 | if !self.allow_features.is_empty() {
|
105 | 105 | cargo.allow_features(self.allow_features);
|
106 | 106 | }
|
| 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 | + |
107 | 122 | cargo.args(self.cargo_args);
|
| 123 | + |
108 | 124 | let _guard = builder.msg_tool(
|
109 | 125 | Kind::Build,
|
110 | 126 | self.mode,
|
|
0 commit comments