File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -758,7 +758,7 @@ impl<'a> Builder<'a> {
758758 if let Some ( linker) = self . linker ( compiler. host ) {
759759 cmd. env ( "RUSTDOC_LINKER" , linker) ;
760760 }
761- if self . config . use_lld && ! compiler. host . contains ( "msvc" ) {
761+ if self . is_fuse_ld_lld ( compiler. host ) {
762762 cmd. env ( "RUSTDOC_FUSE_LD_LLD" , "1" ) ;
763763 }
764764 cmd
@@ -1047,16 +1047,15 @@ impl<'a> Builder<'a> {
10471047 if let Some ( host_linker) = self . linker ( compiler. host ) {
10481048 cargo. env ( "RUSTC_HOST_LINKER" , host_linker) ;
10491049 }
1050- if self . config . use_lld && ! compiler. host . contains ( "msvc" ) {
1050+ if self . is_fuse_ld_lld ( compiler. host ) {
10511051 cargo. env ( "RUSTC_HOST_FUSE_LD_LLD" , "1" ) ;
10521052 }
10531053
10541054 if let Some ( target_linker) = self . linker ( target) {
10551055 let target = crate :: envify ( & target. triple ) ;
10561056 cargo. env ( & format ! ( "CARGO_TARGET_{}_LINKER" , target) , target_linker) ;
10571057 }
1058-
1059- if self . config . use_lld && !target. contains ( "msvc" ) {
1058+ if self . is_fuse_ld_lld ( target) {
10601059 rustflags. arg ( "-Clink-args=-fuse-ld=lld" ) ;
10611060 }
10621061
Original file line number Diff line number Diff line change @@ -863,15 +863,19 @@ impl Build {
863863 && !target. contains ( "msvc" )
864864 {
865865 Some ( self . cc ( target) )
866- } else if target. contains ( "msvc" ) && self . config . use_lld && self . build == target {
867- // `rust.use_lld` means using LLD directly only for MSVC, for other targets it only
868- // adds `-fuse-ld=lld` to already selected linker.
866+ } else if self . config . use_lld && !self . is_fuse_ld_lld ( target) && self . build == target {
869867 Some ( & self . initial_lld )
870868 } else {
871869 None
872870 }
873871 }
874872
873+ // LLD is used through `-fuse-ld=lld` rather than directly.
874+ // Only MSVC targets use LLD directly at the moment.
875+ fn is_fuse_ld_lld ( & self , target : TargetSelection ) -> bool {
876+ self . config . use_lld && !target. contains ( "msvc" )
877+ }
878+
875879 /// Returns if this target should statically link the C runtime, if specified
876880 fn crt_static ( & self , target : TargetSelection ) -> Option < bool > {
877881 if target. contains ( "pc-windows-msvc" ) {
Original file line number Diff line number Diff line change @@ -603,7 +603,7 @@ impl Step for RustdocTheme {
603603 if let Some ( linker) = builder. linker ( self . compiler . host ) {
604604 cmd. env ( "RUSTDOC_LINKER" , linker) ;
605605 }
606- if builder. config . use_lld && ! self . compiler . host . contains ( "msvc" ) {
606+ if builder. is_fuse_ld_lld ( self . compiler . host ) {
607607 cmd. env ( "RUSTDOC_FUSE_LD_LLD" , "1" ) ;
608608 }
609609 try_run ( builder, & mut cmd) ;
@@ -1070,14 +1070,14 @@ impl Step for Compiletest {
10701070
10711071 let mut hostflags = flags. clone ( ) ;
10721072 hostflags. push ( format ! ( "-Lnative={}" , builder. test_helpers_out( compiler. host) . display( ) ) ) ;
1073- if builder. config . use_lld && ! compiler. host . triple . contains ( "msvc" ) {
1073+ if builder. is_fuse_ld_lld ( compiler. host ) {
10741074 hostflags. push ( "-Clink-args=-fuse-ld=lld" . to_string ( ) ) ;
10751075 }
10761076 cmd. arg ( "--host-rustcflags" ) . arg ( hostflags. join ( " " ) ) ;
10771077
10781078 let mut targetflags = flags;
10791079 targetflags. push ( format ! ( "-Lnative={}" , builder. test_helpers_out( target) . display( ) ) ) ;
1080- if builder. config . use_lld && !target . contains ( "msvc" ) {
1080+ if builder. is_fuse_ld_lld ( target ) {
10811081 targetflags. push ( "-Clink-args=-fuse-ld=lld" . to_string ( ) ) ;
10821082 }
10831083 cmd. arg ( "--target-rustcflags" ) . arg ( targetflags. join ( " " ) ) ;
You can’t perform that action at this time.
0 commit comments