From b5b21507c1a9ce2aa94a5cce6789d2b3281e62b8 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 6 Feb 2022 19:54:35 -0600 Subject: [PATCH] Rerun bootstrap's build script when RUSTC changes Previously, rustbuild would give strange errors if you tried to reuse the same build directory under two names: ``` $ mkdir tmp && cd tmp $ ../x.py check Building rustbuild Finished dev [unoptimized] target(s) in 35.27s Checking stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu) ^C $ cd .. $ mv tmp/build build $ ./x.py check Building rustbuild Compiling bootstrap v0.0.0 (/home/jnelson/rust-lang/rust/src/bootstrap) Finished dev [unoptimized] target(s) in 11.18s failed to execute command: "/home/jnelson/rust-lang/rust/tmp/build/x86_64-unknown-linux-gnu/stage0/bin/rustc" "--target" "x86_64-unknown-linux-gnu" "--print" "target-libdir" error: No such file or directory (os error 2) ``` This fixes the error. Reusing the same build directory is useful if you want to test path-things in bootstrap itself, without having to recompile it each time. For good measure, this also reruns the build script when PATH changes. --- src/bootstrap/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap/build.rs b/src/bootstrap/build.rs index d40b924e0ff5f..6e39ea00f808c 100644 --- a/src/bootstrap/build.rs +++ b/src/bootstrap/build.rs @@ -3,6 +3,8 @@ 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.