Skip to content

Commit a126c56

Browse files
committed
improve LLVM submodule handling logic in llvm::prebuilt_llvm_config
Signed-off-by: onur-ozkan <[email protected]>
1 parent 76ed7a1 commit a126c56

File tree

1 file changed

+10
-6
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+10
-6
lines changed

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ impl LdFlags {
8888
/// This will return the llvm-config if it can get it (but it will not build it
8989
/// if not).
9090
pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> LlvmBuildStatus {
91-
// If we have llvm submodule initialized already, sync it.
92-
builder.update_existing_submodule("src/llvm-project");
93-
9491
builder.config.maybe_download_ci_llvm();
9592

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

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

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

0 commit comments

Comments
 (0)