Skip to content

Commit

Permalink
bootstrap: fully rely on RUSTC_WRAPPER
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 28, 2024
1 parent 748c548 commit 946ee4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
};

Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 946ee4f

Please sign in to comment.