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`:
0c091feb5a/lib/std/fs.zig (L1522)

This is caused by appending `dir` (which is guaranteed to be absolute) to `root`,
an obviously incorrect operation:
0c091feb5a/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>
This commit is contained in:
Andrew Gutekanst 2021-09-10 23:52:46 -04:00
parent 0c091feb5a
commit 6734271eb0

View File

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