This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
rustc_codegen_ssa/src/back Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -2684,7 +2684,7 @@ fn add_native_libs_from_crate(
26842684 NativeLibKind :: Static { bundle, whole_archive } => {
26852685 if link_static {
26862686 let bundle = bundle. unwrap_or ( true ) ;
2687- let whole_archive = whole_archive == Some ( true ) ;
2687+ let whole_archive = whole_archive. unwrap_or ( link_output_kind . is_dylib ( ) ) ;
26882688 if bundle && cnum != LOCAL_CRATE {
26892689 if let Some ( filename) = lib. filename {
26902690 // If rlib contains native libs as archives, they are unpacked to tmpdir.
@@ -2706,7 +2706,7 @@ fn add_native_libs_from_crate(
27062706 // link kind is unspecified.
27072707 if !link_output_kind. can_link_dylib ( ) && !sess. target . crt_static_allows_dylibs {
27082708 if link_static {
2709- cmd. link_staticlib_by_name ( name, verbatim, false ) ;
2709+ cmd. link_staticlib_by_name ( name, verbatim, link_output_kind . is_dylib ( ) ) ;
27102710 }
27112711 } else if link_dynamic {
27122712 cmd. link_dylib_by_name ( name, verbatim, true ) ;
Original file line number Diff line number Diff line change @@ -1235,6 +1235,17 @@ impl LinkOutputKind {
12351235 | LinkOutputKind :: WasiReactorExe => true ,
12361236 }
12371237 }
1238+
1239+ pub fn is_dylib ( self ) -> bool {
1240+ match self {
1241+ LinkOutputKind :: DynamicDylib | LinkOutputKind :: StaticDylib => true ,
1242+ LinkOutputKind :: StaticNoPicExe
1243+ | LinkOutputKind :: DynamicNoPicExe
1244+ | LinkOutputKind :: DynamicPicExe
1245+ | LinkOutputKind :: WasiReactorExe
1246+ | LinkOutputKind :: StaticPicExe => false ,
1247+ }
1248+ }
12381249}
12391250
12401251impl fmt:: Display for LinkOutputKind {
You can’t perform that action at this time.
0 commit comments