authorgravatar for sachabarsayuracko@gmail.comglowsquid <sachabarsayuracko@gmail.com> 2026-04-22 02:00:41+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-22 02:00:41+02:00
log0b768cd9ddc4dde512647cd60617db23ed6ec434
treef60e4bd2294d602f49ca3d69ae36d61db3a1f602
parent3ea77badf94d996740337f6ce6e6612178627dd1

zig reduce: fix compilation (#31930)

fixes #31926 Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31930 Reviewed-by: Andrew Kelley <andrew@ziglang.org>

4 files changed, 17 insertions(+), 7 deletions(-)

ci/aarch64-macos-release.sh+3
...@@ -55,6 +55,9 @@ stage3-release/bin/zig build test docs \...@@ -55,6 +55,9 @@ stage3-release/bin/zig build test docs \
55stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=ReleaseSafe55stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=ReleaseSafe
56stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug56stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug
5757
58# Ensure that reduce compiles
59stage3-release/bin/zig reduce -h
60
58# Ensure that stage3 and stage4 are byte-for-byte identical.61# Ensure that stage3 and stage4 are byte-for-byte identical.
59stage3-release/bin/zig build \62stage3-release/bin/zig build \
60 --maxrss ${ZSF_MAX_RSS:-0} \63 --maxrss ${ZSF_MAX_RSS:-0} \
ci/x86_64-linux-release.sh+3
...@@ -77,6 +77,9 @@ stage3-release/bin/zig build test docs \...@@ -77,6 +77,9 @@ stage3-release/bin/zig build test docs \
77stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=ReleaseSafe77stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=ReleaseSafe
78stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug78stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug
7979
80# Ensure that reduce compiles
81stage3-release/bin/zig reduce -h
82
80# Ensure that stage3 and stage4 are byte-for-byte identical.83# Ensure that stage3 and stage4 are byte-for-byte identical.
81stage3-release/bin/zig build \84stage3-release/bin/zig build \
82 --prefix stage4-release \85 --prefix stage4-release \
ci/x86_64-windows-release.ps1+4
...@@ -61,6 +61,10 @@ CheckLastExitCode...@@ -61,6 +61,10 @@ CheckLastExitCode
61# stage3-release\bin\zig.exe build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug61# stage3-release\bin\zig.exe build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug
62# CheckLastExitCode62# CheckLastExitCode
6363
64# Ensure that reduce compiles
65stage3-release\bin\zig.exe build reduce -h
66CheckLastExitCode
67
64# Ensure that stage3 and stage4 are byte-for-byte identical.68# Ensure that stage3 and stage4 are byte-for-byte identical.
65Write-Output "Build and compare stage4..."69Write-Output "Build and compare stage4..."
66stage3-release\bin\zig.exe build `70stage3-release\bin\zig.exe build `
lib/compiler/reduce/Walk.zig+7-7
...@@ -6,9 +6,9 @@ const BuiltinFn = std.zig.BuiltinFn;...@@ -6,9 +6,9 @@ const BuiltinFn = std.zig.BuiltinFn;
66
7ast: *const Ast,7ast: *const Ast,
8transformations: *std.array_list.Managed(Transformation),8transformations: *std.array_list.Managed(Transformation),
9unreferenced_globals: std.StringArrayHashMapUnmanaged(Ast.Node.Index),9unreferenced_globals: std.array_hash_map.String(Ast.Node.Index),
10in_scope_names: std.StringArrayHashMapUnmanaged(u32),10in_scope_names: std.array_hash_map.String(u32),
11replace_names: std.StringArrayHashMapUnmanaged(u32),11replace_names: std.array_hash_map.String(u32),
12gpa: std.mem.Allocator,12gpa: std.mem.Allocator,
13arena: std.mem.Allocator,13arena: std.mem.Allocator,
1414
...@@ -63,9 +63,9 @@ pub fn findTransformations(...@@ -63,9 +63,9 @@ pub fn findTransformations(
63 .transformations = transformations,63 .transformations = transformations,
64 .gpa = transformations.allocator,64 .gpa = transformations.allocator,
65 .arena = arena,65 .arena = arena,
66 .unreferenced_globals = .{},66 .unreferenced_globals = .empty,
67 .in_scope_names = .{},67 .in_scope_names = .empty,
68 .replace_names = .{},68 .replace_names = .empty,
69 };69 };
70 defer {70 defer {
71 walk.unreferenced_globals.deinit(walk.gpa);71 walk.unreferenced_globals.deinit(walk.gpa);
...@@ -607,7 +607,7 @@ fn walkBlock(...@@ -607,7 +607,7 @@ fn walkBlock(
607 {607 {
608 try w.transformations.append(.{ .delete_var_decl = .{608 try w.transformations.append(.{ .delete_var_decl = .{
609 .var_decl_node = stmt,609 .var_decl_node = stmt,
610 .references = .{},610 .references = .empty,
611 } });611 } });
612 const name_tok = var_decl.ast.mut_token + 1;612 const name_tok = var_decl.ast.mut_token + 1;
613 const name_bytes = ast.tokenSlice(name_tok);613 const name_bytes = ast.tokenSlice(name_tok);