Skip to content

Commit 80a5adf

Browse files
committed
Unify LLVM invalidation path handling
Before it was using a different set of paths in different call-sites.
1 parent 4ac032f commit 80a5adf

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

Diff for: src/bootstrap/src/core/build_steps/gcc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ fn detect_gcc_sha(config: &crate::Config, is_git: bool) -> String {
273273
get_closest_merge_commit(
274274
Some(&config.src),
275275
&config.git_config(),
276-
&[config.src.join("src/gcc"), config.src.join("src/bootstrap/download-ci-gcc-stamp")],
276+
&["src/gcc", "src/bootstrap/download-ci-gcc-stamp"],
277277
)
278278
.unwrap()
279279
} else if let Some(info) = crate::utils::channel::read_commit_info_file(&config.src) {

Diff for: src/bootstrap/src/core/build_steps/llvm.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,19 @@ 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
/// This retrieves the LLVM sha we *want* to use, according to git history.
178186
pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
179187
let llvm_sha = if is_git {
180-
get_closest_merge_commit(
181-
Some(&config.src),
182-
&config.git_config(),
183-
&[
184-
config.src.join("src/llvm-project"),
185-
config.src.join("src/bootstrap/download-ci-llvm-stamp"),
186-
// the LLVM shared object file is named `LLVM-12-rust-{version}-nightly`
187-
config.src.join("src/version"),
188-
],
189-
)
190-
.unwrap()
188+
get_closest_merge_commit(Some(&config.src), &config.git_config(), LLVM_INVALIDATION_PATHS)
189+
.unwrap()
191190
} else if let Some(info) = crate::utils::channel::read_commit_info_file(&config.src) {
192191
info.sha.trim().to_owned()
193192
} else {

Diff for: src/bootstrap/src/core/config/config.rs

+3-2
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;
@@ -3109,9 +3110,9 @@ impl Config {
31093110
#[cfg(not(test))]
31103111
self.update_submodule("src/llvm-project");
31113112

3112-
// Check for untracked changes in `src/llvm-project`.
3113+
// Check for untracked changes in `src/llvm-project` and other important places.
31133114
let has_changes = self
3114-
.last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true)
3115+
.last_modified_commit(LLVM_INVALIDATION_PATHS, "download-ci-llvm", true)
31153116
.is_none();
31163117

31173118
// Return false if there are untracked changes, otherwise check if CI LLVM is available.

Diff for: src/bootstrap/src/core/config/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use super::flags::Flags;
1212
use super::{ChangeIdWrapper, Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
1313
use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
1414
use crate::core::build_steps::llvm;
15+
use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
1516
use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig};
1617

1718
pub(crate) fn parse(config: &str) -> Config {
@@ -41,7 +42,7 @@ fn download_ci_llvm() {
4142
let if_unchanged_config = parse("llvm.download-ci-llvm = \"if-unchanged\"");
4243
if if_unchanged_config.llvm_from_ci {
4344
let has_changes = if_unchanged_config
44-
.last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true)
45+
.last_modified_commit(LLVM_INVALIDATION_PATHS, "download-ci-llvm", true)
4546
.is_none();
4647

4748
assert!(

Diff for: src/build_helper/src/git.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::path::{Path, PathBuf};
1+
use std::path::Path;
22
use std::process::{Command, Stdio};
33

44
use crate::ci::CiEnv;
@@ -121,7 +121,7 @@ fn git_upstream_merge_base(
121121
pub fn get_closest_merge_commit(
122122
git_dir: Option<&Path>,
123123
config: &GitConfig<'_>,
124-
target_paths: &[PathBuf],
124+
target_paths: &[&str],
125125
) -> Result<String, String> {
126126
let mut git = Command::new("git");
127127

0 commit comments

Comments
 (0)