| author | |
| committer | |
| log | 50e34a063c270e1fe4fe9b0342ca300bc937d96a |
| tree | 1261912817f7bbf5ff63c9461d4bb2d7536d2f6b |
| parent | c4f97d336528d5b795c6584053f072cf8e28495e |
| parent | ffb989169594cbfcfefbbcc00dd7c3d07f1a9949 |
| signature |
link/include: fix invalid file path concatenation when cross-compiling for Windows -> Mac2 files changed, 29 insertions(+), 2 deletions(-)
lib/std/build.zig+16-1| ... | @@ -2549,7 +2549,22 @@ pub const LibExeObjStep = struct { | ... | @@ -2549,7 +2549,22 @@ pub const LibExeObjStep = struct { |
| 2549 | } else { | 2549 | } else { |
| 2550 | try zig_args.append("-isystem"); | 2550 | try zig_args.append("-isystem"); |
| 2551 | } | 2551 | } |
| 2552 | try zig_args.append(self.builder.pathFromRoot(include_path)); | 2552 | |
| 2553 | const resolved_include_path = self.builder.pathFromRoot(include_path); | ||
| 2554 | |||
| 2555 | const common_include_path = if (std.Target.current.os.tag == .windows and builder.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: { | ||
| 2556 | // We need to check for disk designator and strip it out from dir path so | ||
| 2557 | // that zig/clang can concat resolved_include_path with sysroot. | ||
| 2558 | const disk_designator = fs.path.diskDesignatorWindows(resolved_include_path); | ||
| 2559 | |||
| 2560 | if (mem.indexOf(u8, resolved_include_path, disk_designator)) |where| { | ||
| 2561 | break :blk resolved_include_path[where + disk_designator.len ..]; | ||
| 2562 | } | ||
| 2563 | |||
| 2564 | break :blk resolved_include_path; | ||
| 2565 | } else resolved_include_path; | ||
| 2566 | |||
| 2567 | try zig_args.append(common_include_path); | ||
| 2553 | }, | 2568 | }, |
| 2554 | .other_step => |other| if (other.emit_h) { | 2569 | .other_step => |other| if (other.emit_h) { |
| 2555 | const h_path = other.getOutputHSource().getPath(self.builder); | 2570 | const h_path = other.getOutputHSource().getPath(self.builder); |
src/link/MachO.zig+13-1| ... | @@ -493,7 +493,19 @@ fn resolveSearchDir( | ... | @@ -493,7 +493,19 @@ fn resolveSearchDir( |
| 493 | 493 | ||
| 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 common_dir = if (std.Target.current.os.tag == .windows) blk: { |
| 497 | // We need to check for disk designator and strip it out from dir path so | ||
| 498 | // that we can concat dir with syslibroot. | ||
| 499 | // TODO we should backport this mechanism to 'MachO.Dylib.parseDependentLibs()' | ||
| 500 | const disk_designator = fs.path.diskDesignatorWindows(dir); | ||
| 501 | |||
| 502 | if (mem.indexOf(u8, dir, disk_designator)) |where| { | ||
| 503 | break :blk dir[where + disk_designator.len ..]; | ||
| 504 | } | ||
| 505 | |||
| 506 | break :blk dir; | ||
| 507 | } else dir; | ||
| 508 | const full_path = try fs.path.join(arena, &[_][]const u8{ root, common_dir }); | ||
| 497 | try candidates.append(full_path); | 509 | try candidates.append(full_path); |
| 498 | } | 510 | } |
| 499 | } | 511 | } |