You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[xtask] fix recompilations with cargo xtask clippy (#7740)
@davepacheco reported an issue where `cargo check --all-targets && cargo
xtask clippy` would cause many recompilations, starting from `ring`.
This turned out to be because:
* `cargo xtask`, when run, has `CARGO_MANIFEST_DIR` and other related
environment variables set in its environment, but a regular `cargo
check` does not
* these variables were being inherited by child Cargo processes
* ring's build script emits a bunch of `cargo:rerun-if-env-changed`
instructions for `CARGO_MANIFEST_DIR` etc
* when Cargo determines whether the env has actually changed, it only
looks at what it *sees*, not what it *sets* for scripts
To address this, remove a few environment variables from child Cargo
processes' environments. I've tested this and it solves this issue, but
it isn't a full fix. It's quite possible that we'll have to add the list
if we see more recompilations in the future, but at least we know what's
going on now.
This is probably a bug in Cargo -- in this determination it should look
at what it sets, since that's what build scripts care about.
This is also a bug in ring's build script, I think. Cargo's
documentation says in [this
section](https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-env-changed):
> Note that the environment variables here are intended for global
environment variables like CC and such, it is not possible to use this
for environment variables like TARGET that [Cargo sets for build
scripts](https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts).
The environment variables in use are those received by cargo
invocations, not those received by the executable of the build script.
I've filed ctz/ring#10 for that.
I determined this via logging both of these commands into files and
comparing them. Thanks to @mkeeter for the suggestion to use this
`CARGO_LOG` variable!
```console
$ CARGO_LOG=cargo::core::compiler::fingerprint=trace cargo clippy --all-targets --workspace
$ CARGO_LOG=cargo::core::compiler::fingerprint=trace cargo xtask clippy
```
---
I also included a `rerun-if-changed` instruction in the workspace-hack's
`build.rs` to ensure that that doesn't cause any rebuilds either. (I
should probably fix hakari's initialization template to produce this
line.)
0 commit comments