@@ -242,15 +242,30 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
242
242
243
243
/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
244
244
pub ( crate ) fn is_ci_llvm_modified ( config : & Config ) -> bool {
245
- CiEnv :: is_rust_lang_managed_ci_job ( ) && config . rust_info . is_managed_git_subrepository ( ) && {
246
- // We assume we have access to git, so it's okay to unconditionally pass
247
- // `true` here.
248
- let llvm_sha = detect_llvm_sha ( config , true ) ;
249
- let head_sha =
250
- output ( helpers :: git ( Some ( & config . src ) ) . arg ( "rev-parse" ) . arg ( "HEAD" ) . as_command_mut ( ) ) ;
251
- let head_sha = head_sha . trim ( ) ;
252
- llvm_sha == head_sha
245
+ // If not running in a CI environment, return false.
246
+ if ! CiEnv :: is_ci ( ) {
247
+ return false ;
248
+ }
249
+
250
+ // In rust-lang/rust managed CI, ensure the LLVM submodule is present.
251
+ if CiEnv :: is_rust_lang_managed_ci_job ( ) {
252
+ config . update_submodule ( "src/llvm-project" ) ;
253
253
}
254
+
255
+ // If LLVM submodule isn't present, skip the change check as it won't work.
256
+ // This doesn't happen in rust-lang/rust CI because we force fetching LLVM
257
+ // submodule above.
258
+ if !config. in_tree_llvm_info . is_managed_git_subrepository ( ) {
259
+ return false ;
260
+ }
261
+
262
+ // We assume we have access to git (as this runs in CI), so it's okay
263
+ // to unconditionally pass `true` here.
264
+ let llvm_sha = detect_llvm_sha ( config, true ) ;
265
+ let head_sha =
266
+ output ( helpers:: git ( Some ( & config. src ) ) . arg ( "rev-parse" ) . arg ( "HEAD" ) . as_command_mut ( ) ) ;
267
+ let head_sha = head_sha. trim ( ) ;
268
+ llvm_sha == head_sha
254
269
}
255
270
256
271
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
0 commit comments