From a0c7984fb97b6864352028b848c3240ae5b3554e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 16 Feb 2019 08:57:43 +0100 Subject: [PATCH] Add a RUSTC_TIME env var to time rust crates during bootstrap --- src/bootstrap/bin/rustc.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index f5fb6f0b4d008..595deb07ec82b 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -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" { @@ -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