Skip to content

Commit ef51577

Browse files
committed
make llvm::is_ci_llvm_modified logic more precise
Signed-off-by: onur-ozkan <[email protected]>
1 parent 11ee3a8 commit ef51577

File tree

1 file changed

+24
-11
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+24
-11
lines changed

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

+24-11
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ use build_helper::git::get_closest_merge_commit;
2020

2121
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2222
use crate::core::config::{Config, TargetSelection};
23-
use crate::utils::channel;
2423
use crate::utils::exec::command;
2524
use crate::utils::helpers::{
26-
self, HashStamp, exe, get_clang_cl_resource_dir, output, t, unhashed_basename, up_to_date,
25+
self, HashStamp, exe, get_clang_cl_resource_dir, t, unhashed_basename, up_to_date,
2726
};
2827
use crate::{CLang, GitRepo, Kind, generate_smart_stamp_hash};
2928

@@ -166,7 +165,7 @@ pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
166165
config.src.join("src/version"),
167166
])
168167
.unwrap()
169-
} else if let Some(info) = channel::read_commit_info_file(&config.src) {
168+
} else if let Some(info) = crate::utils::channel::read_commit_info_file(&config.src) {
170169
info.sha.trim().to_owned()
171170
} else {
172171
"".to_owned()
@@ -242,15 +241,29 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
242241

243242
/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
244243
pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool {
245-
CiEnv::is_rust_lang_managed_ci_job() && config.rust_info.is_managed_git_subrepository() && {
246-
// We assume we have access to git, so it's okay to unconditionally pass
247-
// `true` here.
248-
let llvm_sha = detect_llvm_sha(config, true);
249-
let head_sha =
250-
output(helpers::git(Some(&config.src)).arg("rev-parse").arg("HEAD").as_command_mut());
251-
let head_sha = head_sha.trim();
252-
llvm_sha == head_sha
244+
// If not running in a CI environment, return false.
245+
if !CiEnv::is_ci() {
246+
return false;
247+
}
248+
249+
// In rust-lang/rust managed CI, assert the existence of the LLVM submodule.
250+
if CiEnv::is_rust_lang_managed_ci_job() {
251+
assert!(
252+
config.in_tree_llvm_info.is_managed_git_subrepository(),
253+
"LLVM submodule must be fetched in rust-lang/rust managed CI builders."
254+
);
253255
}
256+
// If LLVM submodule isn't present, skip the change check as it won't work.
257+
else if !config.in_tree_llvm_info.is_managed_git_subrepository() {
258+
return false;
259+
}
260+
261+
let llvm_sha = detect_llvm_sha(config, true);
262+
let head_sha = crate::output(
263+
helpers::git(Some(&config.src)).arg("rev-parse").arg("HEAD").as_command_mut(),
264+
);
265+
let head_sha = head_sha.trim();
266+
llvm_sha == head_sha
254267
}
255268

256269
#[derive(Debug, Clone, Hash, PartialEq, Eq)]

0 commit comments

Comments
 (0)