Skip to content

Commit e794ef7

Browse files
committed
fix: set CARGO env var during rustc -vV probe
The -vV probe goes through RUSTC_WRAPPER and RUSTC_WORKSPACE_WRAPPER since rust-lang#13659, but the CARGO env var was not set. Tools like sccache depend on CARGO to detect the workspace wrapper pattern in their compiler detection logic. Closes rust-lang#16805
1 parent e4d75c9 commit e794ef7

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/cargo/util/rustc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl Rustc {
6363
.wrapped(workspace_wrapper.as_ref())
6464
.wrapped(wrapper.as_deref());
6565
apply_env_config(gctx, &mut cmd)?;
66+
cmd.env(crate::CARGO_ENV, gctx.cargo_exe()?);
6667
cmd.arg("-vV");
6768
let verbose_version = cache.cached_output(&cmd, 0)?.0;
6869

tests/testsuite/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4581,8 +4581,8 @@ fn rustc_wrapper_vv_probe_has_cargo_env() {
45814581

45824582
let result = std::fs::read_to_string(marker_dir.join("cargo_env_in_vv")).unwrap();
45834583
assert_eq!(
4584-
result, "false",
4585-
"CARGO env var should not be set during -vV probe without the fix"
4584+
result, "true",
4585+
"CARGO env var should be set during -vV probe for wrapper compatibility"
45864586
);
45874587
}
45884588

0 commit comments

Comments
 (0)