diff options
| -rw-r--r-- | src/bootstrap/src/core/build_steps/gcc.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/llvm.rs | 21 | ||||
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 5 | ||||
| -rw-r--r-- | src/bootstrap/src/core/config/tests.rs | 3 | ||||
| -rw-r--r-- | src/build_helper/src/git.rs | 4 |
5 files changed, 18 insertions, 17 deletions
diff --git a/src/bootstrap/src/core/build_steps/gcc.rs b/src/bootstrap/src/core/build_steps/gcc.rs index b88a5f2bbf1..48bb5cb8e87 100644 --- a/src/bootstrap/src/core/build_steps/gcc.rs +++ b/src/bootstrap/src/core/build_steps/gcc.rs @@ -273,7 +273,7 @@ fn detect_gcc_sha(config: &crate::Config, is_git: bool) -> String { get_closest_merge_commit( Some(&config.src), &config.git_config(), - &[config.src.join("src/gcc"), config.src.join("src/bootstrap/download-ci-gcc-stamp")], + &["src/gcc", "src/bootstrap/download-ci-gcc-stamp"], ) .unwrap() } else if let Some(info) = crate::utils::channel::read_commit_info_file(&config.src) { diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 0ae5256a18f..efecca6ebdd 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -174,20 +174,19 @@ pub fn prebuilt_llvm_config( LlvmBuildStatus::ShouldBuild(Meta { stamp, res, out_dir, root: root.into() }) } +/// Paths whose changes invalidate LLVM downloads. +pub const LLVM_INVALIDATION_PATHS: &[&str] = &[ + "src/llvm-project", + "src/bootstrap/download-ci-llvm-stamp", + // the LLVM shared object file is named `LLVM-<LLVM-version>-rust-{version}-nightly` + "src/version", +]; + /// This retrieves the LLVM sha we *want* to use, according to git history. pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String { let llvm_sha = if is_git { - get_closest_merge_commit( - Some(&config.src), - &config.git_config(), - &[ - config.src.join("src/llvm-project"), - config.src.join("src/bootstrap/download-ci-llvm-stamp"), - // the LLVM shared object file is named `LLVM-12-rust-{version}-nightly` - config.src.join("src/version"), - ], - ) - .unwrap() + get_closest_merge_commit(Some(&config.src), &config.git_config(), LLVM_INVALIDATION_PATHS) + .unwrap() } else if let Some(info) = crate::utils::channel::read_commit_info_file(&config.src) { info.sha.trim().to_owned() } else { diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 2b8c1f49afb..dfd64c3246d 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -23,6 +23,7 @@ use tracing::{instrument, span}; use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX; use crate::core::build_steps::llvm; +use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS; pub use crate::core::config::flags::Subcommand; use crate::core::config::flags::{Color, Flags, Warnings}; use crate::core::download::is_download_ci_available; @@ -3109,9 +3110,9 @@ impl Config { #[cfg(not(test))] self.update_submodule("src/llvm-project"); - // Check for untracked changes in `src/llvm-project`. + // Check for untracked changes in `src/llvm-project` and other important places. let has_changes = self - .last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true) + .last_modified_commit(LLVM_INVALIDATION_PATHS, "download-ci-llvm", true) .is_none(); // Return false if there are untracked changes, otherwise check if CI LLVM is available. diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs index fb2c52966eb..6f21016ea74 100644 --- a/src/bootstrap/src/core/config/tests.rs +++ b/src/bootstrap/src/core/config/tests.rs @@ -12,6 +12,7 @@ use super::flags::Flags; use super::{ChangeIdWrapper, Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS}; use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order}; use crate::core::build_steps::llvm; +use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS; use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig}; pub(crate) fn parse(config: &str) -> Config { @@ -41,7 +42,7 @@ fn download_ci_llvm() { let if_unchanged_config = parse("llvm.download-ci-llvm = \"if-unchanged\""); if if_unchanged_config.llvm_from_ci { let has_changes = if_unchanged_config - .last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true) + .last_modified_commit(LLVM_INVALIDATION_PATHS, "download-ci-llvm", true) .is_none(); assert!( diff --git a/src/build_helper/src/git.rs b/src/build_helper/src/git.rs index 9f778a2fd77..bdec54a7741 100644 --- a/src/build_helper/src/git.rs +++ b/src/build_helper/src/git.rs @@ -1,4 +1,4 @@ -use std::path::{Path, PathBuf}; +use std::path::Path; use std::process::{Command, Stdio}; use crate::ci::CiEnv; @@ -121,7 +121,7 @@ fn git_upstream_merge_base( pub fn get_closest_merge_commit( git_dir: Option<&Path>, config: &GitConfig<'_>, - target_paths: &[PathBuf], + target_paths: &[&str], ) -> Result<String, String> { let mut git = Command::new("git"); |
