diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 6c7cc3bf6a736..2d5e861aa1d1c 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -2046,7 +2046,15 @@ fn install_llvm_file( // projects like miri link against librustc_driver.so. We don't use a symlink, as // these are not allowed inside rustup components. let link = t!(fs::read_link(source)); - t!(std::fs::write(full_dest, format!("INPUT({})\n", link.display()))); + let mut linker_script = t!(fs::File::create(full_dest)); + t!(write!(linker_script, "INPUT({})\n", link.display())); + + // We also want the linker script to have the same mtime as the source, otherwise it + // can trigger rebuilds. + let meta = t!(fs::metadata(source)); + if let Ok(mtime) = meta.modified() { + t!(linker_script.set_modified(mtime)); + } } } else { builder.install(&source, destination, 0o644);