Commit d92c100
Honor the RUSTC env var in stdlib_entry's version lookup
`stdlib_entry()` read the stdlib version by spawning
`Command::new(if cfg!(windows) { "rustc.exe" } else { "rustc" })`,
which finds whichever `rustc` happens to be first on `PATH`. That is
not guaranteed to be the compiler cargo resolved for this build —
rustup overrides, `cargo +nightly build`, a custom `RUSTC` setting at
the cargo level, or even a test harness manipulating `PATH` can all
make the two diverge.
Cargo exports the resolved compiler path via the `RUSTC` environment
variable to every build script precisely for this case. Use it when
set (which is always, for a normal cargo build), falling back to the
bare name only in exotic environments that run a build script without
cargo's env-var scaffolding.
No behavior change in the happy path — the version emitted into the
manifest is still `rustc --version`'s output — but now it reliably
reflects the compiler that built the binary, not whatever `rustc`
shadowed it on `PATH`.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 3167816 commit d92c100
1 file changed
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
274 | 278 | | |
275 | 279 | | |
276 | 280 | | |
277 | 281 | | |
278 | 282 | | |
279 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
280 | 296 | | |
281 | 297 | | |
282 | 298 | | |
| |||
0 commit comments