aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-09-13 09:04:11 +0200
committerGitHub <noreply@github.com>2021-09-13 09:04:11 +0200
commit50e34a063c270e1fe4fe9b0342ca300bc937d96a (patch)
tree1261912817f7bbf5ff63c9461d4bb2d7536d2f6b /lib
parentc4f97d336528d5b795c6584053f072cf8e28495e (diff)
parentffb989169594cbfcfefbbcc00dd7c3d07f1a9949 (diff)
downloadzig-50e34a063c270e1fe4fe9b0342ca300bc937d96a.tar.gz
zig-50e34a063c270e1fe4fe9b0342ca300bc937d96a.zip
Merge pull request #9734 from Andoryuuta/macho-zld-win-filepath
link/include: fix invalid file path concatenation when cross-compiling for Windows -> Mac
Diffstat (limited to 'lib')
-rw-r--r--lib/std/build.zig17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/std/build.zig b/lib/std/build.zig
index 7ac41d1bb0..7b976405dc 100644
--- a/lib/std/build.zig
+++ b/lib/std/build.zig
@@ -2549,7 +2549,22 @@ pub const LibExeObjStep = struct {
} else {
try zig_args.append("-isystem");
}
- try zig_args.append(self.builder.pathFromRoot(include_path));
+
+ const resolved_include_path = self.builder.pathFromRoot(include_path);
+
+ const common_include_path = if (std.Target.current.os.tag == .windows and builder.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: {
+ // We need to check for disk designator and strip it out from dir path so
+ // that zig/clang can concat resolved_include_path with sysroot.
+ const disk_designator = fs.path.diskDesignatorWindows(resolved_include_path);
+
+ if (mem.indexOf(u8, resolved_include_path, disk_designator)) |where| {
+ break :blk resolved_include_path[where + disk_designator.len ..];
+ }
+
+ break :blk resolved_include_path;
+ } else resolved_include_path;
+
+ try zig_args.append(common_include_path);
},
.other_step => |other| if (other.emit_h) {
const h_path = other.getOutputHSource().getPath(self.builder);