Skip to content

Commit 8c6afa9

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

File tree

1 file changed

+23
-8
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+23
-8
lines changed

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

+23-8
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,30 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
242242

243243
/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
244244
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
245+
// If not running in a CI environment, return false.
246+
if !CiEnv::is_ci() {
247+
return false;
248+
}
249+
250+
// In rust-lang/rust managed CI, ensure the LLVM submodule is present.
251+
if CiEnv::is_rust_lang_managed_ci_job() {
252+
config.update_submodule("src/llvm-project");
253253
}
254+
255+
// If LLVM submodule isn't present, skip the change check as it won't work.
256+
// This doesn't happen in rust-lang/rust CI because we force fetching LLVM
257+
// submodule above.
258+
if !config.in_tree_llvm_info.is_managed_git_subrepository() {
259+
return false;
260+
}
261+
262+
// We assume we have access to git (as this runs in CI), so it's okay
263+
// to unconditionally pass `true` here.
264+
let llvm_sha = detect_llvm_sha(config, true);
265+
let head_sha =
266+
output(helpers::git(Some(&config.src)).arg("rev-parse").arg("HEAD").as_command_mut());
267+
let head_sha = head_sha.trim();
268+
llvm_sha == head_sha
254269
}
255270

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

0 commit comments

Comments
 (0)