@@ -1315,7 +1315,14 @@ impl Config {
13151315 ) ;
13161316 }
13171317
1318- if config. lld_enabled && config. is_system_llvm ( config. host_target ) {
1318+ if config. lld_enabled
1319+ && is_system_llvm (
1320+ & config. host_target ,
1321+ config. llvm_from_ci ,
1322+ & config. target_config ,
1323+ config. host_target ,
1324+ )
1325+ {
13191326 panic ! ( "Cannot enable LLD with `rust.lld = true` when using external llvm-config." ) ;
13201327 }
13211328
@@ -2705,3 +2712,28 @@ pub fn submodules_(submodules: &Option<bool>, rust_info: &channel::GitInfo) -> b
27052712 // submodules if we're currently inside a git repository.
27062713 submodules. unwrap_or ( rust_info. is_managed_git_subrepository ( ) )
27072714}
2715+
2716+ /// Returns `true` if this is an external version of LLVM not managed by bootstrap.
2717+ /// In particular, we expect llvm sources to be available when this is false.
2718+ ///
2719+ /// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set.
2720+ pub fn is_system_llvm (
2721+ host_target : & TargetSelection ,
2722+ llvm_from_ci : bool ,
2723+ target_config : & HashMap < TargetSelection , Target > ,
2724+ target : TargetSelection ,
2725+ ) -> bool {
2726+ match target_config. get ( & target) {
2727+ Some ( Target { llvm_config : Some ( _) , .. } ) => {
2728+ let ci_llvm = llvm_from_ci && is_host_target ( host_target, & target) ;
2729+ !ci_llvm
2730+ }
2731+ // We're building from the in-tree src/llvm-project sources.
2732+ Some ( Target { llvm_config : None , .. } ) => false ,
2733+ None => false ,
2734+ }
2735+ }
2736+
2737+ pub fn is_host_target ( host_target : & TargetSelection , target : & TargetSelection ) -> bool {
2738+ host_target == target
2739+ }
0 commit comments