From 47e208e554776aa4f5f3fe74d6f8d995efa3aaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 15 Jun 2026 14:34:09 +0200 Subject: [PATCH 1/2] std.lang: fix accidentally swapped VaList layouts for hexagon and s390x contributes to https://codeberg.org/ziglang/zig/issues/35523 --- lib/std/lang.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/std/lang.zig b/lib/std/lang.zig index 10ed06a85f2493e1acba401f6357855a3325bd39..7f04a24804bc5cafb02fc6d83c8fd7d3fedaeac8 100644 --- a/lib/std/lang.zig +++ b/lib/std/lang.zig @@ -1000,10 +1000,9 @@ pub const VaListArm = extern struct { /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub const VaListHexagon = extern struct { - __gpr: c_long, - __fpr: c_long, - __overflow_arg_area: *anyopaque, - __reg_save_area: *anyopaque, + __current_saved_reg_area_pointer: *anyopaque, + __saved_reg_area_end_pointer: *anyopaque, + __overflow_area_pointer: *anyopaque, }; /// This data structure is used by the Zig language code generation and @@ -1019,9 +1018,10 @@ pub const VaListPowerPc = extern struct { /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub const VaListS390x = extern struct { - __current_saved_reg_area_pointer: *anyopaque, - __saved_reg_area_end_pointer: *anyopaque, - __overflow_area_pointer: *anyopaque, + __gpr: c_long, + __fpr: c_long, + __overflow_arg_area: *anyopaque, + __reg_save_area: *anyopaque, }; /// This data structure is used by the Zig language code generation and -- 2.54.0 From daf3cca1a491636dcd2cde45b12bc3bfcfbab69c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 15 Jun 2026 14:17:03 +0200 Subject: [PATCH 2/2] compiler: fix struct field alignment for big ints on s390x contributes to https://codeberg.org/ziglang/zig/issues/35523 --- src/Type.zig | 2 +- test/behavior/align.zig | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Type.zig b/src/Type.zig index 3f45e0c6e7b74cf9fac12a3ce50f43ed3d50c3fe..50bf56dcc49e2727fb98846729a410dcc6d678d3 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -2521,7 +2521,7 @@ pub fn defaultStructFieldAlignment( ((field_ty.isAbiInt(zcu) and field_ty.intInfo(zcu).bits > 64) or (field_ty.toIntern() == .f80_type and zcu.getTarget().cTypeBitSize(.longdouble) != 80))) { - return abi_align.maxStrict(.@"16"); + return abi_align.maxStrict(if (zcu.getTarget().cpu.arch == .s390x) .@"8" else .@"16"); } return abi_align; } diff --git a/test/behavior/align.zig b/test/behavior/align.zig index bca8094052fd8ef06db380be7dd95c98297cef2f..7306ef388f0d534bd8a11a14dffd49d94128aec6 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -133,6 +133,20 @@ test "alignment and size of structs with 128-bit fields" { y: u8, }; const expected = switch (builtin.cpu.arch) { + .s390x, + => .{ + .a_align = 8, + .a_size = 16, + + .b_align = 8, + .b_size = 24, + + .u128_align = 8, + .u128_size = 16, + .u129_align = 8, + .u129_size = 24, + }, + .amdgcn, .arm, .armeb, @@ -145,7 +159,6 @@ test "alignment and size of structs with 128-bit fields" { .powerpc, .powerpcle, .riscv32, - .s390x, => .{ .a_align = 8, .a_size = 16, @@ -191,7 +204,7 @@ test "alignment and size of structs with 128-bit fields" { else => return error.SkipZigTest, }; - const min_struct_align = if (builtin.zig_backend == .stage2_c) 16 else 0; + const min_struct_align = if (builtin.zig_backend == .stage2_c) if (builtin.cpu.arch == .s390x) 8 else 16 else 0; comptime { assert(@alignOf(A) == @max(expected.a_align, min_struct_align)); assert(@sizeOf(A) == expected.a_size); -- 2.54.0