@@ -1947,7 +1947,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
1947
1947
// This change is somewhat breaking in practice due to local static libraries being linked
1948
1948
// as whole-archive (#85144), so removing whole-archive may be a pre-requisite.
1949
1949
if sess. opts . debugging_opts . link_native_libraries {
1950
- add_local_native_libraries ( cmd, sess, codegen_results, crate_type ) ;
1950
+ add_local_native_libraries ( cmd, sess, codegen_results) ;
1951
1951
}
1952
1952
1953
1953
// Upstream rust libraries and their nobundle static libraries
@@ -2119,16 +2119,6 @@ fn add_order_independent_options(
2119
2119
add_rpath_args ( cmd, sess, codegen_results, out_filename) ;
2120
2120
}
2121
2121
2122
- // A dylib may reexport symbols from the linked rlib or native static library.
2123
- // Even if some symbol is reexported it's still not necessarily counted as used and may be
2124
- // dropped, at least with `ld`-like ELF linkers. So we have to link some rlibs and static
2125
- // libraries as whole-archive to avoid losing reexported symbols.
2126
- // FIXME: Find a way to mark reexported symbols as used and avoid this use of whole-archive.
2127
- fn default_to_whole_archive ( sess : & Session , crate_type : CrateType , cmd : & dyn Linker ) -> bool {
2128
- crate_type == CrateType :: Dylib
2129
- && !( sess. target . limit_rdylib_exports && cmd. exported_symbol_means_used_symbol ( ) )
2130
- }
2131
-
2132
2122
/// # Native library linking
2133
2123
///
2134
2124
/// User-supplied library search paths (-L on the command line). These are the same paths used to
@@ -2142,7 +2132,6 @@ fn add_local_native_libraries(
2142
2132
cmd : & mut dyn Linker ,
2143
2133
sess : & Session ,
2144
2134
codegen_results : & CodegenResults ,
2145
- crate_type : CrateType ,
2146
2135
) {
2147
2136
let filesearch = sess. target_filesearch ( PathKind :: All ) ;
2148
2137
for search_path in filesearch. search_paths ( ) {
@@ -2184,7 +2173,6 @@ fn add_local_native_libraries(
2184
2173
}
2185
2174
NativeLibKind :: Static { whole_archive, bundle, .. } => {
2186
2175
if whole_archive == Some ( true )
2187
- || ( whole_archive == None && default_to_whole_archive ( sess, crate_type, cmd) )
2188
2176
// Backward compatibility case: this can be a rlib (so `+whole-archive` cannot
2189
2177
// be added explicitly if necessary, see the error in `fn link_rlib`) compiled
2190
2178
// as an executable due to `--test`. Use whole-archive implicitly, like before
@@ -2303,7 +2291,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2303
2291
let src = & codegen_results. crate_info . used_crate_source [ & cnum] ;
2304
2292
match data[ cnum. as_usize ( ) - 1 ] {
2305
2293
_ if codegen_results. crate_info . profiler_runtime == Some ( cnum) => {
2306
- add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, crate_type , cnum) ;
2294
+ add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, cnum) ;
2307
2295
}
2308
2296
// compiler-builtins are always placed last to ensure that they're
2309
2297
// linked correctly.
@@ -2313,7 +2301,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2313
2301
}
2314
2302
Linkage :: NotLinked | Linkage :: IncludedFromDylib => { }
2315
2303
Linkage :: Static => {
2316
- add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, crate_type , cnum) ;
2304
+ add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, cnum) ;
2317
2305
2318
2306
// Link static native libs with "-bundle" modifier only if the crate they originate from
2319
2307
// is being linked statically to the current crate. If it's linked dynamically
@@ -2344,10 +2332,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2344
2332
lib. kind
2345
2333
{
2346
2334
let verbatim = lib. verbatim . unwrap_or ( false ) ;
2347
- if whole_archive == Some ( true )
2348
- || ( whole_archive == None
2349
- && default_to_whole_archive ( sess, crate_type, cmd) )
2350
- {
2335
+ if whole_archive == Some ( true ) {
2351
2336
cmd. link_whole_staticlib (
2352
2337
name,
2353
2338
verbatim,
@@ -2374,7 +2359,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2374
2359
// was already "included" in a dylib (e.g., `libstd` when `-C prefer-dynamic`
2375
2360
// is used)
2376
2361
if let Some ( cnum) = compiler_builtins {
2377
- add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, crate_type , cnum) ;
2362
+ add_static_crate :: < B > ( cmd, sess, codegen_results, tmpdir, cnum) ;
2378
2363
}
2379
2364
2380
2365
// Converts a library file-stem into a cc -l argument
@@ -2405,23 +2390,13 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
2405
2390
sess : & ' a Session ,
2406
2391
codegen_results : & CodegenResults ,
2407
2392
tmpdir : & Path ,
2408
- crate_type : CrateType ,
2409
2393
cnum : CrateNum ,
2410
2394
) {
2411
2395
let src = & codegen_results. crate_info . used_crate_source [ & cnum] ;
2412
2396
let cratepath = & src. rlib . as_ref ( ) . unwrap ( ) . 0 ;
2413
2397
2414
2398
let mut link_upstream = |path : & Path | {
2415
- // We don't want to include the whole compiler-builtins crate (e.g., compiler-rt)
2416
- // regardless of the default because it'll get repeatedly linked anyway.
2417
- let path = fix_windows_verbatim_for_gcc ( path) ;
2418
- if default_to_whole_archive ( sess, crate_type, cmd)
2419
- && codegen_results. crate_info . compiler_builtins != Some ( cnum)
2420
- {
2421
- cmd. link_whole_rlib ( & path) ;
2422
- } else {
2423
- cmd. link_rlib ( & path) ;
2424
- }
2399
+ cmd. link_rlib ( & fix_windows_verbatim_for_gcc ( path) ) ;
2425
2400
} ;
2426
2401
2427
2402
// See the comment above in `link_staticlib` and `link_rlib` for why if
0 commit comments