@@ -88,9 +88,6 @@ impl LdFlags {
88
88
/// This will return the llvm-config if it can get it (but it will not build it
89
89
/// if not).
90
90
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
-
94
91
builder. config . maybe_download_ci_llvm ( ) ;
95
92
96
93
// 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
109
106
}
110
107
}
111
108
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
+ }
115
119
116
120
let root = "src/llvm-project/llvm" ;
117
121
let out_dir = builder. llvm_out ( target) ;
0 commit comments