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 23:51:58+01:00
log3592868435b5d23a022544bb76446b3b4829e270
tree6f4c301a9e0a4ac66cdf6a02349c09c8fda92fc0
parent27ae10afe0d764626e0191f0129654131d398814
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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 {...@@ -693,6 +693,8 @@ const PkgConfigResult = struct {
693/// Run pkg-config for the given library name and parse the output, returning the arguments693/// Run pkg-config for the given library name and parse the output, returning the arguments
694/// that should be passed to zig to link the given library.694/// that should be passed to zig to link the given library.
695fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {695fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
696 const wl_rpath_prefix = "-Wl,-rpath,";
697
696 const b = compile.step.owner;698 const b = compile.step.owner;
697 const pkg_name = match: {699 const pkg_name = match: {
698 // First we have to map the library name to pkg config name. Unfortunately,700 // 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 {...@@ -783,6 +785,8 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
783 try zig_cflags.appendSlice(&[_][]const u8{ "-D", macro });785 try zig_cflags.appendSlice(&[_][]const u8{ "-D", macro });
784 } else if (mem.startsWith(u8, arg, "-D")) {786 } else if (mem.startsWith(u8, arg, "-D")) {
785 try zig_cflags.append(arg);787 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..] });
786 } else if (b.debug_pkg_config) {790 } else if (b.debug_pkg_config) {
787 return compile.step.fail("unknown pkg-config flag '{s}'", .{arg});791 return compile.step.fail("unknown pkg-config flag '{s}'", .{arg});
788 }792 }