Skip to content

Commit

Permalink
Add a RUSTC_TIME env var to time rust crates during bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Jun 12, 2019
1 parent 55cee44 commit a0c7984
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/bootstrap/bin/rustc.rs
Expand Up @@ -93,6 +93,21 @@ fn main() {
env::join_paths(&dylib_path).unwrap());
let mut maybe_crate = None;

// Get the name of the crate we're compiling, if any.
let maybe_crate_name = args.windows(2)
.find(|a| &*a[0] == "--crate-name")
.map(|crate_name| &*crate_name[1]);

if let Some(current_crate) = maybe_crate_name {
if let Some(target) = env::var_os("RUSTC_TIME") {
if target == "all" ||
target.into_string().unwrap().split(",").any(|c| c.trim() == current_crate)
{
cmd.arg("-Ztime");
}
}
}

// Non-zero stages must all be treated uniformly to avoid problems when attempting to uplift
// compiler libraries and such from stage 1 to 2.
if stage == "0" {
Expand Down Expand Up @@ -152,10 +167,7 @@ fn main() {
cmd.arg(format!("-Clinker={}", target_linker));
}

let crate_name = args.windows(2)
.find(|a| &*a[0] == "--crate-name")
.unwrap();
let crate_name = &*crate_name[1];
let crate_name = maybe_crate_name.unwrap();
maybe_crate = Some(crate_name);

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

0 comments on commit a0c7984

Please sign in to comment.