clippy-driver acts as a bogus rustc wrapper
This came up in https://github.com/cuviper/autocfg/issues/58, and may also become more relevant with https://github.com/rust-lang/cargo/pull/13659 and https://github.com/djc/rustc-version-rs/issues/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.
cargo clippysetsclippy-driveras RUSTC_WRAPPER
(Not related to this bug itself, but AFAIK, as said in https://github.com/cuviper/autocfg/issues/58#issuecomment-2067625980, cargo clippy sets clippy-driver as RUSTC_WORKSPACE_WRAPPER, not RUSTC_WRAPPER.)
(Not related to this bug itself, but AFAIK, as said in cuviper/autocfg#58 (comment),
cargo clippysetsclippy-driveras RUSTC_WORKSPACE_WRAPPER, not RUSTC_WRAPPER.)
Ah, sorry for that -- fixed.
FYI, Libc no longer compiles with with clippy-driver as a RUSTC_WRAPPER, since this MR: https://github.com/rust-lang/libc/pull/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.