From 62a6d83da11553daadb7d463330571f361c771d8 Mon Sep 17 00:00:00 2001 From: Andrew Gutekanst Date: Sun, 12 Sep 2021 19:34:06 -0400 Subject: [PATCH] Address feedback --- src/link/MachO.zig | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 2b7fa280ba..de5e789b8c 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -491,9 +491,21 @@ 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 }); + const common_dir = if (std.Target.current.os.tag == .windows) blk: { + // We need to check for disk designator and strip it out from dir path so + // that we can concat dir with syslibroot. + // TODO we should backport this mechanism to 'MachO.Dylib.parseDependentLibs()' + const disk_designator = fs.path.diskDesignatorWindows(dir); + + if (mem.indexOf(u8, dir, disk_designator)) |where| { + break :blk dir[where + disk_designator.len ..]; + } + + break :blk dir; + } else dir; + const full_path = try fs.path.join(arena, &[_][]const u8{ root, common_dir }); try candidates.append(full_path); } }