@@ -20,10 +20,9 @@ use build_helper::git::get_closest_merge_commit;
2020
2121use crate :: core:: builder:: { Builder , RunConfig , ShouldRun , Step } ;
2222use crate :: core:: config:: { Config , TargetSelection } ;
23- use crate :: utils:: channel;
2423use crate :: utils:: exec:: command;
2524use 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,
2726} ;
2827use crate :: { CLang , GitRepo , Kind , generate_smart_stamp_hash} ;
2928
@@ -166,7 +165,7 @@ pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
166165 config. src . join ( "src/version" ) ,
167166 ] )
168167 . 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 ) {
170169 info. sha . trim ( ) . to_owned ( )
171170 } else {
172171 "" . to_owned ( )
@@ -242,15 +241,29 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
242241
243242/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
244243pub ( 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+ ) ;
253255 }
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
254267}
255268
256269#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
0 commit comments