@@ -954,45 +954,15 @@ impl Config {
954
954
}
955
955
}
956
956
957
- for ( target, linker_override) in default_linux_linker_overrides ( ) {
958
- // If the user overrode the default Linux linker, do not apply bootstrap defaults
959
- if targets_with_user_linker_override. contains ( & target) {
960
- continue ;
961
- }
962
- let default_linux_linker_override = match linker_override {
963
- DefaultLinuxLinkerOverride :: Off => continue ,
964
- DefaultLinuxLinkerOverride :: SelfContainedLldCc => {
965
- // If we automatically default to the self-contained LLD linker,
966
- // we also need to handle the rust.lld option.
967
- match rust_lld_enabled {
968
- // If LLD was not enabled explicitly, we enable it
969
- None => {
970
- lld_enabled = true ;
971
- Some ( DefaultLinuxLinkerOverride :: SelfContainedLldCc )
972
- }
973
- // If it was enabled already, we don't need to do anything
974
- Some ( true ) => Some ( DefaultLinuxLinkerOverride :: SelfContainedLldCc ) ,
975
- // If it was explicitly disabled, we do not apply the
976
- // linker override
977
- Some ( false ) => None ,
978
- }
979
- }
980
- } ;
981
- if let Some ( linker_override) = default_linux_linker_override {
982
- target_config
983
- . entry ( TargetSelection :: from_user ( & target) )
984
- . or_default ( )
985
- . default_linker_linux_override = linker_override;
986
- }
987
- }
988
-
989
957
let llvm_from_ci = parse_download_ci_llvm (
990
958
& dwn_ctx,
991
959
& rust_info,
992
960
& download_rustc_commit,
993
961
llvm_download_ci_llvm,
994
962
llvm_assertions,
995
963
) ;
964
+ let is_host_system_llvm =
965
+ is_system_llvm ( & target_config, llvm_from_ci, host_target, host_target) ;
996
966
997
967
if llvm_from_ci {
998
968
let warn = |option : & str | {
@@ -1040,6 +1010,41 @@ impl Config {
1040
1010
build_target. llvm_filecheck = Some ( ci_llvm_bin. join ( exe ( "FileCheck" , host_target) ) ) ;
1041
1011
}
1042
1012
1013
+ for ( target, linker_override) in default_linux_linker_overrides ( ) {
1014
+ // If the user overrode the default Linux linker, do not apply bootstrap defaults
1015
+ if targets_with_user_linker_override. contains ( & target) {
1016
+ continue ;
1017
+ }
1018
+
1019
+ let default_linux_linker_override = match linker_override {
1020
+ DefaultLinuxLinkerOverride :: Off => continue ,
1021
+ DefaultLinuxLinkerOverride :: SelfContainedLldCc => {
1022
+ // If we automatically default to the self-contained LLD linker,
1023
+ // we also need to handle the rust.lld option.
1024
+ match rust_lld_enabled {
1025
+ // If LLD was not enabled explicitly, we enable it, unless LLVM config has
1026
+ // been set
1027
+ None if !is_host_system_llvm => {
1028
+ lld_enabled = true ;
1029
+ Some ( DefaultLinuxLinkerOverride :: SelfContainedLldCc )
1030
+ }
1031
+ None => None ,
1032
+ // If it was enabled already, we don't need to do anything
1033
+ Some ( true ) => Some ( DefaultLinuxLinkerOverride :: SelfContainedLldCc ) ,
1034
+ // If it was explicitly disabled, we do not apply the
1035
+ // linker override
1036
+ Some ( false ) => None ,
1037
+ }
1038
+ }
1039
+ } ;
1040
+ if let Some ( linker_override) = default_linux_linker_override {
1041
+ target_config
1042
+ . entry ( TargetSelection :: from_user ( & target) )
1043
+ . or_default ( )
1044
+ . default_linker_linux_override = linker_override;
1045
+ }
1046
+ }
1047
+
1043
1048
let initial_rustfmt = build_rustfmt. or_else ( || maybe_download_rustfmt ( & dwn_ctx, & out) ) ;
1044
1049
1045
1050
if matches ! ( bootstrap_override_lld, BootstrapOverrideLld :: SelfContained )
@@ -1051,7 +1056,7 @@ impl Config {
1051
1056
) ;
1052
1057
}
1053
1058
1054
- if lld_enabled && is_system_llvm ( & dwn_ctx , & target_config , llvm_from_ci , host_target ) {
1059
+ if lld_enabled && is_host_system_llvm {
1055
1060
panic ! ( "Cannot enable LLD with `rust.lld = true` when using external llvm-config." ) ;
1056
1061
}
1057
1062
@@ -1845,8 +1850,7 @@ impl Config {
1845
1850
///
1846
1851
/// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set.
1847
1852
pub fn is_system_llvm ( & self , target : TargetSelection ) -> bool {
1848
- let dwn_ctx = DownloadContext :: from ( self ) ;
1849
- is_system_llvm ( dwn_ctx, & self . target_config , self . llvm_from_ci , target)
1853
+ is_system_llvm ( & self . target_config , self . llvm_from_ci , self . host_target , target)
1850
1854
}
1851
1855
1852
1856
/// Returns `true` if this is our custom, patched, version of LLVM.
@@ -2449,16 +2453,15 @@ pub fn submodules_(submodules: &Option<bool>, rust_info: &channel::GitInfo) -> b
2449
2453
/// In particular, we expect llvm sources to be available when this is false.
2450
2454
///
2451
2455
/// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set.
2452
- pub fn is_system_llvm < ' a > (
2453
- dwn_ctx : impl AsRef < DownloadContext < ' a > > ,
2456
+ pub fn is_system_llvm (
2454
2457
target_config : & HashMap < TargetSelection , Target > ,
2455
2458
llvm_from_ci : bool ,
2459
+ host_target : TargetSelection ,
2456
2460
target : TargetSelection ,
2457
2461
) -> bool {
2458
- let dwn_ctx = dwn_ctx. as_ref ( ) ;
2459
2462
match target_config. get ( & target) {
2460
2463
Some ( Target { llvm_config : Some ( _) , .. } ) => {
2461
- let ci_llvm = llvm_from_ci && is_host_target ( & dwn_ctx . host_target , & target) ;
2464
+ let ci_llvm = llvm_from_ci && is_host_target ( & host_target, & target) ;
2462
2465
!ci_llvm
2463
2466
}
2464
2467
// We're building from the in-tree src/llvm-project sources.
0 commit comments