@@ -1947,7 +1947,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
19471947 // This change is somewhat breaking in practice due to local static libraries being linked
19481948 // as whole-archive (#85144), so removing whole-archive may be a pre-requisite.
19491949 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) ;
19511951 }
19521952
19531953 // Upstream rust libraries and their nobundle static libraries
@@ -2119,16 +2119,6 @@ fn add_order_independent_options(
21192119 add_rpath_args ( cmd, sess, codegen_results, out_filename) ;
21202120}
21212121
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-
21322122/// # Native library linking
21332123///
21342124/// 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(
21422132 cmd : & mut dyn Linker ,
21432133 sess : & Session ,
21442134 codegen_results : & CodegenResults ,
2145- crate_type : CrateType ,
21462135) {
21472136 let filesearch = sess. target_filesearch ( PathKind :: All ) ;
21482137 for search_path in filesearch. search_paths ( ) {
@@ -2184,7 +2173,6 @@ fn add_local_native_libraries(
21842173 }
21852174 NativeLibKind :: Static { whole_archive, bundle, .. } => {
21862175 if whole_archive == Some ( true )
2187- || ( whole_archive == None && default_to_whole_archive ( sess, crate_type, cmd) )
21882176 // Backward compatibility case: this can be a rlib (so `+whole-archive` cannot
21892177 // be added explicitly if necessary, see the error in `fn link_rlib`) compiled
21902178 // 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>>(
23032291 let src = & codegen_results. crate_info . used_crate_source [ & cnum] ;
23042292 match data[ cnum. as_usize ( ) - 1 ] {
23052293 _ 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) ;
23072295 }
23082296 // compiler-builtins are always placed last to ensure that they're
23092297 // linked correctly.
@@ -2313,7 +2301,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
23132301 }
23142302 Linkage :: NotLinked | Linkage :: IncludedFromDylib => { }
23152303 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) ;
23172305
23182306 // Link static native libs with "-bundle" modifier only if the crate they originate from
23192307 // 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>>(
23442332 lib. kind
23452333 {
23462334 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 ) {
23512336 cmd. link_whole_staticlib (
23522337 name,
23532338 verbatim,
@@ -2374,7 +2359,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
23742359 // was already "included" in a dylib (e.g., `libstd` when `-C prefer-dynamic`
23752360 // is used)
23762361 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) ;
23782363 }
23792364
23802365 // Converts a library file-stem into a cc -l argument
@@ -2405,23 +2390,13 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
24052390 sess : & ' a Session ,
24062391 codegen_results : & CodegenResults ,
24072392 tmpdir : & Path ,
2408- crate_type : CrateType ,
24092393 cnum : CrateNum ,
24102394 ) {
24112395 let src = & codegen_results. crate_info . used_crate_source [ & cnum] ;
24122396 let cratepath = & src. rlib . as_ref ( ) . unwrap ( ) . 0 ;
24132397
24142398 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) ) ;
24252400 } ;
24262401
24272402 // See the comment above in `link_staticlib` and `link_rlib` for why if
0 commit comments