authorgravatar for xq@random-projects.netFelix "xq" Queißner <xq@random-projects.net> 2024-06-30 10:54:04+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-26 22:55:18+01:00
log0ed905b9c6f7a3d69027fba5e4f6a1ea4f535e39
tree1cbcf6ac2e9cd74f742bb5c6083a2be51b69396c
parent5bb9963bbbfeed105542f52d022a80a7dd5e13a0

Enables parsing for '-Wl,-rpath,' in pkg-config output, allows better support for NixOS linking.


1 files changed, 4 insertions(+), 0 deletions(-)

lib/std/Build/Step/Compile.zig+4
......@@ -693,6 +693,8 @@ const PkgConfigResult = struct {
693693/// Run pkg-config for the given library name and parse the output, returning the arguments
694694/// that should be passed to zig to link the given library.
695695fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
696 const wl_rpath_prefix = "-Wl,-rpath,";
697
696698 const b = compile.step.owner;
697699 const pkg_name = match: {
698700 // First we have to map the library name to pkg config name. Unfortunately,
......@@ -783,6 +785,8 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
783785 try zig_cflags.appendSlice(&[_][]const u8{ "-D", macro });
784786 } else if (mem.startsWith(u8, arg, "-D")) {
785787 try zig_cflags.append(arg);
788 } else if (mem.startsWith(u8, arg, wl_rpath_prefix)) {
789 try zig_cflags.appendSlice(&[_][]const u8{ "-rpath", arg[wl_rpath_prefix.len..] });
786790 } else if (b.debug_pkg_config) {
787791 return compile.step.fail("unknown pkg-config flag '{s}'", .{arg});
788792 }