Skip to content

Commit 5fef0e9

Browse files
committed
use allowed "if-unchanged" logic for compiler builds
Signed-off-by: onur-ozkan <[email protected]>
1 parent 0037048 commit 5fef0e9

File tree

1 file changed

+61
-20
lines changed

1 file changed

+61
-20
lines changed

src/bootstrap/src/core/config/config.rs

+61-20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,60 @@ use crate::utils::cache::{INTERNER, Interned};
2828
use crate::utils::channel::{self, GitInfo};
2929
use 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+
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+
":!INSTALL.md",
54+
":!LICENSE-APACHE",
55+
":!LICENSE-MIT",
56+
":!LICENSES",
57+
":!README.md",
58+
":!RELEASES.md",
59+
":!REUSE.toml",
60+
":!config.example.toml",
61+
":!configure",
62+
":!rust-bors.toml",
63+
":!rustfmt.toml",
64+
":!tests",
65+
":!triagebot.toml",
66+
":!x",
67+
":!x.ps1",
68+
":!x.py",
69+
":!src/ci/docker",
70+
":!src/ci/github-actions",
71+
":!src/ci/scripts",
72+
":!src/ci/cpu-usage-over-time.py",
73+
":!src/ci/publish_toolstate.sh",
74+
":!src/ci/run.sh",
75+
":!src/ci/shared.sh",
76+
":!src/doc",
77+
":!src/etc",
78+
":!src/gcc",
79+
":!src/librustdoc",
80+
":!src/rustdoc-json-types",
81+
":!src/tools",
82+
":!src/README.md",
83+
];
84+
3185
macro_rules! check_ci_llvm {
3286
($name:expr) => {
3387
assert!(
@@ -2751,18 +2805,9 @@ impl Config {
27512805
}
27522806
};
27532807

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-
27622808
// Look for a version to compare to based on the current commit.
27632809
// 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();
2810+
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();
27662811
if commit.is_empty() {
27672812
println!("ERROR: could not find commit hash for downloading rustc");
27682813
println!("HELP: maybe your repository history is too shallow?");
@@ -2784,27 +2829,23 @@ impl Config {
27842829
return None;
27852830
}
27862831

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))
2832+
let in_tree_build_required = !t!(helpers::git(Some(&self.src))
27892833
.args(["diff-index", "--quiet", &commit])
27902834
.arg("--")
2791-
.args(files_to_track)
2835+
.args(RUSTC_IF_UNCHANGED_ALLOWED_PATHS)
27922836
.as_command_mut()
27932837
.status())
27942838
.success();
2795-
if has_changes {
2839+
2840+
if in_tree_build_required {
27962841
if if_unchanged {
27972842
if self.is_verbose() {
2798-
println!(
2799-
"WARNING: saw changes to compiler/ or library/ since {commit}; \
2800-
ignoring `download-rustc`"
2801-
);
2843+
println!("WARNING: changes detected since {commit}; ignoring `download-rustc`");
28022844
}
28032845
return None;
28042846
}
28052847
println!(
2806-
"WARNING: `download-rustc` is enabled, but there are changes to \
2807-
compiler/ or library/"
2848+
"WARNING: `download-rustc` is enabled while there are changes on the paths that can influence the compiler builds."
28082849
);
28092850
}
28102851

0 commit comments

Comments
 (0)