@@ -489,19 +489,19 @@ impl<'a> Linker for GccLinker<'a> {
489
489
search_paths : & SearchPaths ,
490
490
) {
491
491
self . hint_static ( ) ;
492
+ let colon = if verbatim && self . is_gnu { ":" } else { "" } ;
492
493
if !whole_archive {
493
- self . cmd . arg ( format ! ( "-l{}{name}" , if verbatim && self . is_gnu { ":" } else { "" } ) ) ;
494
- } else if !self . sess . target . is_like_osx {
495
- self . linker_arg ( "--whole-archive" ) ;
496
- self . cmd . arg ( format ! ( "-l{}{name}" , if verbatim && self . is_gnu { ":" } else { "" } ) ) ;
497
- self . linker_arg ( "--no-whole-archive" ) ;
498
- } else {
494
+ self . cmd . arg ( format ! ( "-l{colon}{name}" ) ) ;
495
+ } else if self . sess . target . is_like_osx {
499
496
// -force_load is the macOS equivalent of --whole-archive, but it
500
497
// involves passing the full path to the library to link.
501
498
self . linker_arg ( "-force_load" ) ;
502
- let lib =
503
- find_native_static_library ( name, verbatim, search_paths. get ( self . sess ) , self . sess ) ;
504
- self . linker_arg ( & lib) ;
499
+ let search_paths = search_paths. get ( self . sess ) ;
500
+ self . linker_arg ( find_native_static_library ( name, verbatim, search_paths, self . sess ) ) ;
501
+ } else {
502
+ self . linker_arg ( "--whole-archive" ) ;
503
+ self . cmd . arg ( format ! ( "-l{colon}{name}" ) ) ;
504
+ self . linker_arg ( "--no-whole-archive" ) ;
505
505
}
506
506
}
507
507
@@ -511,9 +511,10 @@ impl<'a> Linker for GccLinker<'a> {
511
511
self . cmd . arg ( path) ;
512
512
} else if self . sess . target . is_like_osx {
513
513
self . linker_arg ( "-force_load" ) ;
514
- self . linker_arg ( & path) ;
514
+ self . linker_arg ( path) ;
515
515
} else {
516
- self . linker_args ( & [ OsString :: from ( "--whole-archive" ) , path. into ( ) ] ) ;
516
+ self . linker_arg ( "--whole-archive" ) ;
517
+ self . linker_arg ( path) ;
517
518
self . linker_arg ( "--no-whole-archive" ) ;
518
519
}
519
520
}
@@ -830,11 +831,9 @@ impl<'a> Linker for MsvcLinker<'a> {
830
831
whole_archive : bool ,
831
832
_search_paths : & SearchPaths ,
832
833
) {
833
- if !whole_archive {
834
- self . cmd . arg ( format ! ( "{}{}" , name, if verbatim { "" } else { ".lib" } ) ) ;
835
- } else {
836
- self . cmd . arg ( format ! ( "/WHOLEARCHIVE:{}{}" , name, if verbatim { "" } else { ".lib" } ) ) ;
837
- }
834
+ let prefix = if whole_archive { "/WHOLEARCHIVE:" } else { "" } ;
835
+ let suffix = if verbatim { "" } else { ".lib" } ;
836
+ self . cmd . arg ( format ! ( "{prefix}{name}{suffix}" ) ) ;
838
837
}
839
838
840
839
fn link_staticlib_by_path ( & mut self , path : & Path , whole_archive : bool ) {
@@ -1066,7 +1065,7 @@ impl<'a> Linker for EmLinker<'a> {
1066
1065
}
1067
1066
1068
1067
fn link_staticlib_by_path ( & mut self , path : & Path , _whole_archive : bool ) {
1069
- self . add_object ( path) ;
1068
+ self . cmd . arg ( path) ;
1070
1069
}
1071
1070
1072
1071
fn include_path ( & mut self , path : & Path ) {
@@ -1398,8 +1397,7 @@ impl<'a> Linker for L4Bender<'a> {
1398
1397
if !whole_archive {
1399
1398
self . cmd . arg ( format ! ( "-PC{name}" ) ) ;
1400
1399
} else {
1401
- self . cmd . arg ( "--whole-archive" ) . arg ( format ! ( "-l{name}" ) ) ;
1402
- self . cmd . arg ( "--no-whole-archive" ) ;
1400
+ self . cmd . arg ( "--whole-archive" ) . arg ( format ! ( "-l{name}" ) ) . arg ( "--no-whole-archive" ) ;
1403
1401
}
1404
1402
}
1405
1403
@@ -1583,9 +1581,10 @@ impl<'a> Linker for AixLinker<'a> {
1583
1581
if !whole_archive {
1584
1582
self . cmd . arg ( format ! ( "-l{name}" ) ) ;
1585
1583
} else {
1586
- let lib =
1587
- find_native_static_library ( name, verbatim, search_paths. get ( self . sess ) , self . sess ) ;
1588
- self . cmd . arg ( format ! ( "-bkeepfile:{}" , lib. to_str( ) . unwrap( ) ) ) ;
1584
+ let mut arg = OsString :: from ( "-bkeepfile:" ) ;
1585
+ let search_path = search_paths. get ( self . sess ) ;
1586
+ arg. push ( find_native_static_library ( name, verbatim, search_path, self . sess ) ) ;
1587
+ self . cmd . arg ( arg) ;
1589
1588
}
1590
1589
}
1591
1590
@@ -1594,7 +1593,9 @@ impl<'a> Linker for AixLinker<'a> {
1594
1593
if !whole_archive {
1595
1594
self . cmd . arg ( path) ;
1596
1595
} else {
1597
- self . cmd . arg ( format ! ( "-bkeepfile:{}" , path. to_str( ) . unwrap( ) ) ) ;
1596
+ let mut arg = OsString :: from ( "-bkeepfile:" ) ;
1597
+ arg. push ( path) ;
1598
+ self . cmd . arg ( arg) ;
1598
1599
}
1599
1600
}
1600
1601
0 commit comments