diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 62ef5804dce6d..3c7f426781832 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -103,8 +103,10 @@ fn main() { println!("cargo:rustc-check-cfg=values(llvm_component,\"{}\")", component); } - if tracked_env_var_os("RUST_CHECK").is_some() { + if env::var_os("RUST_CHECK").is_some() { // If we're just running `check`, there's no need for LLVM to be built. + // We only track the RUST_CHECK var if it exists to prevent spurious rebuilds. + println!("cargo:rerun-if-env-changed=RUST_CHECK"); return; } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index dd2b9d59366ea..6c8efb0232641 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -780,9 +780,21 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS cargo.env("LLVM_RUSTLLVM", "1"); } let llvm_config = builder.ensure(native::Llvm { target }); - cargo.env("LLVM_CONFIG", &llvm_config); + + // HACK: on windows, paths are case insensitive, so case differences cause spurious rebuilds + if target.contains("windows") { + cargo.env("LLVM_CONFIG", llvm_config.as_os_str().to_ascii_lowercase()); + } else { + cargo.env("LLVM_CONFIG", &llvm_config); + } + if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { - cargo.env("CFG_LLVM_ROOT", s); + // HACK: on windows, paths are case insensitive, so case differences cause spurious rebuilds + if target.contains("windows") { + cargo.env("CFG_LLVM_ROOT", s.as_os_str().to_ascii_lowercase()); + } else { + cargo.env("CFG_LLVM_ROOT", s); + } } // Some LLVM linker flags (-L and -l) may be needed to link `rustc_llvm`. Its build script