@@ -87,10 +87,14 @@ impl LdFlags {
8787///
8888/// This will return the llvm-config if it can get it (but it will not build it
8989/// 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 {
9498 builder. config . maybe_download_ci_llvm ( ) ;
9599
96100 // 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
109113 }
110114 }
111115
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+ }
115120
116121 let root = "src/llvm-project/llvm" ;
117122 let out_dir = builder. llvm_out ( target) ;
@@ -284,7 +289,7 @@ impl Step for Llvm {
284289 } ;
285290
286291 // 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 ) {
288293 LlvmBuildStatus :: AlreadyBuilt ( p) => return p,
289294 LlvmBuildStatus :: ShouldBuild ( m) => m,
290295 } ;
0 commit comments