Skip to content

Commit 0ed905b

Browse files
Felix "xq" Queißneralexrp
Felix "xq" Queißner
authored andcommitted
Enables parsing for '-Wl,-rpath,' in pkg-config output, allows better support for NixOS linking.
1 parent 5bb9963 commit 0ed905b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/std/Build/Step/Compile.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
695695
fn 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
}

0 commit comments

Comments
 (0)