@@ -306,8 +306,10 @@ impl<'a> GccLinker<'a> {
306
306
if let Some ( path) = & self . sess . opts . debugging_opts . profile_sample_use {
307
307
self . linker_arg ( & format ! ( "-plugin-opt=sample-profile={}" , path. display( ) ) ) ;
308
308
} ;
309
- self . linker_arg ( & format ! ( "-plugin-opt={}" , opt_level) ) ;
310
- self . linker_arg ( & format ! ( "-plugin-opt=mcpu={}" , self . target_cpu) ) ;
309
+ self . linker_args ( & [
310
+ & format ! ( "-plugin-opt={}" , opt_level) ,
311
+ & format ! ( "-plugin-opt=mcpu={}" , self . target_cpu) ,
312
+ ] ) ;
311
313
}
312
314
313
315
fn build_dylib ( & mut self , out_filename : & Path ) {
@@ -321,10 +323,9 @@ impl<'a> GccLinker<'a> {
321
323
// principled solution at some point to force the compiler to pass
322
324
// the right `-Wl,-install_name` with an `@rpath` in it.
323
325
if self . sess . opts . cg . rpath || self . sess . opts . debugging_opts . osx_rpath_install_name {
324
- self . linker_arg ( "-install_name" ) ;
325
- let mut v = OsString :: from ( "@rpath/" ) ;
326
- v. push ( out_filename. file_name ( ) . unwrap ( ) ) ;
327
- self . linker_arg ( & v) ;
326
+ let mut rpath = OsString :: from ( "@rpath/" ) ;
327
+ rpath. push ( out_filename. file_name ( ) . unwrap ( ) ) ;
328
+ self . linker_args ( & [ OsString :: from ( "-install_name" ) , rpath] ) ;
328
329
}
329
330
} else {
330
331
self . cmd . arg ( "-shared" ) ;
@@ -398,8 +399,7 @@ impl<'a> Linker for GccLinker<'a> {
398
399
self . build_dylib ( out_filename) ;
399
400
}
400
401
LinkOutputKind :: WasiReactorExe => {
401
- self . linker_arg ( "--entry" ) ;
402
- self . linker_arg ( "_initialize" ) ;
402
+ self . linker_args ( & [ "--entry" , "_initialize" ] ) ;
403
403
}
404
404
}
405
405
// VxWorks compiler driver introduced `--static-crt` flag specifically for rustc,
@@ -471,8 +471,7 @@ impl<'a> Linker for GccLinker<'a> {
471
471
self . cmd . arg ( path) ;
472
472
}
473
473
fn full_relro ( & mut self ) {
474
- self . linker_arg ( "-zrelro" ) ;
475
- self . linker_arg ( "-znow" ) ;
474
+ self . linker_args ( & [ "-zrelro" , "-znow" ] ) ;
476
475
}
477
476
fn partial_relro ( & mut self ) {
478
477
self . linker_arg ( "-zrelro" ) ;
@@ -656,7 +655,6 @@ impl<'a> Linker for GccLinker<'a> {
656
655
}
657
656
658
657
let is_windows = self . sess . target . is_like_windows ;
659
- let mut arg = OsString :: new ( ) ;
660
658
let path = tmpdir. join ( if is_windows { "list.def" } else { "list" } ) ;
661
659
662
660
debug ! ( "EXPORTED SYMBOLS:" ) ;
@@ -708,27 +706,18 @@ impl<'a> Linker for GccLinker<'a> {
708
706
}
709
707
710
708
if self . sess . target . is_like_osx {
711
- if !self . is_ld {
712
- arg. push ( "-Wl," )
713
- }
714
- arg. push ( "-exported_symbols_list," ) ;
709
+ self . linker_args ( & [ OsString :: from ( "-exported_symbols_list" ) , path. into ( ) ] ) ;
715
710
} else if self . sess . target . is_like_solaris {
716
- if !self . is_ld {
717
- arg. push ( "-Wl," )
718
- }
719
- arg. push ( "-M," ) ;
711
+ self . linker_args ( & [ OsString :: from ( "-M" ) , path. into ( ) ] ) ;
720
712
} else {
721
- if ! self . is_ld {
722
- arg . push ( "-Wl," )
723
- }
724
- // Both LD and LLD accept export list in *.def file form, there are no flags required
725
- if !is_windows {
726
- arg . push ( "--version-script=" )
713
+ if is_windows {
714
+ self . linker_arg ( path ) ;
715
+ } else {
716
+ let mut arg = OsString :: from ( "--version-script=" ) ;
717
+ arg . push ( path ) ;
718
+ self . linker_arg ( arg ) ;
727
719
}
728
720
}
729
-
730
- arg. push ( & path) ;
731
- self . cmd . arg ( arg) ;
732
721
}
733
722
734
723
fn subsystem ( & mut self , subsystem : & str ) {
@@ -786,8 +775,7 @@ impl<'a> Linker for GccLinker<'a> {
786
775
self . linker_arg ( "--as-needed" ) ;
787
776
} else if self . sess . target . is_like_solaris {
788
777
// -z ignore is the Solaris equivalent to the GNU ld --as-needed option
789
- self . linker_arg ( "-z" ) ;
790
- self . linker_arg ( "ignore" ) ;
778
+ self . linker_args ( & [ "-z" , "ignore" ] ) ;
791
779
}
792
780
}
793
781
}
0 commit comments