Skip to content

Commit

Permalink
use the build triple for deciding whether the first argument is clipp…
Browse files Browse the repository at this point in the history
…y or not

previously we had false-negatives when cross-compiling, which meant people just wouldn't get clippy lints for targets other than the host
  • Loading branch information
jyn514 committed Dec 9, 2023
1 parent 5645405 commit 342fd8a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ fn main() {
// otherwise, substitute whatever cargo thinks rustc should be with RUSTC_REAL.
// NOTE: this means we ignore RUSTC in the environment.
// FIXME: We might want to consider removing RUSTC_REAL and setting RUSTC directly?
let target_name = target
.map(|s| s.to_owned())
.unwrap_or_else(|| env::var("CFG_COMPILER_HOST_TRIPLE").unwrap());
let is_clippy = args[0].to_string_lossy().ends_with(&exe("clippy-driver", &target_name));
// NOTE: we intentionally pass the name of the host, not the target.
let host = env::var("CFG_COMPILER_BUILD_TRIPLE").unwrap();
let is_clippy = args[0].to_string_lossy().ends_with(&exe("clippy-driver", &host));
let rustc_driver = if is_clippy {
if is_build_script {
// Don't run clippy on build scripts (for one thing, we may not have libstd built with
Expand All @@ -87,8 +86,6 @@ fn main() {
// 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");
// NOTE: we intentionally pass the name of the host, not the target.
let host = env::var("CFG_COMPILER_BUILD_TRIPLE").unwrap();
let arg0 = exe(args[0].to_str().expect("only utf8 paths are supported"), &host);
if Path::new(&arg0) == current_exe {
args.remove(0);
Expand Down

0 comments on commit 342fd8a

Please sign in to comment.