This commit is contained in:
Jacob Crabill 2025-11-25 13:06:42 -03:00 committed by GitHub
commit 46770686d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1223,11 +1223,19 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
break :prefix "-l"; break :prefix "-l";
}; };
switch (system_lib.use_pkg_config) { switch (system_lib.use_pkg_config) {
.no => try zig_args.append(b.fmt("{s}{s}", .{ prefix, system_lib.name })), .no => {
if (compile.linkage != .static) {
// Avoid putting another compiled library inside a static library.
try zig_args.append(b.fmt("{s}{s}", .{ prefix, system_lib.name }));
}
},
.yes, .force => { .yes, .force => {
if (compile.runPkgConfig(system_lib.name)) |result| { if (compile.runPkgConfig(system_lib.name)) |result| {
try zig_args.appendSlice(result.cflags); try zig_args.appendSlice(result.cflags);
if (compile.linkage != .static) {
// Avoid putting another compiled library inside a static library.
try zig_args.appendSlice(result.libs); try zig_args.appendSlice(result.libs);
}
try seen_system_libs.put(arena, system_lib.name, result.cflags); try seen_system_libs.put(arena, system_lib.name, result.cflags);
} else |err| switch (err) { } else |err| switch (err) {
error.PkgConfigInvalidOutput, error.PkgConfigInvalidOutput,
@ -1269,10 +1277,10 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
}, },
.lib => l: { .lib => l: {
const other_produces_implib = other.producesImplib(); const other_produces_implib = other.producesImplib();
const other_is_static = other_produces_implib or other.isStaticLibrary(); const other_is_compiled_lib = other_produces_implib or other.isStaticLibrary() or other.isDynamicLibrary();
if (compile.isStaticLibrary() and other_is_static) { if (compile.isStaticLibrary() and other_is_compiled_lib) {
// Avoid putting a static library inside a static library. // Avoid putting another compiled library inside a static library.
break :l; break :l;
} }