From 1b278ce889b0fe89db20f9875069d99b6ce0862c Mon Sep 17 00:00:00 2001 From: Morgan Moore Date: Sun, 11 Jan 2026 17:02:26 -0500 Subject: [PATCH 1/4] Update build.zig for 0.16 fs.Dir -> Io.Dir --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 5de3dabdedea8..f0d546610810d 100644 --- a/build.zig +++ b/build.zig @@ -68,12 +68,12 @@ pub fn build(b: *std.Build) void { defer b.allocator.free(cache_include); // TODO: Remove compatibility shim when Zig 0.16.0 is the minimum required version. - const open_dir_opts: std.fs.Dir.OpenOptions = if (@hasField(std.fs.Dir.OpenOptions, "follow_symlinks")) + const open_dir_opts: std.Io.Dir.OpenOptions = if (@hasField(std.Io.Dir.OpenOptions, "follow_symlinks")) .{ .access_sub_paths = true, .follow_symlinks = false } else .{ .access_sub_paths = true, .no_follow = true }; - var dir = std.fs.openDirAbsolute(cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!"); - dir.close(); + var dir = std.Io.Dir.openDirAbsolute(mod.owner.graph.io, cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!"); + dir.close(mod.owner.graph.io); mod.addIncludePath(.{ .cwd_relative = cache_include }); }, From 940b2c262a9d068e8beba6f79a2903c3e7cd3751 Mon Sep 17 00:00:00 2001 From: Morgan Moore Date: Sun, 11 Jan 2026 17:52:40 -0500 Subject: [PATCH 2/4] Add branching for 0.16 and current support --- build.zig | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/build.zig b/build.zig index f0d546610810d..57fcdd3664ff2 100644 --- a/build.zig +++ b/build.zig @@ -67,13 +67,28 @@ pub fn build(b: *std.Build) void { const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory"); defer b.allocator.free(cache_include); - // TODO: Remove compatibility shim when Zig 0.16.0 is the minimum required version. - const open_dir_opts: std.Io.Dir.OpenOptions = if (@hasField(std.Io.Dir.OpenOptions, "follow_symlinks")) - .{ .access_sub_paths = true, .follow_symlinks = false } - else - .{ .access_sub_paths = true, .no_follow = true }; - var dir = std.Io.Dir.openDirAbsolute(mod.owner.graph.io, cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!"); - dir.close(mod.owner.graph.io); + if (@hasDecl(std.Io, "Dir")) { + // v0.16 -> Dir moved to std.Io + const open_dir_opts: std.Io.Dir.OpenOptions = .{ + .access_sub_paths = true, + .follow_symlinks = false, + }; + + var dir = std.Io.Dir.openDirAbsolute(mod.owner.graph.io, cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!"); + + dir.close(mod.owner.graph.io); + } else if (@hasDecl(std.fs, "Dir")) { + // <=0.15.2 -> Dir on std.fs + // TODO: Remove compatibility shim when Zig 0.16.0 is the minimum required version. + const open_dir_opts: std.fs.Dir.OpenOptions = if (@hasField(std.fs.Dir.OpenOptions, "follow_symlinks")) + .{ .access_sub_paths = true, .follow_symlinks = false } + else + .{ .access_sub_paths = true, .no_follow = true }; + + var dir = std.fs.openDirAbsolute(cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!"); + + dir.close(); + } mod.addIncludePath(.{ .cwd_relative = cache_include }); }, From 53b1f48aef0a977ff2467f22aafdfa195d409ff2 Mon Sep 17 00:00:00 2001 From: Morgan Moore Date: Mon, 12 Jan 2026 15:45:15 -0500 Subject: [PATCH 3/4] Remove compatability shim for emscripten build --- build.zig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index 57fcdd3664ff2..4517f858fe703 100644 --- a/build.zig +++ b/build.zig @@ -79,11 +79,10 @@ pub fn build(b: *std.Build) void { dir.close(mod.owner.graph.io); } else if (@hasDecl(std.fs, "Dir")) { // <=0.15.2 -> Dir on std.fs - // TODO: Remove compatibility shim when Zig 0.16.0 is the minimum required version. - const open_dir_opts: std.fs.Dir.OpenOptions = if (@hasField(std.fs.Dir.OpenOptions, "follow_symlinks")) - .{ .access_sub_paths = true, .follow_symlinks = false } - else - .{ .access_sub_paths = true, .no_follow = true }; + const open_dir_opts: std.fs.Dir.OpenOptions = .{ + .access_sub_paths = true, + .follow_symlinks = false, + }; var dir = std.fs.openDirAbsolute(cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!"); From e90096868841457ccc9abd98e34154c1739fb2cb Mon Sep 17 00:00:00 2001 From: Jay Petacat Date: Wed, 14 Jan 2026 09:39:05 -0700 Subject: [PATCH 4/4] Fix build with Zig 0.15.2 --- build.zig | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/build.zig b/build.zig index 4517f858fe703..1223d96ad0fce 100644 --- a/build.zig +++ b/build.zig @@ -67,27 +67,22 @@ pub fn build(b: *std.Build) void { const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory"); defer b.allocator.free(cache_include); + // TODO: Remove compatibility shim when minimum Zig version is 0.16.0. if (@hasDecl(std.Io, "Dir")) { - // v0.16 -> Dir moved to std.Io - const open_dir_opts: std.Io.Dir.OpenOptions = .{ + // Zig 0.16.0-dev + var dir = std.Io.Dir.openDirAbsolute(mod.owner.graph.io, cache_include, .{ .access_sub_paths = true, .follow_symlinks = false, - }; - - var dir = std.Io.Dir.openDirAbsolute(mod.owner.graph.io, cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!"); - + }) catch @panic("No emscripten cache. Generate it!"); dir.close(mod.owner.graph.io); } else if (@hasDecl(std.fs, "Dir")) { - // <=0.15.2 -> Dir on std.fs - const open_dir_opts: std.fs.Dir.OpenOptions = .{ + // Zig 0.15.x + var dir = std.fs.openDirAbsolute(cache_include, .{ .access_sub_paths = true, - .follow_symlinks = false, - }; - - var dir = std.fs.openDirAbsolute(cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!"); - + .no_follow = true, + }) catch @panic("No emscripten cache. Generate it!"); dir.close(); - } + } else @compileError("Fix `openDirAbsolute` compatibility shim"); mod.addIncludePath(.{ .cwd_relative = cache_include }); },