From f5eb5c884f8a4bd67879c85ad76782967ab7f36a Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 4 Mar 2021 17:19:41 -0500 Subject: [PATCH 1/2] Make rustc shim's verbose output include crate_name being compiled. This change is mainly motivated by an issue with the environment printing I added in PR 82403: multiple rustc invocations progress in parallel, and the environment output, spanning multiple lines, gets interleaved in ways make it difficult to extra the enviroment settings. (This aforementioned difficulty is more of a hiccup than an outright show-stopper, because the environment variables tend to be the same for all of the rustc invocations, so it doesn't matter too much if one mixes up which lines one is looking at. But still: Better to fix it.) --- src/bootstrap/bin/rustc.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 6b1be0ca09d0d..1bd36e25c0204 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -141,18 +141,23 @@ fn main() { if verbose > 1 { let rust_env_vars = env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO")); + let prefix = match crate_name { + Some(crate_name) => format!("rustc {}", crate_name), + None => "rustc".to_string(), + }; for (i, (k, v)) in rust_env_vars.enumerate() { - eprintln!("rustc env[{}]: {:?}={:?}", i, k, v); + eprintln!("{} env[{}]: {:?}={:?}", prefix, i, k, v); } - eprintln!("rustc working directory: {}", env::current_dir().unwrap().display()); + eprintln!("{} working directory: {}", prefix, env::current_dir().unwrap().display()); eprintln!( - "rustc command: {:?}={:?} {:?}", + "{} command: {:?}={:?} {:?}", + prefix, bootstrap::util::dylib_path_var(), env::join_paths(&dylib_path).unwrap(), cmd, ); - eprintln!("sysroot: {:?}", sysroot); - eprintln!("libdir: {:?}", libdir); + eprintln!("{} sysroot: {:?}", prefix, sysroot); + eprintln!("{} libdir: {:?}", prefix, libdir); } let start = Instant::now(); From 444a7567693506347a3ce9e79f6823abf7141b17 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 5 Mar 2021 11:46:04 -0500 Subject: [PATCH 2/2] Revise prefix a bit, adding both `--test` (conditionally) and `[RUSTC-SHIM]` unconditionally. 1. I added `--test` based on review feedback from simulacrum: I decided I would rather include such extra context than get confused later on by its absence. (However, I chose to encode it differently than how `[RUSTC-TIMING]` does... I don't have much basis for doing so, other than `--test` to me more directly reflects what it came from.) 2. I also decided to include `[RUSTC-SHIM]` at start of all of these lines driven by the verbosity level, to make to clear where these lines of text originate from. (Basically, I skimmed over the output and realized that a casual observer might not be able to tell where this huge set of new lines were coming from.) --- src/bootstrap/bin/rustc.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 1bd36e25c0204..0ab5e9c63c94f 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -138,12 +138,14 @@ fn main() { cmd.arg("-Z").arg("force-unstable-if-unmarked"); } + let is_test = args.iter().any(|a| a == "--test"); if verbose > 1 { let rust_env_vars = env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO")); + let prefix = if is_test { "[RUSTC-SHIM] rustc --test" } else { "[RUSTC-SHIM] rustc" }; let prefix = match crate_name { - Some(crate_name) => format!("rustc {}", crate_name), - None => "rustc".to_string(), + Some(crate_name) => format!("{} {}", prefix, crate_name), + None => prefix.to_string(), }; for (i, (k, v)) in rust_env_vars.enumerate() { eprintln!("{} env[{}]: {:?}={:?}", prefix, i, k, v); @@ -171,7 +173,6 @@ fn main() { { if let Some(crate_name) = crate_name { let dur = start.elapsed(); - let is_test = args.iter().any(|a| a == "--test"); // If the user requested resource usage data, then // include that in addition to the timing output. let rusage_data =