Commit 6734271eb0

Andrew Gutekanst <andrew.gutekanst@gmail.com>
2021-09-11 05:52:46
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 parent 0c091fe
Changed files (1)
src
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);