-
Notifications
You must be signed in to change notification settings - Fork 23
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
autocfg still calls rustc without the wrapper #58
Comments
Hmm... I'm not sure that we should, given rust-lang/cargo#10885, but I suppose if cargo is willing to change then we can follow suit. We can't make that behavior conditional on version, since that's what we're probing there, but maybe if the wrapper fails we can try again without it. |
This might alternatively be a feature request for Cargo. Do Exposing the original Possible implementations for fixing this on the Cargo side include:
Any of these, especially the last one, seems better than boiling the ocean to update every real-world build script. |
Sounds like a new approach to resolve this feature request: rust-lang/cargo#11244 |
I would expect it's more of a pond than an ocean -- do you really think manual |
This kind of thing is common: https://github.com/dtolnay/semver/blob/1.0.22/build.rs#L67-L68 In my own crates, the build scripts are written so that if Some examples in high-profile crates:
And here's hundreds more uses of $RUSTC: https://github.com/search?q=%2F%5Cbvar(_os)%3F%5C(%22RUSTC%22%5C)%2F%20path%3Abuild.rs&type=code. Who knows what they're all doing but practically none of them pay attention to *_WRAPPER. |
Ouch, that's a lot more than I expected... |
Yeah... that makes setting RUSTC to a non-existent path not very appealing. :/ So maybe the farthest we can go is to say that if you invoke RUSTC directly without the wrapper all you should do is query the version. You definitely can't expect the sysroot to be the same as with the wrapper though, and you can't expect direct RUSTC invocations to support the target indicated by TARGET. |
That said, rustc bootstrap may still want to require the wrapper to be called even for |
FYI, clippy-deriver is one of the wrappers that currently does not work properly in the use case of getting the rustc version. $ 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 AFAIK clippy-driver is usually only used as RUSTC_WORKSPACE_WRAPPER, so I think we could work around the problem by applying only RUSTC_WRAPPER when getting the rustc version. (The bug should be fixed on the clippy side, but a workaround is needed anyway, since rustc version detection needs to work with older toolchains.) Since RUSTC_WORKSPACE_WRAPPER applies only for workspace members, unlike RUSTC_WRAPPER which applies for all crates, it should not change the toolchain (since it will result in linking crates compiled with different rustc versions). So ignoring RUSTC_WORKSPACE_WRAPPER when getting the rustc version should not affect the correctness of the results. |
Why is clippy-driver even a wrapper? The equivalent I would argue this is a bug in clippy-driver. A wrapper is supposed to wrap the rustc invocation, not change its |
Filed as a clippy bug: rust-lang/rust-clippy#12697 |
It also seems weird to me that the clippy wrapper would be set while executing a build script, but so it is... |
That is expected, it is set for the entire "cargo clippy" invocation and cargo does not unset anything for build scripts. After all build scripts should also honor which RUSTC cargo invokes (and with which wrapper).
|
I'm playing around with a patched version of cargo that lets me set
This makes it immediately obvious when something bypasses RUSTC_WRAPPER.
And it turns out this makes autocfg panic. I think it's this call that is not wrapped:
autocfg/src/lib.rs
Line 160 in c10bc17
The text was updated successfully, but these errors were encountered: