Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/std/Build/Step/Compile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1222,11 +1222,19 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
break :prefix "-l";
};
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 => {
if (compile.runPkgConfig(system_lib.name)) |result| {
try zig_args.appendSlice(result.cflags);
try zig_args.appendSlice(result.libs);
if (compile.linkage != .static) {
// Avoid putting another compiled library inside a static library.
try zig_args.appendSlice(result.libs);
}
try seen_system_libs.put(arena, system_lib.name, result.cflags);
} else |err| switch (err) {
error.PkgConfigInvalidOutput,
Expand Down Expand Up @@ -1268,10 +1276,10 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
},
.lib => l: {
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) {
// Avoid putting a static library inside a static library.
if (compile.isStaticLibrary() and other_is_compiled_lib) {
// Avoid putting another compiled library inside a static library.
break :l;
}

Expand Down