fix: change the way to decide whether there's a RUSTC_WORKSPACE_WRAPPER
#2408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1280 added support for locating the
rustc
binary when there's a workspace wrapper set viaRUSTC_WORKSPACE_WRAPPER
. A check on the existence of env varCARGO
was included as a guardrail against false positives.However, this doesn't seem to always work. In my reproduction at https://github.com/bugenzhao/sccache-wrapper-reproduce, it seems that the environment variable
CARGO
is not set whencargo
attempts to detect the compiler as its initial step:https://github.com/rust-lang/cargo/blob/2251525ae503fa196f6d7f9ce6d32eccb2d5f044/src/cargo/util/rustc.rs#L62-L66
As a result, we fail to decide the
maybe_rustc_executable
and eventually run into the testing of C compiler:This PR attempts to fix this by directly checking whether
RUSTC_WORKSPACE_WRAPPER
is set.