@@ -28,6 +28,24 @@ use crate::utils::cache::{INTERNER, Interned};
28
28
use crate :: utils:: channel:: { self , GitInfo } ;
29
29
use crate :: utils:: helpers:: { self , exe, output, t} ;
30
30
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
+
31
49
macro_rules! check_ci_llvm {
32
50
( $name: expr) => {
33
51
assert!(
@@ -2768,32 +2786,33 @@ impl Config {
2768
2786
}
2769
2787
} ;
2770
2788
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 ( ) ;
2772
2791
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
2774
2793
// these changes to speed up the build process for library developers. This provides consistent
2775
2794
// functionality for library developers between `download-rustc=true` and `download-rustc="if-unchanged"`
2776
2795
// options.
2777
- if CiEnv :: is_ci ( ) {
2778
- files_to_track . push ( "library" ) ;
2796
+ if ! CiEnv :: is_ci ( ) {
2797
+ allowed_paths . push ( ":! library" ) ;
2779
2798
}
2780
2799
2781
2800
// Look for a version to compare to based on the current commit.
2782
2801
// 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 ;
2795
2808
}
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
+ } ;
2797
2816
2798
2817
if CiEnv :: is_ci ( ) && {
2799
2818
let head_sha =
0 commit comments