From c718aeffc4ce244363a1dc61287d33e881a163e0 Mon Sep 17 00:00:00 2001 From: khyperia <953151+khyperia@users.noreply.github.com> Date: Sat, 13 Aug 2022 14:08:29 +0200 Subject: [PATCH] Add RUSTC_STAGE env var to ./x.py clippy invocation --- src/bootstrap/builder.rs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0ab4824ac0a73..50eba50ee6ef6 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1426,20 +1426,30 @@ impl<'a> Builder<'a> { // Only run clippy on a very limited subset of crates (in particular, not build scripts). cargo.arg("-Zunstable-options"); // Explicitly does *not* set `--cfg=bootstrap`, since we're using a nightly clippy. - let host_version = Command::new("rustc").arg("--version").output().map_err(|_| ()); - let output = host_version.and_then(|output| { - if output.status.success() { - Ok(output) - } else { - Err(()) - } - }).unwrap_or_else(|_| { + let output = Command::new("rustc") + .arg("--version") + .env("RUSTC_STAGE", stage.to_string()) + .output(); + let output = output.unwrap_or_else(|err| { eprintln!( - "error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component" + "error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component (could not execute rustc: {})", + err ); eprintln!("help: try `rustup component add clippy`"); crate::detail_exit(1); }); + if !output.status.success() { + if let Some(code) = output.status.code() { + eprintln!("rustc exited with code {code}"); + } + if !output.stdout.is_empty() { + eprintln!("stdout: {}", String::from_utf8_lossy(&output.stdout)); + } + if !output.stderr.is_empty() { + eprintln!("stderr: {}", String::from_utf8_lossy(&output.stderr)); + } + crate::detail_exit(1); + } if !t!(std::str::from_utf8(&output.stdout)).contains("nightly") { rustflags.arg("--cfg=bootstrap"); }