@@ -1315,7 +1315,14 @@ impl Config {
1315
1315
) ;
1316
1316
}
1317
1317
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
+ {
1319
1326
panic ! ( "Cannot enable LLD with `rust.lld = true` when using external llvm-config." ) ;
1320
1327
}
1321
1328
@@ -2700,3 +2707,28 @@ pub fn submodules_(submodules: &Option<bool>, rust_info: &channel::GitInfo) -> b
2700
2707
// submodules if we're currently inside a git repository.
2701
2708
submodules. unwrap_or ( rust_info. is_managed_git_subrepository ( ) )
2702
2709
}
2710
+
2711
+ /// Returns `true` if this is an external version of LLVM not managed by bootstrap.
2712
+ /// In particular, we expect llvm sources to be available when this is false.
2713
+ ///
2714
+ /// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set.
2715
+ pub fn is_system_llvm (
2716
+ host_target : & TargetSelection ,
2717
+ llvm_from_ci : bool ,
2718
+ target_config : & HashMap < TargetSelection , Target > ,
2719
+ target : TargetSelection ,
2720
+ ) -> bool {
2721
+ match target_config. get ( & target) {
2722
+ Some ( Target { llvm_config : Some ( _) , .. } ) => {
2723
+ let ci_llvm = llvm_from_ci && is_host_target ( host_target, & target) ;
2724
+ !ci_llvm
2725
+ }
2726
+ // We're building from the in-tree src/llvm-project sources.
2727
+ Some ( Target { llvm_config : None , .. } ) => false ,
2728
+ None => false ,
2729
+ }
2730
+ }
2731
+
2732
+ pub fn is_host_target ( host_target : & TargetSelection , target : & TargetSelection ) -> bool {
2733
+ host_target == target
2734
+ }
0 commit comments