Rollup merge of #94409 - RalfJung:path, r=Mark-Simulacrum

avoid rebuilding bootstrap when PATH changes

Fixes https://github.com/rust-lang/rust/issues/94408

r? ```@Mark-Simulacrum```
This commit is contained in:
Matthias Krüger 2022-02-27 21:46:35 +01:00 committed by GitHub
commit 736dae2f71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,13 +4,13 @@ use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=RUSTC");
println!("cargo:rerun-if-env-changed=PATH");
println!("cargo:rustc-env=BUILD_TRIPLE={}", env::var("HOST").unwrap());
// This may not be a canonicalized path.
let mut rustc = PathBuf::from(env::var_os("RUSTC").unwrap());
if rustc.is_relative() {
println!("cargo:rerun-if-env-changed=PATH");
for dir in env::split_paths(&env::var_os("PATH").unwrap_or_default()) {
let absolute = dir.join(&rustc);
if absolute.exists() {