Skip to content

Commit 342fd8a

Browse files
committed
use the build triple for deciding whether the first argument is clippy 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
1 parent 5645405 commit 342fd8a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/bootstrap/src/bin/rustc.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ fn main() {
6868
// otherwise, substitute whatever cargo thinks rustc should be with RUSTC_REAL.
6969
// NOTE: this means we ignore RUSTC in the environment.
7070
// FIXME: We might want to consider removing RUSTC_REAL and setting RUSTC directly?
71-
let target_name = target
72-
.map(|s| s.to_owned())
73-
.unwrap_or_else(|| env::var("CFG_COMPILER_HOST_TRIPLE").unwrap());
74-
let is_clippy = args[0].to_string_lossy().ends_with(&exe("clippy-driver", &target_name));
71+
// NOTE: we intentionally pass the name of the host, not the target.
72+
let host = env::var("CFG_COMPILER_BUILD_TRIPLE").unwrap();
73+
let is_clippy = args[0].to_string_lossy().ends_with(&exe("clippy-driver", &host));
7574
let rustc_driver = if is_clippy {
7675
if is_build_script {
7776
// Don't run clippy on build scripts (for one thing, we may not have libstd built with
@@ -87,8 +86,6 @@ fn main() {
8786
// don't remove the first arg if we're being run as RUSTC instead of RUSTC_WRAPPER.
8887
// Cargo also sometimes doesn't pass the `.exe` suffix on Windows - add it manually.
8988
let current_exe = env::current_exe().expect("couldn't get path to rustc shim");
90-
// NOTE: we intentionally pass the name of the host, not the target.
91-
let host = env::var("CFG_COMPILER_BUILD_TRIPLE").unwrap();
9289
let arg0 = exe(args[0].to_str().expect("only utf8 paths are supported"), &host);
9390
if Path::new(&arg0) == current_exe {
9491
args.remove(0);

0 commit comments

Comments
 (0)