Skip to content

Commit baa95ef

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

File tree

1 file changed

+65
-17
lines changed

1 file changed

+65
-17
lines changed

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

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,53 @@ 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+
":!.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+
3178
macro_rules! check_ci_llvm {
3279
($name:expr) => {
3380
assert!(
@@ -2768,32 +2815,33 @@ impl Config {
27682815
}
27692816
};
27702817

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();
27722820

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
27742822
// these changes to speed up the build process for library developers. This provides consistent
27752823
// functionality for library developers between `download-rustc=true` and `download-rustc="if-unchanged"`
27762824
// options.
2777-
if CiEnv::is_ci() {
2778-
files_to_track.push("library");
2825+
if !CiEnv::is_ci() {
2826+
allowed_paths.push(":!library");
27792827
}
27802828

27812829
// Look for a version to compare to based on the current commit.
27822830
// 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;
27952837
}
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+
};
27972845

27982846
if CiEnv::is_ci() && {
27992847
let head_sha =

0 commit comments

Comments
 (0)