@@ -28,6 +28,24 @@ use crate::utils::cache::{INTERNER, Interned};
2828use crate :: utils:: channel:: { self , GitInfo } ;
2929use crate :: utils:: helpers:: { self , exe, output, t} ;
3030
31+ /// Each path in this list is considered "allowed" in the `download-rustc="if-unchanged"` logic.
32+ /// This means they can be modified and changes to these paths should never trigger a compiler build
33+ /// when "if-unchanged" is set.
34+ ///
35+ /// NOTE: Paths must have the ":!" prefix to tell git to ignore changes in those paths during
36+ /// the diff check.
37+ ///
38+ /// WARNING: Be cautious when adding paths to this list. If a path that influences the compiler build
39+ /// is added here, it will cause bootstrap to skip necessary rebuilds, which may lead to risky results.
40+ /// For example, "src/bootstrap" should never be included in this list as it plays a crucial role in the
41+ /// final output/compiler, which can be significantly affected by changes made to the bootstrap sources.
42+ #[ rustfmt:: skip] // We don't want rustfmt to oneline this list
43+ pub ( crate ) const RUSTC_IF_UNCHANGED_ALLOWED_PATHS : & [ & str ] = & [
44+ ":!src/tools" ,
45+ ":!tests" ,
46+ ":!triagebot.toml" ,
47+ ] ;
48+
3149macro_rules! check_ci_llvm {
3250 ( $name: expr) => {
3351 assert!(
@@ -2768,32 +2786,33 @@ impl Config {
27682786 }
27692787 } ;
27702788
2771- let mut files_to_track = vec ! [ "compiler" , "src/version" , "src/stage0" , "src/ci/channel" ] ;
2789+ // RUSTC_IF_UNCHANGED_ALLOWED_PATHS
2790+ let mut allowed_paths = RUSTC_IF_UNCHANGED_ALLOWED_PATHS . to_vec ( ) ;
27722791
2773- // In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, ignore
2792+ // In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, allow
27742793 // these changes to speed up the build process for library developers. This provides consistent
27752794 // functionality for library developers between `download-rustc=true` and `download-rustc="if-unchanged"`
27762795 // options.
2777- if CiEnv :: is_ci ( ) {
2778- files_to_track . push ( "library" ) ;
2796+ if ! CiEnv :: is_ci ( ) {
2797+ allowed_paths . push ( ":! library" ) ;
27792798 }
27802799
27812800 // Look for a version to compare to based on the current commit.
27822801 // Only commits merged by bors will have CI artifacts.
2783- let commit =
2784- match self . last_modified_commit ( & files_to_track, "download-rustc" , if_unchanged) {
2785- Some ( commit) => commit,
2786- None => {
2787- if if_unchanged {
2788- return None ;
2789- }
2790- println ! ( "ERROR: could not find commit hash for downloading rustc" ) ;
2791- println ! ( "HELP: maybe your repository history is too shallow?" ) ;
2792- println ! ( "HELP: consider disabling `download-rustc`" ) ;
2793- println ! ( "HELP: or fetch enough history to include one upstream commit" ) ;
2794- crate :: exit!( 1 ) ;
2802+ let commit = match self . last_modified_commit ( & allowed_paths, "download-rustc" , if_unchanged)
2803+ {
2804+ Some ( commit) => commit,
2805+ None => {
2806+ if if_unchanged {
2807+ return None ;
27952808 }
2796- } ;
2809+ println ! ( "ERROR: could not find commit hash for downloading rustc" ) ;
2810+ println ! ( "HELP: maybe your repository history is too shallow?" ) ;
2811+ println ! ( "HELP: consider setting `rust.download-rustc=false` in config.toml" ) ;
2812+ println ! ( "HELP: or fetch enough history to include one upstream commit" ) ;
2813+ crate :: exit!( 1 ) ;
2814+ }
2815+ } ;
27972816
27982817 if CiEnv :: is_ci ( ) && {
27992818 let head_sha =
0 commit comments