From 6658c8e2449fb6a674ac606823e43c44f3caf275 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sun, 15 Sep 2024 07:43:16 +0300 Subject: [PATCH] check if the LLVM submodule is fetched in `is_ci_llvm_modified` Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/llvm.rs | 12 +++++++++++- src/bootstrap/src/lib.rs | 2 -- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 08e24ecc3401a..81a48000cf145 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -241,7 +241,17 @@ 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_ci() && config.rust_info.is_managed_git_subrepository() && { + // If the LLVM submodule is unavailable (which is the case when `llvm.download-ci-llvm` is set to true), + // LLVM cannot be modified which means it is unnecessary to run the git logic below. + // + // This is very unlikely to happen on our (rust-lang/rust) CI runners, as we intentionally fetch all + // submodules in CI and most of the time (probably always) prefer `llvm.download-ci-llvm` to be set + // to "if-unchanged" or true. + if config.in_tree_llvm_info.is_managed_git_subrepository() { + return false; + } + + CiEnv::is_ci() && { // We assume we have access to git, so it's okay to unconditionally pass // `true` here. let llvm_sha = detect_llvm_sha(config, true); diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 6467f4e35910d..9a48b7d36d9a4 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -312,8 +312,6 @@ impl Build { let miri_info = config.miri_info.clone(); let rustfmt_info = config.rustfmt_info.clone(); let enzyme_info = config.enzyme_info.clone(); - - // we always try to use git for LLVM builds let in_tree_llvm_info = config.in_tree_llvm_info.clone(); let in_tree_gcc_info = config.in_tree_gcc_info.clone();