@@ -1920,7 +1920,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
1920
1920
// This change is somewhat breaking in practice due to local static libraries being linked
1921
1921
// as whole-archive (#85144), so removing whole-archive may be a pre-requisite.
1922
1922
if sess. opts . debugging_opts . link_native_libraries {
1923
- add_local_native_libraries ( cmd, sess, codegen_results, crate_type ) ;
1923
+ add_local_native_libraries ( cmd, sess, codegen_results) ;
1924
1924
}
1925
1925
1926
1926
// Upstream rust libraries and their nobundle static libraries
@@ -2092,16 +2092,6 @@ fn add_order_independent_options(
2092
2092
add_rpath_args ( cmd, sess, codegen_results, out_filename) ;
2093
2093
}
2094
2094
2095
- // A dylib may reexport symbols from the linked rlib or native static library.
2096
- // Even if some symbol is reexported it's still not necessarily counted as used and may be
2097
- // dropped, at least with `ld`-like ELF linkers. So we have to link some rlibs and static
2098
- // libraries as whole-archive to avoid losing reexported symbols.
2099
- // FIXME: Find a way to mark reexported symbols as used and avoid this use of whole-archive.
2100
- fn default_to_whole_archive ( sess : & Session , crate_type : CrateType , cmd : & dyn Linker ) -> bool {
2101
- crate_type == CrateType :: Dylib
2102
- && !( sess. target . limit_rdylib_exports && cmd. exported_symbol_means_used_symbol ( ) )
2103
- }
2104
-
2105
2095
/// # Native library linking
2106
2096
///
2107
2097
/// User-supplied library search paths (-L on the command line). These are the same paths used to
@@ -2115,7 +2105,6 @@ fn add_local_native_libraries(
2115
2105
cmd : & mut dyn Linker ,
2116
2106
sess : & Session ,
2117
2107
codegen_results : & CodegenResults ,
2118
- crate_type : CrateType ,
2119
2108
) {
2120
2109
let filesearch = sess. target_filesearch ( PathKind :: All ) ;
2121
2110
for search_path in filesearch. search_paths ( ) {
@@ -2157,7 +2146,6 @@ fn add_local_native_libraries(
2157
2146
}
2158
2147
NativeLibKind :: Static { whole_archive, bundle, .. } => {
2159
2148
if whole_archive == Some ( true )
2160
- || ( whole_archive == None && default_to_whole_archive ( sess, crate_type, cmd) )
2161
2149
// Backward compatibility case: this can be a rlib (so `+whole-archive` cannot
2162
2150
// be added explicitly if necessary, see the error in `fn link_rlib`) compiled
2163
2151
// as an executable due to `--test`. Use whole-archive implicitly, like before
@@ -2276,7 +2264,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2276
2264
let src = & codegen_results. crate_info . used_crate_source [ & cnum] ;
2277
2265
match data[ cnum. as_usize ( ) - 1 ] {
2278
2266
_ if codegen_results. crate_info . profiler_runtime == Some ( cnum) => {
2279
- add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, crate_type , cnum) ;
2267
+ add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, cnum) ;
2280
2268
}
2281
2269
// compiler-builtins are always placed last to ensure that they're
2282
2270
// linked correctly.
@@ -2286,7 +2274,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2286
2274
}
2287
2275
Linkage :: NotLinked | Linkage :: IncludedFromDylib => { }
2288
2276
Linkage :: Static => {
2289
- add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, crate_type , cnum) ;
2277
+ add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, cnum) ;
2290
2278
2291
2279
// Link static native libs with "-bundle" modifier only if the crate they originate from
2292
2280
// is being linked statically to the current crate. If it's linked dynamically
@@ -2317,10 +2305,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2317
2305
lib. kind
2318
2306
{
2319
2307
let verbatim = lib. verbatim . unwrap_or ( false ) ;
2320
- if whole_archive == Some ( true )
2321
- || ( whole_archive == None
2322
- && default_to_whole_archive ( sess, crate_type, cmd) )
2323
- {
2308
+ if whole_archive == Some ( true ) {
2324
2309
cmd. link_whole_staticlib (
2325
2310
name,
2326
2311
verbatim,
@@ -2347,7 +2332,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2347
2332
// was already "included" in a dylib (e.g., `libstd` when `-C prefer-dynamic`
2348
2333
// is used)
2349
2334
if let Some ( cnum) = compiler_builtins {
2350
- add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, crate_type , cnum) ;
2335
+ add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, cnum) ;
2351
2336
}
2352
2337
2353
2338
// Converts a library file-stem into a cc -l argument
@@ -2378,23 +2363,13 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2378
2363
sess : & ' a Session ,
2379
2364
codegen_results : & CodegenResults ,
2380
2365
tmpdir : & Path ,
2381
- crate_type : CrateType ,
2382
2366
cnum : CrateNum ,
2383
2367
) {
2384
2368
let src = & codegen_results. crate_info . used_crate_source [ & cnum] ;
2385
2369
let cratepath = & src. rlib . as_ref ( ) . unwrap ( ) . 0 ;
2386
2370
2387
2371
let mut link_upstream = |path : & Path | {
2388
- // We don't want to include the whole compiler-builtins crate (e.g., compiler-rt)
2389
- // regardless of the default because it'll get repeatedly linked anyway.
2390
- let path = fix_windows_verbatim_for_gcc ( path) ;
2391
- if default_to_whole_archive ( sess, crate_type, cmd)
2392
- && codegen_results. crate_info . compiler_builtins != Some ( cnum)
2393
- {
2394
- cmd. link_whole_rlib ( & path) ;
2395
- } else {
2396
- cmd. link_rlib ( & path) ;
2397
- }
2372
+ cmd. link_rlib ( & fix_windows_verbatim_for_gcc ( path) ) ;
2398
2373
} ;
2399
2374
2400
2375
// See the comment above in `link_staticlib` and `link_rlib` for why if
0 commit comments