@@ -89,11 +89,12 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
89
89
// to try to eagerly statically link all dependencies. This is normally
90
90
// done for end-product dylibs, not intermediate products.
91
91
//
92
- // Treat cdylibs similarly. If `-C prefer-dynamic` is set, the caller may
93
- // be code-size conscious, but without it, it makes sense to statically
94
- // link a cdylib.
95
- CrateType :: Dylib | CrateType :: Cdylib if !sess. opts . cg . prefer_dynamic => Linkage :: Static ,
96
- CrateType :: Dylib | CrateType :: Cdylib => Linkage :: Dynamic ,
92
+ // Treat cdylibs and staticlibs similarly. If `-C prefer-dynamic` is set,
93
+ // the caller may be code-size conscious, but without it, it makes sense
94
+ // to statically link a cdylib or staticlib.
95
+ CrateType :: Dylib | CrateType :: Cdylib | CrateType :: Staticlib => {
96
+ if sess. opts . cg . prefer_dynamic { Linkage :: Dynamic } else { Linkage :: Static }
97
+ }
97
98
98
99
// If the global prefer_dynamic switch is turned off, or the final
99
100
// executable will be statically linked, prefer static crate linkage.
@@ -108,9 +109,6 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
108
109
// No linkage happens with rlibs, we just needed the metadata (which we
109
110
// got long ago), so don't bother with anything.
110
111
CrateType :: Rlib => Linkage :: NotLinked ,
111
-
112
- // staticlibs must have all static dependencies.
113
- CrateType :: Staticlib => Linkage :: Static ,
114
112
} ;
115
113
116
114
match preferred_linkage {
@@ -123,12 +121,11 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
123
121
return v;
124
122
}
125
123
126
- // Staticlibs and static executables must have all static dependencies.
124
+ // Static executables must have all static dependencies.
127
125
// If any are not found, generate some nice pretty errors.
128
- if ty == CrateType :: Staticlib
129
- || ( ty == CrateType :: Executable
130
- && sess. crt_static ( Some ( ty) )
131
- && !sess. target . crt_static_allows_dylibs )
126
+ if ty == CrateType :: Executable
127
+ && sess. crt_static ( Some ( ty) )
128
+ && !sess. target . crt_static_allows_dylibs
132
129
{
133
130
for & cnum in tcx. crates ( ( ) ) . iter ( ) {
134
131
if tcx. dep_kind ( cnum) . macros_only ( ) {
0 commit comments