dtolnay / rustversion

Conditional compilation according to rustc compiler version
Apache License 2.0
334 stars 15 forks source link

rerun if RUSTC changes #44

Closed hkBst closed 7 months ago

hkBst commented 7 months ago

Currently rustversion uses RUSTC to determine which executable to ask for a version. If RUSTC changes, then it is possible that the version information changes as well, so should rerun in that case.

hkBst commented 7 months ago

One such situation in which rustversion does the wrong thing is when you run: cargo run then change to RUSTC=rustc_with_other_version_or_nightlyness cargo run. The second run will not pickup on the changed version because rustversion does not currently think it should rerun if RUSTC changed.

I can provide a test crate and a test wrapper for rustc if it helps.

The reason I am interested in this is that I currently have 1.76.0 installed but with nightly enabled. Since nightly has evolved since, I now need to disable nightly-detection by crates to avoid errors. There does not seem to be a direct way to do that, so I'd like to wrap rustc to change the way it reports its version.

dtolnay commented 7 months ago

Cargo already runs $RUSTC -vV and re-runs all build scripts when the rustc version is changed. The relevant thing is the rustc version, not the $RUSTC environment variable. If $RUSTC changes but the rustc version does not, there is no need to rebuild. If $RUSTC does not change but the rustc version does, we do rebuild.

If the only issue is that your wrapper only recognizes -V and not -vV, then I would prefer not to accept this change.

hkBst commented 7 months ago

Ah, indeed the wrapper started out not supporting "-vV". I will retest with that support. Thanks for the tip!