Skip to content

Commit

Permalink
make llvm::is_ci_llvm_modified logic more precise
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Oct 5, 2024
1 parent 11ee3a8 commit 8c6afa9
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,30 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {

/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool {
CiEnv::is_rust_lang_managed_ci_job() && config.rust_info.is_managed_git_subrepository() && {
// We assume we have access to git, so it's okay to unconditionally pass
// `true` here.
let llvm_sha = detect_llvm_sha(config, true);
let head_sha =
output(helpers::git(Some(&config.src)).arg("rev-parse").arg("HEAD").as_command_mut());
let head_sha = head_sha.trim();
llvm_sha == head_sha
// If not running in a CI environment, return false.
if !CiEnv::is_ci() {
return false;
}

// In rust-lang/rust managed CI, ensure the LLVM submodule is present.
if CiEnv::is_rust_lang_managed_ci_job() {
config.update_submodule("src/llvm-project");
}

// If LLVM submodule isn't present, skip the change check as it won't work.
// This doesn't happen in rust-lang/rust CI because we force fetching LLVM
// submodule above.
if !config.in_tree_llvm_info.is_managed_git_subrepository() {
return false;
}

// We assume we have access to git (as this runs in CI), so it's okay
// to unconditionally pass `true` here.
let llvm_sha = detect_llvm_sha(config, true);
let head_sha =
output(helpers::git(Some(&config.src)).arg("rev-parse").arg("HEAD").as_command_mut());
let head_sha = head_sha.trim();
llvm_sha == head_sha
}

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

0 comments on commit 8c6afa9

Please sign in to comment.