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

cargo doesn't rerun build scripts when RUSTC is changed #10367

Open
jyn514 opened this issue Feb 7, 2022 · 3 comments
Open

cargo doesn't rerun build scripts when RUSTC is changed #10367

jyn514 opened this issue Feb 7, 2022 · 3 comments
Labels
A-rebuild-detection Area: rebuild detection and fingerprinting C-bug Category: bug

Comments

@jyn514
Copy link
Member

jyn514 commented Feb 7, 2022

Problem

The RUSTC env variable is provided to build scripts by cargo. According to the docs: https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-env-changed

It is not necessary to use this for environment variables like TARGET that Cargo sets.

Cargo should rerun build scripts when rustc changes. I suspect this code needs to account for the path of the compiler, not just the version:

hash_rustc_version(bcx, &mut hasher);

See rust-lang/rust#93723 for a reproduction, but it's not anywhere close to minimal.

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.59.0-beta.5 (5ad495c68 2022-01-25)
@jyn514 jyn514 added the C-bug Category: bug label Feb 7, 2022
@ehuss
Copy link
Contributor

ehuss commented Feb 27, 2022

This is currently intentional behavior. There are situations where RUSTC changes, but we don't want that to trigger a full recompile. If one rustc emits the same version output as another, then cargo assumes they essentially behave the same, even if they are from different paths. I'm not sure this is something that can be changed without causing unwanted recompiles in some situations.

@ehuss ehuss added the A-rebuild-detection Area: rebuild detection and fingerprinting label Feb 27, 2022
@jyn514
Copy link
Member Author

jyn514 commented Mar 1, 2022

Ok. Is it possible to document this somewhere? Maybe around https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-env-changed ?

@jyn514
Copy link
Member Author

jyn514 commented Mar 1, 2022

If one rustc emits the same version output as another, then cargo assumes they essentially behave the same, even if they are from different paths.

To be clear, the original bug in x.py was that it cached the path from the build script and would try to run that compiler on all subsequent builds, which broke because the target directory was deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rebuild-detection Area: rebuild detection and fingerprinting C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants