@@ -28,6 +28,53 @@ 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
+ const RUSTC_IF_UNCHANGED_ALLOWED_PATHS : & [ & str ] = & [
41
+ ":!.clang-format" ,
42
+ ":!.editorconfig" ,
43
+ ":!.git-blame-ignore-revs" ,
44
+ ":!.gitattributes" ,
45
+ ":!.gitignore" ,
46
+ ":!.gitmodules" ,
47
+ ":!.ignore" ,
48
+ ":!.mailmap" ,
49
+ ":!CODE_OF_CONDUCT.md" ,
50
+ ":!CONTRIBUTING.md" ,
51
+ ":!COPYRIGHT" ,
52
+ ":!INSTALL.md" ,
53
+ ":!LICENSE-APACHE" ,
54
+ ":!LICENSE-MIT" ,
55
+ ":!LICENSES" ,
56
+ ":!README.md" ,
57
+ ":!RELEASES.md" ,
58
+ ":!REUSE.toml" ,
59
+ ":!config.example.toml" ,
60
+ ":!configure" ,
61
+ ":!rust-bors.toml" ,
62
+ ":!rustfmt.toml" ,
63
+ ":!tests" ,
64
+ ":!triagebot.toml" ,
65
+ ":!x" ,
66
+ ":!x.ps1" ,
67
+ ":!x.py" ,
68
+ ":!src/ci/cpu-usage-over-time.py" ,
69
+ ":!src/ci/publish_toolstate.sh" ,
70
+ ":!src/doc" ,
71
+ ":!src/etc" ,
72
+ ":!src/librustdoc" ,
73
+ ":!src/rustdoc-json-types" ,
74
+ ":!src/tools" ,
75
+ ":!src/README.md" ,
76
+ ] ;
77
+
31
78
macro_rules! check_ci_llvm {
32
79
( $name: expr) => {
33
80
assert!(
@@ -2768,32 +2815,33 @@ impl Config {
2768
2815
}
2769
2816
} ;
2770
2817
2771
- let mut files_to_track = vec ! [ "compiler" , "src/version" , "src/stage0" , "src/ci/channel" ] ;
2818
+ // RUSTC_IF_UNCHANGED_ALLOWED_PATHS
2819
+ let mut allowed_paths = RUSTC_IF_UNCHANGED_ALLOWED_PATHS . to_vec ( ) ;
2772
2820
2773
- // In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, ignore
2821
+ // In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, allow
2774
2822
// these changes to speed up the build process for library developers. This provides consistent
2775
2823
// functionality for library developers between `download-rustc=true` and `download-rustc="if-unchanged"`
2776
2824
// options.
2777
- if CiEnv :: is_ci ( ) {
2778
- files_to_track . push ( "library" ) ;
2825
+ if ! CiEnv :: is_ci ( ) {
2826
+ allowed_paths . push ( ":! library" ) ;
2779
2827
}
2780
2828
2781
2829
// Look for a version to compare to based on the current commit.
2782
2830
// 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 ) ;
2831
+ let commit = match self . last_modified_commit ( & allowed_paths, "download-rustc" , if_unchanged)
2832
+ {
2833
+ Some ( commit) => commit,
2834
+ None => {
2835
+ if if_unchanged {
2836
+ return None ;
2795
2837
}
2796
- } ;
2838
+ println ! ( "ERROR: could not find commit hash for downloading rustc" ) ;
2839
+ println ! ( "HELP: maybe your repository history is too shallow?" ) ;
2840
+ println ! ( "HELP: consider setting `rust.download-rustc=false` in config.toml" ) ;
2841
+ println ! ( "HELP: or fetch enough history to include one upstream commit" ) ;
2842
+ crate :: exit!( 1 ) ;
2843
+ }
2844
+ } ;
2797
2845
2798
2846
if CiEnv :: is_ci ( ) && {
2799
2847
let head_sha =
0 commit comments