From 6734271eb0b8b7eafd098986b30a5bc34e180b72 Mon Sep 17 00:00:00 2001 From: Andrew Gutekanst Date: Fri, 10 Sep 2021 23:52:46 -0400 Subject: [PATCH] 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 Signed-off-by: Stephen Gutekanst Signed-off-by: Andrew Gutekanst --- src/link/MachO.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 12556b53d6a91168a7f2307fafca862cddff9e2f..2b7fa280bad2c3f8535dc9783f294cc95f0f35fd 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -491,7 +491,7 @@ fn resolveSearchDir( ) !?[]const u8 { var candidates = std.ArrayList([]const u8).init(arena); - if (fs.path.isAbsolute(dir)) { + if (!fs.path.isAbsolute(dir)) { if (syslibroot) |root| { const full_path = try fs.path.join(arena, &[_][]const u8{ root, dir }); try candidates.append(full_path); -- 2.54.0