zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit beb507a1edadb2829478d066b80ea62ed537157a (tree)
parent a1441943e41014cfbce3105c4cdd9d3e0d137e4f
Author: Alex Rønne Petersen <alex@alexrp.com>
Date:   Sun, 19 Oct 2025 22:40:15 +0200

std.builtin: add CallingConvention.x86_64_x32

This was forgotten during the refactoring of std.builtin.CallingConvention. It
mirrors mips64_n32 for MIPS.

Diffstat:
Mlib/std/Target.zig | 6+++++-
Mlib/std/builtin.zig | 1+
Msrc/Sema.zig | 1+
Msrc/codegen/llvm.zig | 1+
Mtest/cases/compile_errors/invalid_variadic_function.zig | 4++--
Mtest/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig | 2+-
6 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/std/Target.zig b/lib/std/Target.zig @@ -1787,6 +1787,7 @@ pub const Cpu = struct { => unreachable, .x86_64_sysv, + .x86_64_x32, .x86_64_win, .x86_64_regcall_v3_sysv, .x86_64_regcall_v4_win, @@ -3632,7 +3633,10 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention return switch (target.cpu.arch) { .x86_64 => switch (target.os.tag) { .windows, .uefi => .{ .x86_64_win = .{} }, - else => .{ .x86_64_sysv = .{} }, + else => switch (target.abi) { + .gnuabin32, .muslabin32 => .{ .x86_64_x32 = .{} }, + else => .{ .x86_64_sysv = .{} }, + }, }, .x86 => switch (target.os.tag) { .windows, .uefi => .{ .x86_win = .{} }, diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig @@ -204,6 +204,7 @@ pub const CallingConvention = union(enum(u8)) { // Calling conventions for the `x86_64` architecture. x86_64_sysv: CommonOptions, + x86_64_x32: CommonOptions, x86_64_win: CommonOptions, x86_64_regcall_v3_sysv: CommonOptions, x86_64_regcall_v4_win: CommonOptions, diff --git a/src/Sema.zig b/src/Sema.zig @@ -9035,6 +9035,7 @@ pub fn handleExternLibName( /// functions or there are no more other calling conventions that support variadic functions. const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention.Tag{ .x86_64_sysv, + .x86_64_x32, .x86_64_win, .x86_sysv, .x86_win, diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig @@ -11919,6 +11919,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *const s .x86_sysv, .x86_win, .x86_thiscall_mingw, + .x86_64_x32, .aarch64_aapcs, .aarch64_aapcs_darwin, .aarch64_aapcs_win, diff --git a/test/cases/compile_errors/invalid_variadic_function.zig b/test/cases/compile_errors/invalid_variadic_function.zig @@ -12,6 +12,6 @@ comptime { // target=x86_64-linux // // :1:8: error: variadic function does not support 'auto' calling convention -// :1:8: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' +// :1:8: note: supported calling conventions: 'x86_64_sysv', 'x86_64_x32', 'x86_64_win' // :2:16: error: variadic function does not support 'inline' calling convention -// :2:16: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' +// :2:16: note: supported calling conventions: 'x86_64_sysv', 'x86_64_x32', 'x86_64_win' diff --git a/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig b/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig @@ -15,4 +15,4 @@ comptime { // target=x86_64-linux // // :1:13: error: variadic function does not support 'auto' calling convention -// :1:13: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' +// :1:13: note: supported calling conventions: 'x86_64_sysv', 'x86_64_x32', 'x86_64_win'