From 946ee4f515a79303a39633a38d24ab1c17d5cedb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 13 Jul 2024 14:23:54 +0200 Subject: [PATCH] bootstrap: fully rely on RUSTC_WRAPPER --- src/bootstrap/src/bin/rustc.rs | 13 ++++--------- src/bootstrap/src/core/builder.rs | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index d04e2fbeb7853..4ce2f5f2d17df 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -16,7 +16,7 @@ //! never get replaced. use std::env; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::process::{Child, Command}; use std::time::Instant; @@ -75,17 +75,12 @@ fn main() { args.drain(..2); rustc_real } else { + // The first param is the clippy-driver we should call. args.remove(0) } } else { - // Cargo doesn't respect RUSTC_WRAPPER for version information >:( - // don't remove the first arg if we're being run as RUSTC instead of RUSTC_WRAPPER. - // Cargo also sometimes doesn't pass the `.exe` suffix on Windows - add it manually. - let current_exe = env::current_exe().expect("couldn't get path to rustc shim"); - let arg0 = exe(args[0].to_str().expect("only utf8 paths are supported"), &host); - if Path::new(&arg0) == current_exe { - args.remove(0); - } + // We are RUSTC_WRAPPER; remove the dummy rustc invocation we wrap. + args.remove(0); rustc_real }; diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index ff0d1f3a725d2..69e09580cb7a1 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1802,8 +1802,8 @@ impl<'a> Builder<'a> { // NOTE: we intentionally use RUSTC_WRAPPER so that we can support clippy - RUSTC is not // respected by clippy-driver; RUSTC_WRAPPER happens earlier, before clippy runs. cargo.env("RUSTC_WRAPPER", self.bootstrap_out.join("rustc")); - // NOTE: we also need to set RUSTC so cargo can run `rustc -vV`; apparently that ignores RUSTC_WRAPPER >:( - cargo.env("RUSTC", self.bootstrap_out.join("rustc")); + // Set RUSTC to a non-existent path: it should never be called, since we always invoke the wrapper! + cargo.env("RUSTC", "/path/to/nowhere/all-rustc-calls-should-go-through-the-wrapper"); // Someone might have set some previous rustc wrapper (e.g. // sccache) before bootstrap overrode it. Respect that variable.