@@ -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!(
@@ -2772,32 +2790,33 @@ impl Config {
27722790 }
27732791 } ;
27742792
2775- let mut files_to_track = vec ! [ "compiler" , "src/version" , "src/stage0" , "src/ci/channel" ] ;
2793+ // RUSTC_IF_UNCHANGED_ALLOWED_PATHS
2794+ let mut allowed_paths = RUSTC_IF_UNCHANGED_ALLOWED_PATHS . to_vec ( ) ;
27762795
2777- // In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, ignore
2796+ // In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, allow
27782797 // these changes to speed up the build process for library developers. This provides consistent
27792798 // functionality for library developers between `download-rustc=true` and `download-rustc="if-unchanged"`
27802799 // options.
2781- if CiEnv :: is_ci ( ) {
2782- files_to_track . push ( "library" ) ;
2800+ if ! CiEnv :: is_ci ( ) {
2801+ allowed_paths . push ( ":! library" ) ;
27832802 }
27842803
27852804 // Look for a version to compare to based on the current commit.
27862805 // Only commits merged by bors will have CI artifacts.
2787- let commit =
2788- match self . last_modified_commit ( & files_to_track, "download-rustc" , if_unchanged) {
2789- Some ( commit) => commit,
2790- None => {
2791- if if_unchanged {
2792- return None ;
2793- }
2794- println ! ( "ERROR: could not find commit hash for downloading rustc" ) ;
2795- println ! ( "HELP: maybe your repository history is too shallow?" ) ;
2796- println ! ( "HELP: consider disabling `download-rustc`" ) ;
2797- println ! ( "HELP: or fetch enough history to include one upstream commit" ) ;
2798- crate :: exit!( 1 ) ;
2806+ let commit = match self . last_modified_commit ( & allowed_paths, "download-rustc" , if_unchanged)
2807+ {
2808+ Some ( commit) => commit,
2809+ None => {
2810+ if if_unchanged {
2811+ return None ;
27992812 }
2800- } ;
2813+ println ! ( "ERROR: could not find commit hash for downloading rustc" ) ;
2814+ println ! ( "HELP: maybe your repository history is too shallow?" ) ;
2815+ println ! ( "HELP: consider setting `rust.download-rustc=false` in config.toml" ) ;
2816+ println ! ( "HELP: or fetch enough history to include one upstream commit" ) ;
2817+ crate :: exit!( 1 ) ;
2818+ }
2819+ } ;
28012820
28022821 if CiEnv :: is_ci ( ) && {
28032822 let head_sha =
0 commit comments