From d32ce89889843063385357c39d67e3db78b99ba7 Mon Sep 17 00:00:00 2001 From: Daniel Rainer Date: Mon, 18 Aug 2025 20:51:31 +0200 Subject: [PATCH] Remove unnecessary rebuild paths Cargo tracks normal Rust dependencies and automatically figures out if changes to Rust source files, `Cargo.{toml,lock}`, and `build.rs` necessitate a rebuild, and if so of what. In some cases these checks are smarter than just comparing file modification times, so not specifying such paths explicitly can reduce the amount of rebuilding which happens, without skipping necessary rebuilding. ja: this reverts b2aaf1db52f (Rebuild if src changed, 2025-03-28) and 460b93a (Rebuild on changes relevant to build artifacts, 2025-03-30) which tried to fix #11332 ("moving Git HEAD does not invalidate cargo build results"). But that expectation is overbearing. It's better to only rebuild if something else of relevance to the build output has changed. Closes #11736 --- build.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/build.rs b/build.rs index a31076f61..0b316e32d 100644 --- a/build.rs +++ b/build.rs @@ -63,20 +63,11 @@ fn main() { let _ = std::fs::create_dir_all(sec1dir.to_str().unwrap()); } - rsconf::rebuild_if_paths_changed(&[ - "build.rs", - "Cargo.lock", - "Cargo.toml", - "crates/gettext-extraction", - "crates/printf", - "src", - ]); - // These are necessary if built with embedded functions, // but only in release builds (because rust-embed in debug builds reads from the filesystem). #[cfg(feature = "embed-data")] #[cfg(not(debug_assertions))] - rsconf::rebuild_if_paths_changed(&["share"]); + rsconf::rebuild_if_path_changed("share"); #[cfg(feature = "embed-data")] #[cfg(not(clippy))] @@ -85,6 +76,7 @@ fn main() { #[cfg(feature = "gettext-extract")] rsconf::rebuild_if_env_changed("FISH_GETTEXT_EXTRACTION_FILE"); + rsconf::rebuild_if_path_changed("src/libc.c"); cc::Build::new().file("src/libc.c").compile("flibc.a"); let mut build = cc::Build::new();