From 5d2892740a842378fd03ced7af1c1ce6d1411539 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 23 Mar 2023 22:34:31 +0100 Subject: [PATCH] build: when parsing rpaths, do not expand special runtime paths on Darwin Special runtime paths on Darwin are: `@executable_path` and `@loader_path`. --- lib/std/Build/CompileStep.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/std/Build/CompileStep.zig b/lib/std/Build/CompileStep.zig index 72855f360e..2747f56af2 100644 --- a/lib/std/Build/CompileStep.zig +++ b/lib/std/Build/CompileStep.zig @@ -1725,6 +1725,22 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { try zig_args.ensureUnusedCapacity(2 * self.rpaths.items.len); for (self.rpaths.items) |rpath| { zig_args.appendAssumeCapacity("-rpath"); + + if (self.target_info.target.isDarwin()) switch (rpath) { + .path => |path| { + // On Darwin, we should not try to expand special runtime paths such as + // * @executable_path + // * @loader_path + if (mem.startsWith(u8, path, "@executable_path") or + mem.startsWith(u8, path, "@loader_path")) + { + zig_args.appendAssumeCapacity(path); + continue; + } + }, + .generated => {}, + }; + zig_args.appendAssumeCapacity(rpath.getPath2(b, step)); }