From 23d093d494238a82b4d825e11587ed8da69279ae Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Tue, 17 Jun 2025 17:13:14 +0800 Subject: [PATCH] fix: change the way to decide whether there's a `RUSTC_WORKSPACE_WRAPPER` Signed-off-by: Bugen Zhao --- src/compiler/compiler.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/compiler/compiler.rs b/src/compiler/compiler.rs index a00f64d7e..5cc1c848c 100644 --- a/src/compiler/compiler.rs +++ b/src/compiler/compiler.rs @@ -1301,13 +1301,12 @@ where let maybe_rustc_executable = if is_rustc_like(executable) { Some(executable.to_path_buf()) - } else if env.iter().any(|(k, _)| k == OsStr::new("CARGO")) { - // If not, detect the scenario where cargo is configured to wrap rustc with something other than sccache. - // This happens when sccache is used as a `RUSTC_WRAPPER` and another tool is used as a - // `RUSTC_WORKSPACE_WRAPPER`. In that case rustc will be the first argument rather than the command. - // - // The check for the `CARGO` env acts as a guardrail against false positives. - // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-reads + } else if env + .iter() + .any(|(k, _)| k == OsStr::new("RUSTC_WORKSPACE_WRAPPER") || k == OsStr::new("CARGO")) + { + // When sccache is used as a `RUSTC_WRAPPER` and another tool is used as a `RUSTC_WORKSPACE_WRAPPER`, + // rustc will be the first argument rather than the command. args.iter() .next() .filter(|arg1| is_rustc_like(arg1))