@@ -20,10 +20,9 @@ use build_helper::git::get_closest_merge_commit;
20
20
21
21
use crate :: core:: builder:: { Builder , RunConfig , ShouldRun , Step } ;
22
22
use crate :: core:: config:: { Config , TargetSelection } ;
23
- use crate :: utils:: channel;
24
23
use crate :: utils:: exec:: command;
25
24
use crate :: utils:: helpers:: {
26
- self , HashStamp , exe, get_clang_cl_resource_dir, output , t, unhashed_basename, up_to_date,
25
+ self , HashStamp , exe, get_clang_cl_resource_dir, t, unhashed_basename, up_to_date,
27
26
} ;
28
27
use crate :: { CLang , GitRepo , Kind , generate_smart_stamp_hash} ;
29
28
@@ -166,7 +165,7 @@ pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
166
165
config. src . join ( "src/version" ) ,
167
166
] )
168
167
. unwrap ( )
169
- } else if let Some ( info) = channel:: read_commit_info_file ( & config. src ) {
168
+ } else if let Some ( info) = crate :: utils :: channel:: read_commit_info_file ( & config. src ) {
170
169
info. sha . trim ( ) . to_owned ( )
171
170
} else {
172
171
"" . to_owned ( )
@@ -242,15 +241,29 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
242
241
243
242
/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
244
243
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
244
+ // If not running in a CI environment, return false.
245
+ if !CiEnv :: is_ci ( ) {
246
+ return false ;
247
+ }
248
+
249
+ // In rust-lang/rust managed CI, assert the existence of the LLVM submodule.
250
+ if CiEnv :: is_rust_lang_managed_ci_job ( ) {
251
+ assert ! (
252
+ config. in_tree_llvm_info. is_managed_git_subrepository( ) ,
253
+ "LLVM submodule must be fetched in rust-lang/rust managed CI builders."
254
+ ) ;
253
255
}
256
+ // If LLVM submodule isn't present, skip the change check as it won't work.
257
+ else if !config. in_tree_llvm_info . is_managed_git_subrepository ( ) {
258
+ return false ;
259
+ }
260
+
261
+ let llvm_sha = detect_llvm_sha ( config, true ) ;
262
+ let head_sha = crate :: output (
263
+ helpers:: git ( Some ( & config. src ) ) . arg ( "rev-parse" ) . arg ( "HEAD" ) . as_command_mut ( ) ,
264
+ ) ;
265
+ let head_sha = head_sha. trim ( ) ;
266
+ llvm_sha == head_sha
254
267
}
255
268
256
269
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
0 commit comments