From 8c8b53cb4f088d65a298ef02864162a996d3e10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 10 Jun 2025 08:48:19 +0200 Subject: [PATCH 1/3] Invoke `cargo rustc` with the `check` profile to avoid codegen --- collector/src/compile/execute/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/collector/src/compile/execute/mod.rs b/collector/src/compile/execute/mod.rs index 55e48c3a9..d062ff747 100644 --- a/collector/src/compile/execute/mod.rs +++ b/collector/src/compile/execute/mod.rs @@ -330,12 +330,11 @@ impl<'a> CargoProcess<'a> { let mut cmd = self.base_command(self.cwd, cargo_subcommand); cmd.arg("-p").arg(self.get_pkgid(self.cwd)?); match self.profile { - Profile::Check => { + Profile::Check | Profile::Clippy => { cmd.arg("--profile").arg("check"); } Profile::Debug => {} Profile::Doc => {} - Profile::Clippy => {} Profile::Opt => { cmd.arg("--release"); } From f7ea54a393c18ee867ca18b157d15779c0ba4fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 10 Jun 2025 08:49:38 +0200 Subject: [PATCH 2/3] Invoke `clippy-driver` instead of `cargo-clippy` --- collector/src/bin/collector.rs | 3 ++- collector/src/toolchain.rs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/collector/src/bin/collector.rs b/collector/src/bin/collector.rs index a91186dcd..16f1078db 100644 --- a/collector/src/bin/collector.rs +++ b/collector/src/bin/collector.rs @@ -382,7 +382,8 @@ struct CompileTimeOptions { #[arg(long)] rustdoc: Option, - /// The path to the local clippy to measure + /// The path to the local clippy to measure. + /// It should be a path to the `clippy-driver` binary. #[arg(long)] clippy: Option, } diff --git a/collector/src/toolchain.rs b/collector/src/toolchain.rs index 42ba7ff0f..8adf127e3 100644 --- a/collector/src/toolchain.rs +++ b/collector/src/toolchain.rs @@ -128,7 +128,7 @@ impl SysrootDownload { let components = ToolchainComponents::from_binaries_and_libdir( sysroot_bin("rustc")?, Some(sysroot_bin("rustdoc")?), - sysroot_bin("cargo-clippy").ok(), + sysroot_bin("clippy-driver").ok(), sysroot_bin("cargo")?, &self.directory.join(&self.rust_sha).join("lib"), )?; @@ -484,12 +484,12 @@ pub fn get_local_toolchain( ) } else if profiles.contains(&Profile::Clippy) { // We need a `clippy`. Look for one next to `rustc`. - if let Ok(clippy) = rustc.with_file_name("cargo-clippy").canonicalize() { + if let Ok(clippy) = rustc.with_file_name("clippy-driver").canonicalize() { debug!("found clippy: {:?}", &clippy); Some(clippy) } else { anyhow::bail!( - "'Clippy' build specified but '--cargo-clippy' not specified and no 'cargo-clippy' found \ + "'Clippy' build specified but '--clippy' not specified and no 'clippy-driver' found \ next to 'rustc'" ); } From f24861a4fdeb8ae313d3168897dc145dbca14b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 10 Jun 2025 09:10:00 +0200 Subject: [PATCH 3/3] Actually invoke Clippy in the Clippy profile --- collector/src/compile/execute/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/collector/src/compile/execute/mod.rs b/collector/src/compile/execute/mod.rs index d062ff747..9e94991c0 100644 --- a/collector/src/compile/execute/mod.rs +++ b/collector/src/compile/execute/mod.rs @@ -248,7 +248,7 @@ impl<'a> CargoProcess<'a> { }; if let Some(c) = &self.toolchain.components.clippy { - cmd.env("CLIPPY", &*FAKE_CLIPPY).env("CLIPPY_REAL", c); + cmd.env("CLIPPY_REAL", c); } for config in &self.toolchain.components.cargo_configs { @@ -330,11 +330,17 @@ impl<'a> CargoProcess<'a> { let mut cmd = self.base_command(self.cwd, cargo_subcommand); cmd.arg("-p").arg(self.get_pkgid(self.cwd)?); match self.profile { - Profile::Check | Profile::Clippy => { + Profile::Check => { cmd.arg("--profile").arg("check"); } Profile::Debug => {} Profile::Doc => {} + Profile::Clippy => { + cmd.arg("--profile").arg("check"); + // For Clippy, we still invoke `cargo rustc`, but we need to override the + // executed rustc to be clippy-fake. + cmd.env("RUSTC", &*FAKE_CLIPPY); + } Profile::Opt => { cmd.arg("--release"); }