authorgravatar for goon.pri.low@gmail.comKendall Condon <goon.pri.low@gmail.com> 2026-04-20 17:43:49-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:37:23-07:00
loge1ce81eb546e10ae505b411b6882266d1834fce1
tree373df001de7f20af02de0d675087fd5071ca7675
parenta9423234a6a4eb5bad25e12829b5a1a09ba9ca96

link.Elf: fix large abi aligned globals


3 files changed, 11 insertions(+), 2 deletions(-)

src/link/Elf/ZigObject.zig+1-1
......@@ -1386,7 +1386,7 @@ fn updateNavCode(
13861386 .none => switch (mod.optimize_mode) {
13871387 .Debug, .ReleaseSafe, .ReleaseFast => target_util.defaultFunctionAlignment(target),
13881388 .ReleaseSmall => target_util.minFunctionAlignment(target),
1389 },
1389 }.maxStrict(Type.fromInterned(nav.resolved.?.type).abiAlignment(zcu)),
13901390 else => |a| a.maxStrict(target_util.minFunctionAlignment(target)),
13911391 };
13921392
src/link/Elf2.zig+1-1
......@@ -2863,7 +2863,7 @@ fn navMapIndex(elf: *Elf, zcu: *Zcu, nav_index: InternPool.Nav.Index) !Node.NavM
28632863 .ReleaseFast,
28642864 => target_util.defaultFunctionAlignment(target),
28652865 .ReleaseSmall => min,
2866 },
2866 }.maxStrict(Type.fromInterned(nav.resolved.?.type).abiAlignment(zcu)),
28672867 };
28682868 },
28692869 else => switch (nav.resolved.?.@"align") {
test/behavior/align.zig+9
......@@ -15,6 +15,15 @@ test "global variable alignment" {
1515 }
1616}
1717
18test "large abi alignment of global" {
19 const S = struct {
20 var global: @This() = undefined;
21 x: u64 align(64),
22 };
23
24 try std.testing.expect(@ctz(@intFromPtr(&S.global)) >= 6);
25}
26
1827test "large alignment of local constant" {
1928 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
2029 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; // flaky