build: when parsing rpaths, do not expand special runtime paths on Darwin

Special runtime paths on Darwin are: `@executable_path` and `@loader_path`.
This commit is contained in:
Jakub Konka 2023-03-23 22:34:31 +01:00
parent 38ee46dda3
commit 5d2892740a

View File

@ -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));
}