From 6b96f06ecfdb4d79b16ff9e21554c0614c99cc3a 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 420141062..fd221c07c 100644 --- a/src/compiler/compiler.rs +++ b/src/compiler/compiler.rs @@ -1292,13 +1292,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))