aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/Compile.zig
diff options
context:
space:
mode:
authorFelix "xq" Queißner <git@random-projects.net>2024-06-30 10:54:04 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2025-03-26 22:55:18 +0100
commit0ed905b9c6f7a3d69027fba5e4f6a1ea4f535e39 (patch)
tree1cbcf6ac2e9cd74f742bb5c6083a2be51b69396c /lib/std/Build/Step/Compile.zig
parent5bb9963bbbfeed105542f52d022a80a7dd5e13a0 (diff)
downloadzig-0ed905b9c6f7a3d69027fba5e4f6a1ea4f535e39.tar.gz
zig-0ed905b9c6f7a3d69027fba5e4f6a1ea4f535e39.zip
Enables parsing for '-Wl,-rpath,' in pkg-config output, allows better support for NixOS linking.
Diffstat (limited to 'lib/std/Build/Step/Compile.zig')
-rw-r--r--lib/std/Build/Step/Compile.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
index 616e8f76b4..c401a840ba 100644
--- a/lib/std/Build/Step/Compile.zig
+++ b/lib/std/Build/Step/Compile.zig
@@ -693,6 +693,8 @@ const PkgConfigResult = struct {
/// Run pkg-config for the given library name and parse the output, returning the arguments
/// that should be passed to zig to link the given library.
fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
+ const wl_rpath_prefix = "-Wl,-rpath,";
+
const b = compile.step.owner;
const pkg_name = match: {
// 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 {
try zig_cflags.appendSlice(&[_][]const u8{ "-D", macro });
} else if (mem.startsWith(u8, arg, "-D")) {
try zig_cflags.append(arg);
+ } else if (mem.startsWith(u8, arg, wl_rpath_prefix)) {
+ try zig_cflags.appendSlice(&[_][]const u8{ "-rpath", arg[wl_rpath_prefix.len..] });
} else if (b.debug_pkg_config) {
return compile.step.fail("unknown pkg-config flag '{s}'", .{arg});
}