@@ -1021,38 +1021,23 @@ fn add_local_native_libraries(cmd: &mut Linker, sess: &Session) {
1021
1021
}
1022
1022
} ) ;
1023
1023
1024
- let pair = sess. cstore . used_libraries ( ) . into_iter ( ) . filter ( |l| {
1024
+ let libs = sess. cstore . used_libraries ( ) . into_iter ( ) . filter ( |l| {
1025
1025
relevant_lib ( sess, l)
1026
- } ) . partition ( |lib| {
1027
- lib. kind == NativeLibraryKind :: NativeStatic
1028
1026
} ) ;
1029
- let ( staticlibs, others) : ( Vec < _ > , Vec < _ > ) = pair;
1030
-
1031
- // Some platforms take hints about whether a library is static or dynamic.
1032
- // For those that support this, we ensure we pass the option if the library
1033
- // was flagged "static" (most defaults are dynamic) to ensure that if
1034
- // libfoo.a and libfoo.so both exist that the right one is chosen.
1035
- cmd. hint_static ( ) ;
1036
-
1037
- let search_path = archive_search_paths ( sess) ;
1038
- for l in staticlibs {
1039
- // Here we explicitly ask that the entire archive is included into the
1040
- // result artifact. For more details see #15460, but the gist is that
1041
- // the linker will strip away any unused objects in the archive if we
1042
- // don't otherwise explicitly reference them. This can occur for
1043
- // libraries which are just providing bindings, libraries with generic
1044
- // functions, etc.
1045
- cmd. link_whole_staticlib ( & l. name . as_str ( ) , & search_path) ;
1046
- }
1047
-
1048
- cmd. hint_dynamic ( ) ;
1049
1027
1050
- for lib in others {
1028
+ for lib in libs {
1051
1029
match lib. kind {
1052
1030
NativeLibraryKind :: NativeUnknown => cmd. link_dylib ( & lib. name . as_str ( ) ) ,
1053
1031
NativeLibraryKind :: NativeFramework => cmd. link_framework ( & lib. name . as_str ( ) ) ,
1054
- NativeLibraryKind :: NativeStaticNobundle => cmd. link_staticlib ( & lib. name . as_str ( ) ) ,
1055
- NativeLibraryKind :: NativeStatic => bug ! ( ) ,
1032
+ NativeLibraryKind :: NativeStaticNobundle | NativeLibraryKind :: NativeStatic => {
1033
+ // Some platforms take hints about whether a library is static or dynamic.
1034
+ // For those that support this, we ensure we pass the option if the library
1035
+ // was flagged "static" (most defaults are dynamic) to ensure that if
1036
+ // libfoo.a and libfoo.so both exist that the right one is chosen.
1037
+ cmd. hint_static ( ) ;
1038
+ cmd. link_staticlib ( & lib. name . as_str ( ) ) ;
1039
+ cmd. hint_dynamic ( ) ;
1040
+ }
1056
1041
}
1057
1042
}
1058
1043
}
@@ -1338,7 +1323,9 @@ fn add_upstream_native_libraries(cmd: &mut Linker, sess: &Session, crate_type: c
1338
1323
// or is an rlib already included via some other dylib crate, the symbols from
1339
1324
// native libs will have already been included in that dylib.
1340
1325
if data[ cnum. as_usize ( ) - 1 ] == Linkage :: Static {
1341
- cmd. link_staticlib ( & lib. name . as_str ( ) )
1326
+ cmd. hint_static ( ) ;
1327
+ cmd. link_staticlib ( & lib. name . as_str ( ) ) ;
1328
+ cmd. hint_dynamic ( ) ;
1342
1329
}
1343
1330
} ,
1344
1331
// ignore statically included native libraries here as we've
0 commit comments