@@ -28,6 +28,63 @@ 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
+ ":!.github" ,
42
+ ":!.clang-format" ,
43
+ ":!.editorconfig" ,
44
+ ":!.git-blame-ignore-revs" ,
45
+ ":!.gitattributes" ,
46
+ ":!.gitignore" ,
47
+ ":!.gitmodules" ,
48
+ ":!.ignore" ,
49
+ ":!.mailmap" ,
50
+ ":!CODE_OF_CONDUCT.md" ,
51
+ ":!CONTRIBUTING.md" ,
52
+ ":!COPYRIGHT" ,
53
+ ":!Cargo.lock" ,
54
+ ":!Cargo.toml" ,
55
+ ":!INSTALL.md" ,
56
+ ":!LICENSE-APACHE" ,
57
+ ":!LICENSE-MIT" ,
58
+ ":!LICENSES" ,
59
+ ":!README.md" ,
60
+ ":!RELEASES.md" ,
61
+ ":!REUSE.toml" ,
62
+ ":!config.example.toml" ,
63
+ ":!configure" ,
64
+ ":!rust-bors.toml" ,
65
+ ":!rustfmt.toml" ,
66
+ ":!src" ,
67
+ ":!tests" ,
68
+ ":!triagebot.toml" ,
69
+ ":!x" ,
70
+ ":!x.ps1" ,
71
+ ":!x.py" ,
72
+ ] ;
73
+
74
+ /// Holds subpaths from [`RUSTC_IF_UNCHANGED_ALLOWED_PATHS`] that should not be allowed.
75
+ const RUSTC_IF_UNCHANGED_DENIED_SUBPATHS : & [ & str ] = & [
76
+ "src/stage0" ,
77
+ "src/version" ,
78
+ "src/ci/channel" ,
79
+ // FIXME: We should add more paths from bootstrap, but this may require
80
+ // moving some logic into separate For instance, the logic for handling
81
+ // rustflags should be moved to a specific module and that module's path
82
+ // should be included here.
83
+ "src/bootstrap/defaults" ,
84
+ "src/bootstrap/src/bin/rustc.rs" ,
85
+ "src/bootstrap/src/core/config/config.rs" ,
86
+ ] ;
87
+
31
88
macro_rules! check_ci_llvm {
32
89
( $name: expr) => {
33
90
assert!(
@@ -2751,18 +2808,9 @@ impl Config {
2751
2808
}
2752
2809
} ;
2753
2810
2754
- let files_to_track = & [
2755
- self . src . join ( "compiler" ) ,
2756
- self . src . join ( "library" ) ,
2757
- self . src . join ( "src/version" ) ,
2758
- self . src . join ( "src/stage0" ) ,
2759
- self . src . join ( "src/ci/channel" ) ,
2760
- ] ;
2761
-
2762
2811
// Look for a version to compare to based on the current commit.
2763
2812
// Only commits merged by bors will have CI artifacts.
2764
- let commit =
2765
- get_closest_merge_commit ( Some ( & self . src ) , & self . git_config ( ) , files_to_track) . unwrap ( ) ;
2813
+ let commit = get_closest_merge_commit ( Some ( & self . src ) , & self . git_config ( ) , & [ ] ) . unwrap ( ) ;
2766
2814
if commit. is_empty ( ) {
2767
2815
println ! ( "ERROR: could not find commit hash for downloading rustc" ) ;
2768
2816
println ! ( "HELP: maybe your repository history is too shallow?" ) ;
@@ -2784,27 +2832,27 @@ impl Config {
2784
2832
return None ;
2785
2833
}
2786
2834
2787
- // Warn if there were changes to the compiler or standard library since the ancestor commit.
2788
- let has_changes = !t ! ( helpers:: git( Some ( & self . src) )
2789
- . args( [ "diff-index" , "--quiet" , & commit] )
2790
- . arg( "--" )
2791
- . args( files_to_track)
2792
- . as_command_mut( )
2793
- . status( ) )
2794
- . success ( ) ;
2795
- if has_changes {
2835
+ let in_tree_build_required = |paths| {
2836
+ !t ! ( helpers:: git( Some ( & self . src) )
2837
+ . args( [ "diff-index" , "--quiet" , & commit] )
2838
+ . arg( "--" )
2839
+ . args( paths)
2840
+ . as_command_mut( )
2841
+ . status( ) )
2842
+ . success ( )
2843
+ } ;
2844
+
2845
+ if in_tree_build_required ( RUSTC_IF_UNCHANGED_ALLOWED_PATHS )
2846
+ || in_tree_build_required ( RUSTC_IF_UNCHANGED_DENIED_SUBPATHS )
2847
+ {
2796
2848
if if_unchanged {
2797
2849
if self . is_verbose ( ) {
2798
- println ! (
2799
- "WARNING: saw changes to compiler/ or library/ since {commit}; \
2800
- ignoring `download-rustc`"
2801
- ) ;
2850
+ println ! ( "WARNING: changes detected since {commit}; ignoring `download-rustc`" ) ;
2802
2851
}
2803
2852
return None ;
2804
2853
}
2805
2854
println ! (
2806
- "WARNING: `download-rustc` is enabled, but there are changes to \
2807
- compiler/ or library/"
2855
+ "WARNING: `download-rustc` is enabled while there are changes on the paths that can influence the compiler builds."
2808
2856
) ;
2809
2857
}
2810
2858
0 commit comments