@@ -1222,11 +1222,19 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
1222
1222
break :prefix "-l" ;
1223
1223
};
1224
1224
switch (system_lib .use_pkg_config ) {
1225
- .no = > try zig_args .append (b .fmt ("{s}{s}" , .{ prefix , system_lib .name })),
1225
+ .no = > {
1226
+ if (compile .linkage != .static ) {
1227
+ // Avoid putting another compiled library inside a static library.
1228
+ try zig_args .append (b .fmt ("{s}{s}" , .{ prefix , system_lib .name }));
1229
+ }
1230
+ },
1226
1231
.yes , .force = > {
1227
1232
if (compile .runPkgConfig (system_lib .name )) | result | {
1228
1233
try zig_args .appendSlice (result .cflags );
1229
- try zig_args .appendSlice (result .libs );
1234
+ if (compile .linkage != .static ) {
1235
+ // Avoid putting another compiled library inside a static library.
1236
+ try zig_args .appendSlice (result .libs );
1237
+ }
1230
1238
try seen_system_libs .put (arena , system_lib .name , result .cflags );
1231
1239
} else | err | switch (err ) {
1232
1240
error .PkgConfigInvalidOutput ,
@@ -1268,10 +1276,10 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
1268
1276
},
1269
1277
.lib = > l : {
1270
1278
const other_produces_implib = other .producesImplib ();
1271
- const other_is_static = other_produces_implib or other .isStaticLibrary ();
1279
+ const other_is_compiled_lib = other_produces_implib or other .isStaticLibrary () or other . isDynamicLibrary ();
1272
1280
1273
- if (compile .isStaticLibrary () and other_is_static ) {
1274
- // Avoid putting a static library inside a static library.
1281
+ if (compile .isStaticLibrary () and other_is_compiled_lib ) {
1282
+ // Avoid putting another compiled library inside a static library.
1275
1283
break :l ;
1276
1284
}
1277
1285
0 commit comments