Skip to content

Commit

Permalink
improve LLVM submodule handling logic in llvm::prebuilt_llvm_config
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Sep 27, 2024
1 parent 76ed7a1 commit a126c56
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ impl LdFlags {
/// This will return the llvm-config if it can get it (but it will not build it
/// if not).
pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> LlvmBuildStatus {
// If we have llvm submodule initialized already, sync it.
builder.update_existing_submodule("src/llvm-project");

builder.config.maybe_download_ci_llvm();

// If we're using a custom LLVM bail out here, but we can only use a
Expand All @@ -109,9 +106,16 @@ pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> L
}
}

// Initialize the llvm submodule if not initialized already.
// If submodules are disabled, this does nothing.
builder.config.update_submodule("src/llvm-project");
// Although we check if we are using CI LLVM above, certain commands (like `x test mir-opt --bless`)
// may call this function with different targets, which could bypass the condition above. Therefore,
// we need to check again whether we are not using CI LLVM before fetching the LLVM submodule.
//
// Note: `Build::update_existing_submodule` is not used intentionally as we want to fetch the submodule
// for non-ci LLVM cases.
if !builder.config.llvm_from_ci {
// If submodules are disabled, this does nothing.
builder.config.update_submodule("src/llvm-project");
}

let root = "src/llvm-project/llvm";
let out_dir = builder.llvm_out(target);
Expand Down

0 comments on commit a126c56

Please sign in to comment.