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(
3030 var open_dirs_count: u32 = 0;
3131 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
3343 // Doesn't yet include contents of directories.
3444 var total_items: usize = conf_wf.embeds.slice.len + conf_wf.copies.slice.len + conf_wf.directories.slice.len;
3545 progress_node.setEstimatedTotalItems(total_items);
......@@ -58,7 +68,7 @@ pub fn make(
5868 try step.addWatchInput(maker, arena, src_lazy_path);
5969 }
6070
61 for (directories, open_dir_cache) |conf_dir, *opened_dir| {
71 for (directories, open_dir_cache) |conf_dir, src_dir| {
6272 const exclude_extensions = conf_dir.exclude_extensions.slice(conf) orelse &.{};
6373 const include_extensions = conf_dir.include_extensions.slice(conf);
6474
......@@ -72,12 +82,6 @@ pub fn make(
7282 const need_derived_inputs = try step.addDirectoryWatchInput(maker, src_lazy_path);
7383 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
8185 var it = try src_dir.walk(gpa);
8286 defer it.deinit();
8387 while (it.next(io) catch |err| switch (err) {