Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy-driver acts as a bogus rustc wrapper #12697

Open
RalfJung opened this issue Apr 20, 2024 · 3 comments
Open

clippy-driver acts as a bogus rustc wrapper #12697

RalfJung opened this issue Apr 20, 2024 · 3 comments

Comments

@RalfJung
Copy link
Member

RalfJung commented Apr 20, 2024

This came up in cuviper/autocfg#58, and may also become more relevant with rust-lang/cargo#13659 and djc/rustc-version-rs#45:

Apparently, cargo clippy sets clippy-driver as RUSTC_WORKSPACE_WRAPPER, but that wrapper behaves incorrectly, i.e. it does not always properly forward everything to rustc:

$ clippy-driver rustc --version                                              
clippy 0.1.79 (f9b16149 2024-04-19)

$ clippy-driver rustc --version --verbose
clippy 0.1.79 (f9b16149 2024-04-19)

$ clippy-driver rustc --rustc --version  
rustc 1.79.0-nightly (f9b161492 2024-04-19)

$ clippy-driver rustc --rustc --version --verbose
rustc 1.79.0-nightly (f9b161492 2024-04-19)
binary: rustc
commit-hash: f9b16149208c8a8a349c32813312716f6603eb6f
commit-date: 2024-04-19
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.4

$ clippy-driver rustc -V
clippy 0.1.79 (f9b16149 2024-04-19)

$ clippy-driver rustc -Vv
rustc 1.79.0-nightly (f9b161492 2024-04-19)
binary: rustc
commit-hash: f9b16149208c8a8a349c32813312716f6603eb6f
commit-date: 2024-04-19
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.4

$ clippy-driver rustc -vV
rustc 1.79.0-nightly (f9b161492 2024-04-19)
binary: rustc
commit-hash: f9b16149208c8a8a349c32813312716f6603eb6f
commit-date: 2024-04-19
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.4

I am surprised that clippy-driver is even being set as RUSTC_WORKSPACE_WRAPPER; Miri (which has a similar problem to solve) does not do that. Instead cargo-miri sets itself as RUSTC_WRAPPER so that it can then dispatch to the driver as appropriate. Either way can work, but whatever is set as RUSTC_WRAPPER/RUSTC_WORKSPACE_WRAPPER should behave like a proper wrapper and not intercept --version queries.

@taiki-e
Copy link
Member

taiki-e commented Apr 20, 2024

cargo clippy sets clippy-driver as RUSTC_WRAPPER

(Not related to this bug itself, but AFAIK, as said in cuviper/autocfg#58 (comment), cargo clippy sets clippy-driver as RUSTC_WORKSPACE_WRAPPER, not RUSTC_WRAPPER.)

@RalfJung
Copy link
Member Author

(Not related to this bug itself, but AFAIK, as said in cuviper/autocfg#58 (comment), cargo clippy sets clippy-driver as RUSTC_WORKSPACE_WRAPPER, not RUSTC_WRAPPER.)

Ah, sorry for that -- fixed.

@nlflint
Copy link

nlflint commented Aug 30, 2024

FYI, Libc no longer compiles with with clippy-driver as a RUSTC_WRAPPER, since this MR: rust-lang/libc#3845. this crate is used everywhere.

The problem appears to --version behavior difference between between rustc and clippy-driver. See line of code here: https://github.com/rust-lang/libc/blob/6637dbe2365d0649ae592c9533a2f7b93ba7200a/build.rs#L231

Libc could make their version parsing more sophisticated, but I think the proper fix is for clippy-driver to properly wrap rustc and not change behavior of --version.

For now, I'm working around by setting RUSTC_WORKSPACE_WRAPPER, instead of RUSTC_WRAPPER, with the path to my clippy-driver. Works pretty much the same, but bypasses the problem in libc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants