Skip to content

Commit 1971a27

Browse files
committed
Synchronize LLVM invalidation paths between config and LLVM step
1 parent b832360 commit 1971a27

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,18 @@ pub fn prebuilt_llvm_config(
174174
LlvmBuildStatus::ShouldBuild(Meta { stamp, res, out_dir, root: root.into() })
175175
}
176176

177+
/// Paths whose changes invalidate LLVM downloads.
178+
pub const LLVM_INVALIDATION_PATHS: &[&str] = &[
179+
"src/llvm-project",
180+
"src/bootstrap/download-ci-llvm-stamp",
181+
// the LLVM shared object file is named `LLVM-<LLVM-version>-rust-{version}-nightly`
182+
"src/version",
183+
];
184+
177185
/// Detect whether LLVM sources have been modified locally or not.
178186
pub(crate) fn detect_llvm_freshness(config: &Config, is_git: bool) -> PathFreshness {
179187
if is_git {
180-
config.check_path_modifications(&[
181-
"src/llvm-project",
182-
"src/bootstrap/download-ci-llvm-stamp",
183-
// the LLVM shared object file is named `LLVM-12-rust-{version}-nightly`
184-
"src/version",
185-
])
188+
config.check_path_modifications(LLVM_INVALIDATION_PATHS)
186189
} else if let Some(info) = crate::utils::channel::read_commit_info_file(&config.src) {
187190
PathFreshness::LastModifiedUpstream { upstream: info.sha.trim().to_owned() }
188191
} else {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use tracing::{instrument, span};
2323

2424
use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX;
2525
use crate::core::build_steps::llvm;
26+
use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
2627
pub use crate::core::config::flags::Subcommand;
2728
use crate::core::config::flags::{Color, Flags, Warnings};
2829
use crate::core::download::is_download_ci_available;
@@ -3108,7 +3109,7 @@ impl Config {
31083109
self.update_submodule("src/llvm-project");
31093110

31103111
// Check for untracked changes in `src/llvm-project`.
3111-
let has_changes = self.has_changes_from_upstream(&["src/llvm-project"]);
3112+
let has_changes = self.has_changes_from_upstream(LLVM_INVALIDATION_PATHS);
31123113

31133114
// Return false if there are untracked changes, otherwise check if CI LLVM is available.
31143115
if has_changes { false } else { llvm::is_ci_llvm_available(self, asserts) }

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use super::flags::Flags;
1111
use super::{ChangeIdWrapper, Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
1212
use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
1313
use crate::core::build_steps::llvm;
14+
use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
1415
use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig};
1516

1617
pub(crate) fn parse(config: &str) -> Config {
@@ -39,7 +40,7 @@ fn download_ci_llvm() {
3940

4041
let if_unchanged_config = parse("llvm.download-ci-llvm = \"if-unchanged\"");
4142
if if_unchanged_config.llvm_from_ci {
42-
let has_changes = if_unchanged_config.has_changes_from_upstream(&["src/llvm-project"]);
43+
let has_changes = if_unchanged_config.has_changes_from_upstream(LLVM_INVALIDATION_PATHS);
4344

4445
assert!(
4546
!has_changes,

0 commit comments

Comments
 (0)