authorgravatar for andrew.gutekanst@gmail.comAndrew Gutekanst <andrew.gutekanst@gmail.com> 2021-09-10 23:52:46-04:00
committergravatar for andrew.gutekanst@gmail.comAndrew Gutekanst <andrew.gutekanst@gmail.com> 2021-09-10 23:55:13-04:00
log6734271eb0b8b7eafd098986b30a5bc34e180b72
treecda1ce0885d8eff9aba9e955432fb8a51314f018
parent0c091feb5ae52caf1ebf885c0de55b3159207001

link: fix invalid file path used when cross-compiling for Windows -> Mac

While investigating hexops/mach#8 with @slimsag, we found that zld is forming invalid file paths (absolute paths concatenated together), which hits the unreachable `OBJECT_NAME_INVALID` case in `openDirAccessMaskW`: https://github.com/ziglang/zig/blob/0c091feb5ae52caf1ebf885c0de55b3159207001/lib/std/fs.zig#L1522 This is caused by appending `dir` (which is guaranteed to be absolute) to `root`, an obviously incorrect operation: https://github.com/ziglang/zig/blob/0c091feb5ae52caf1ebf885c0de55b3159207001/src/link/MachO.zig#L494-L499 Fixes hexops/mach#8 Co-authored-by: Stephen Gutekanst <stephen@hexops.com> Signed-off-by: Stephen Gutekanst <stephen@hexops.com> Signed-off-by: Andrew Gutekanst <andrew.gutekanst@gmail.com>

1 files changed, 1 insertions(+), 1 deletions(-)

src/link/MachO.zig+1-1
...@@ -491,7 +491,7 @@ fn resolveSearchDir(...@@ -491,7 +491,7 @@ fn resolveSearchDir(
491) !?[]const u8 {491) !?[]const u8 {
492 var candidates = std.ArrayList([]const u8).init(arena);492 var candidates = std.ArrayList([]const u8).init(arena);
493493
494 if (fs.path.isAbsolute(dir)) {494 if (!fs.path.isAbsolute(dir)) {
495 if (syslibroot) |root| {495 if (syslibroot) |root| {
496 const full_path = try fs.path.join(arena, &[_][]const u8{ root, dir });496 const full_path = try fs.path.join(arena, &[_][]const u8{ root, dir });
497 try candidates.append(full_path);497 try candidates.append(full_path);