authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-09-25 20:39:20-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-09-27 12:16:04+02:00
logda561521dd78dcde03fc51de8fd64551b368f56d
tree021acb222f212b13bb61ee63e0dd64e4040383cd
parentbc616127e87a76ef3de02d5aee6c7d6ff6c9e34f

WriteFile: populate open_dir_cache regardless of mode

operate assumes that `open_dir_cache` is populated, but that wasn't the case when the mode was .tmp/.mutate Fixes https://codeberg.org/ziglang/zig/issues/36958

1 files changed, 11 insertions(+), 7 deletions(-)

lib/compiler/Maker/Step/WriteFile.zig+11-7
...@@ -30,6 +30,16 @@ pub fn make(...@@ -30,6 +30,16 @@ pub fn make(
30 var open_dirs_count: u32 = 0;30 var open_dirs_count: u32 = 0;
31 defer Io.Dir.closeMany(io, open_dir_cache[0..open_dirs_count]);31 defer Io.Dir.closeMany(io, open_dir_cache[0..open_dirs_count]);
3232
33 for (directories, open_dir_cache) |conf_dir, *opened_dir| {
34 const src_lazy_path = conf_dir.src_path.get(conf);
35 const src_dir_path = try maker.resolveLazyPath(arena, src_lazy_path, step_index);
36
37 opened_dir.* = src_dir_path.root_dir.handle.openDir(io, src_dir_path.subPathOrDot(), .{ .iterate = true }) catch |err| {
38 return step.fail(maker, "failed opening source directory {f}: {t}", .{ src_dir_path, err });
39 };
40 open_dirs_count += 1;
41 }
42
33 // Doesn't yet include contents of directories.43 // Doesn't yet include contents of directories.
34 var total_items: usize = conf_wf.embeds.slice.len + conf_wf.copies.slice.len + conf_wf.directories.slice.len;44 var total_items: usize = conf_wf.embeds.slice.len + conf_wf.copies.slice.len + conf_wf.directories.slice.len;
35 progress_node.setEstimatedTotalItems(total_items);45 progress_node.setEstimatedTotalItems(total_items);
...@@ -58,7 +68,7 @@ pub fn make(...@@ -58,7 +68,7 @@ pub fn make(
58 try step.addWatchInput(maker, arena, src_lazy_path);68 try step.addWatchInput(maker, arena, src_lazy_path);
59 }69 }
6070
61 for (directories, open_dir_cache) |conf_dir, *opened_dir| {71 for (directories, open_dir_cache) |conf_dir, src_dir| {
62 const exclude_extensions = conf_dir.exclude_extensions.slice(conf) orelse &.{};72 const exclude_extensions = conf_dir.exclude_extensions.slice(conf) orelse &.{};
63 const include_extensions = conf_dir.include_extensions.slice(conf);73 const include_extensions = conf_dir.include_extensions.slice(conf);
6474
...@@ -72,12 +82,6 @@ pub fn make(...@@ -72,12 +82,6 @@ pub fn make(
72 const need_derived_inputs = try step.addDirectoryWatchInput(maker, src_lazy_path);82 const need_derived_inputs = try step.addDirectoryWatchInput(maker, src_lazy_path);
73 const src_dir_path = try maker.resolveLazyPath(arena, src_lazy_path, step_index);83 const src_dir_path = try maker.resolveLazyPath(arena, src_lazy_path, step_index);
7484
75 var src_dir = src_dir_path.root_dir.handle.openDir(io, src_dir_path.subPathOrDot(), .{ .iterate = true }) catch |err| {
76 return step.fail(maker, "failed opening source directory {f}: {t}", .{ src_dir_path, err });
77 };
78 opened_dir.* = src_dir;
79 open_dirs_count += 1;
80
81 var it = try src_dir.walk(gpa);85 var it = try src_dir.walk(gpa);
82 defer it.deinit();86 defer it.deinit();
83 while (it.next(io) catch |err| switch (err) {87 while (it.next(io) catch |err| switch (err) {