Skip to content

Commit a0c7984

Browse files
committed
Add a RUSTC_TIME env var to time rust crates during bootstrap
1 parent 55cee44 commit a0c7984

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/bootstrap/bin/rustc.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ fn main() {
9393
env::join_paths(&dylib_path).unwrap());
9494
let mut maybe_crate = None;
9595

96+
// Get the name of the crate we're compiling, if any.
97+
let maybe_crate_name = args.windows(2)
98+
.find(|a| &*a[0] == "--crate-name")
99+
.map(|crate_name| &*crate_name[1]);
100+
101+
if let Some(current_crate) = maybe_crate_name {
102+
if let Some(target) = env::var_os("RUSTC_TIME") {
103+
if target == "all" ||
104+
target.into_string().unwrap().split(",").any(|c| c.trim() == current_crate)
105+
{
106+
cmd.arg("-Ztime");
107+
}
108+
}
109+
}
110+
96111
// Non-zero stages must all be treated uniformly to avoid problems when attempting to uplift
97112
// compiler libraries and such from stage 1 to 2.
98113
if stage == "0" {
@@ -152,10 +167,7 @@ fn main() {
152167
cmd.arg(format!("-Clinker={}", target_linker));
153168
}
154169

155-
let crate_name = args.windows(2)
156-
.find(|a| &*a[0] == "--crate-name")
157-
.unwrap();
158-
let crate_name = &*crate_name[1];
170+
let crate_name = maybe_crate_name.unwrap();
159171
maybe_crate = Some(crate_name);
160172

161173
// If we're compiling specifically the `panic_abort` crate then we pass

0 commit comments

Comments
 (0)