@@ -87,10 +87,14 @@ impl LdFlags {
87
87
///
88
88
/// This will return the llvm-config if it can get it (but it will not build it
89
89
/// if not).
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
-
90
+ pub fn prebuilt_llvm_config (
91
+ builder : & Builder < ' _ > ,
92
+ target : TargetSelection ,
93
+ // Certain commands (like `x test mir-opt --bless`) may call this function with different targets,
94
+ // which could bypass the CI LLVM early-return even if `builder.config.llvm_from_ci` is true.
95
+ // This flag should be `true` only if the caller needs the LLVM sources (e.g., if it will build LLVM).
96
+ handle_submodule_when_needed : bool ,
97
+ ) -> LlvmBuildStatus {
94
98
builder. config . maybe_download_ci_llvm ( ) ;
95
99
96
100
// If we're using a custom LLVM bail out here, but we can only use a
@@ -109,9 +113,10 @@ pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> L
109
113
}
110
114
}
111
115
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" ) ;
116
+ if handle_submodule_when_needed {
117
+ // If submodules are disabled, this does nothing.
118
+ builder. config . update_submodule ( "src/llvm-project" ) ;
119
+ }
115
120
116
121
let root = "src/llvm-project/llvm" ;
117
122
let out_dir = builder. llvm_out ( target) ;
@@ -284,7 +289,7 @@ impl Step for Llvm {
284
289
} ;
285
290
286
291
// If LLVM has already been built or been downloaded through download-ci-llvm, we avoid building it again.
287
- let Meta { stamp, res, out_dir, root } = match prebuilt_llvm_config ( builder, target) {
292
+ let Meta { stamp, res, out_dir, root } = match prebuilt_llvm_config ( builder, target, true ) {
288
293
LlvmBuildStatus :: AlreadyBuilt ( p) => return p,
289
294
LlvmBuildStatus :: ShouldBuild ( m) => m,
290
295
} ;
0 commit comments