commit cfeab9258739f44b73542952b3ca62c1187669e1 (tree)
parent 14bc6f5917ae94902cdf209e3ac9af908b506795
Author: Alex Rønne Petersen <alex@alexrp.com>
Date: Thu, 18 Jun 2026 12:45:27 +0200
Merge pull request 'add full support for libc-less `x86_64-linux-x32` and `mips64(el)-linux-abin32`' (#35828) from alexrp/zig:x32-n32 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35828
Diffstat:
16 files changed, 160 insertions(+), 105 deletions(-)
diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig
@@ -2271,6 +2271,8 @@ pub const TargetQuery = struct {
gnux32,
eabi,
eabihf,
+ abin32,
+ x32,
ilp32,
android,
androideabi,
@@ -2304,6 +2306,8 @@ pub const TargetQuery = struct {
.gnux32 => .gnux32,
.eabi => .eabi,
.eabihf => .eabihf,
+ .abin32 => .abin32,
+ .x32 => .x32,
.ilp32 => .ilp32,
.android => .android,
.androideabi => .androideabi,
@@ -2337,6 +2341,8 @@ pub const TargetQuery = struct {
.gnux32 => .gnux32,
.eabi => .eabi,
.eabihf => .eabihf,
+ .abin32 => .abin32,
+ .x32 => .x32,
.ilp32 => .ilp32,
.android => .android,
.androideabi => .androideabi,
diff --git a/lib/std/Target.zig b/lib/std/Target.zig
@@ -796,6 +796,8 @@ pub const Abi = enum {
gnux32,
eabi,
eabihf,
+ abin32,
+ x32,
ilp32,
android,
androideabi,
@@ -887,8 +889,12 @@ pub const Abi = enum {
=> .muslabi64,
// No musl support.
+ .alpha,
.arc,
.arceb,
+ .or1k,
+ .sparc,
+ .sparc64,
=> .gnu,
.csky,
=> .gnueabi,
@@ -2920,10 +2926,17 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
switch (abi) {
- .gnux32, .muslx32, .gnuabin32, .muslabin32, .ilp32 => return 32,
- .gnuabi64, .muslabi64 => return 64,
+ .gnux32,
+ .muslx32,
+ .x32,
+ .gnuabin32,
+ .muslabin32,
+ .abin32,
+ .ilp32,
+ => return 32,
else => {},
}
+
return switch (cpu_arch) {
.avr,
.msp430,
@@ -3002,12 +3015,12 @@ pub fn ptrBitWidth(target: *const Target) u16 {
pub fn stackAlignment(target: *const Target) u16 {
// Overrides for when the stack alignment is not equal to the pointer width.
switch (target.cpu.arch) {
- .ez80,
- => return 1,
- .m68k,
- => return 2,
- .amdgcn,
- => return 4,
+ .ez80 => return 1,
+
+ .m68k => return 2,
+
+ .amdgcn => return 4,
+
.arm,
.armeb,
.hppa,
@@ -3018,6 +3031,7 @@ pub fn stackAlignment(target: *const Target) u16 {
.thumb,
.thumbeb,
=> return 8,
+
.aarch64,
.aarch64_be,
.alpha,
@@ -3034,18 +3048,23 @@ pub fn stackAlignment(target: *const Target) u16 {
.wasm64,
.x86_64,
=> return 16,
+
// Some of the following prongs should really be testing the ABI, but our current `Abi` enum
// can't handle that level of nuance yet.
.powerpc64,
.powerpc64le,
=> if (target.os.tag == .linux) return 16,
+
.riscv32,
.riscv32be,
.riscv64,
.riscv64be,
=> if (!target.cpu.has(.riscv, .e)) return 16,
+
.x86 => if (target.os.tag != .windows and target.os.tag != .uefi) return 16,
+
.kvx => return 32,
+
else => {},
}
@@ -3148,7 +3167,9 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) u16 {
pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
switch (target.os.tag) {
.freestanding, .other => switch (target.cpu.arch) {
- .msp430, .x86_16 => switch (c_type) {
+ .msp430,
+ .x86_16,
+ => switch (c_type) {
.char => return 8,
.short, .ushort, .int, .uint => return 16,
.float, .long, .ulong => return 32,
@@ -3160,12 +3181,14 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.long, .ulong, .float, .double, .longdouble => return 32,
.longlong, .ulonglong => return 64,
},
- .mips64, .mips64el => switch (c_type) {
+ .mips64,
+ .mips64el,
+ => switch (c_type) {
.char => return 8,
.short, .ushort => return 16,
.int, .uint, .float => return 32,
.long, .ulong => switch (target.abi) {
- .gnuabin32, .muslabin32 => return 32,
+ .abin32 => return 32,
else => return 64,
},
.longlong, .ulonglong, .double => return 64,
@@ -3176,7 +3199,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.short, .ushort => return 16,
.int, .uint, .float => return 32,
.long, .ulong => switch (target.abi) {
- .gnux32, .muslx32 => return 32,
+ .x32 => return 32,
else => return 64,
},
.longlong, .ulonglong, .double => return 64,
@@ -3189,25 +3212,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.long, .ulong => return target.ptrBitWidth(),
.longlong, .ulonglong, .double => return 64,
.longdouble => switch (target.cpu.arch) {
- .x86 => switch (target.abi) {
- .android => return 64,
- else => return 80,
- },
-
- .powerpc,
- .powerpcle,
- .powerpc64,
- .powerpc64le,
- => switch (target.abi) {
- .musl,
- .muslabin32,
- .muslabi64,
- .musleabi,
- .musleabihf,
- .muslx32,
- => return 64,
- else => return 128,
- },
+ .x86 => return 80,
.alpha,
.riscv32,
@@ -3216,6 +3221,10 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.riscv64be,
.aarch64,
.aarch64_be,
+ .powerpc,
+ .powerpcle,
+ .powerpc64,
+ .powerpc64le,
.s390x,
.sparc64,
.wasm32,
@@ -3249,23 +3258,25 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.wasi,
.emscripten,
=> switch (target.cpu.arch) {
- .mips64, .mips64el => switch (c_type) {
+ .mips64,
+ .mips64el,
+ => switch (c_type) {
.char => return 8,
.short, .ushort => return 16,
.int, .uint, .float => return 32,
.long, .ulong => switch (target.abi) {
- .gnuabin32, .muslabin32 => return 32,
+ .gnuabin32, .muslabin32, .abin32 => return 32,
else => return 64,
},
.longlong, .ulonglong, .double => return 64,
- .longdouble => if (target.os.tag == .freebsd) return 64 else return 128,
+ .longdouble => return 128,
},
.x86_64 => switch (c_type) {
.char => return 8,
.short, .ushort => return 16,
.int, .uint, .float => return 32,
.long, .ulong => switch (target.abi) {
- .gnux32, .muslx32 => return 32,
+ .gnux32, .muslx32, .x32 => return 32,
else => return 64,
},
.longlong, .ulonglong, .double => return 64,
@@ -3286,15 +3297,11 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.powerpc,
.powerpcle,
=> switch (target.abi) {
- .musl,
- .muslabin32,
- .muslabi64,
- .musleabi,
- .musleabihf,
- .muslx32,
- => return 64,
+ .musleabi, .musleabihf => return 64,
else => switch (target.os.tag) {
- .freebsd, .netbsd, .openbsd => return 64,
+ .netbsd,
+ .openbsd,
+ => return 64,
else => return 128,
},
},
@@ -3302,15 +3309,11 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.powerpc64,
.powerpc64le,
=> switch (target.abi) {
- .musl,
- .muslabin32,
- .muslabi64,
- .musleabi,
- .musleabihf,
- .muslx32,
- => return 64,
+ .musl => return 64,
else => switch (target.os.tag) {
- .freebsd, .openbsd => return 64,
+ .freebsd,
+ .openbsd,
+ => return 64,
else => return 128,
},
},
@@ -3346,7 +3349,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.long, .ulong => return 32,
.longlong, .ulonglong, .double => return 64,
.longdouble => switch (target.abi) {
- .gnu, .ilp32 => return 80,
+ .gnu => return 80,
else => return 64,
},
},
@@ -3357,7 +3360,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.long, .ulong => return 32,
.longlong, .ulonglong, .double => return 64,
.longdouble => switch (target.abi) {
- .gnu, .ilp32 => return 80,
+ .gnu => return 80,
else => return 64,
},
},
@@ -3476,12 +3479,14 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
// Overrides for unusual alignments
switch (target.cpu.arch) {
- .avr, .ez80 => return 1,
+ .avr,
+ .ez80,
+ => return 1,
.x86 => switch (target.os.tag) {
.windows, .uefi => switch (c_type) {
.longlong, .ulonglong, .double => return 8,
.longdouble => switch (target.abi) {
- .gnu, .ilp32 => return 4,
+ .gnu => return 4,
else => return 8,
},
else => {},
@@ -3506,8 +3511,6 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
return @min(
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
@as(u16, switch (target.cpu.arch) {
- .ez80 => 1,
-
.msp430,
.x86_16,
=> 2,
@@ -3575,6 +3578,7 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
=> 16,
.avr,
+ .ez80,
=> unreachable, // Handled above.
}),
);
@@ -3587,11 +3591,13 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
.longdouble => return 4,
else => {},
},
- .avr, .ez80 => return 1,
+ .avr,
+ .ez80,
+ => return 1,
.x86 => switch (target.os.tag) {
.windows, .uefi => switch (c_type) {
.longdouble => switch (target.abi) {
- .gnu, .ilp32 => return 4,
+ .gnu => return 4,
else => return 8,
},
else => {},
@@ -3619,9 +3625,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
return @min(
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
@as(u16, switch (target.cpu.arch) {
- .ez80 => 1,
-
- .x86_16, .msp430 => 2,
+ .x86_16,
+ .msp430,
+ => 2,
.arc,
.arceb,
@@ -3686,6 +3692,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
=> 16,
.avr,
+ .ez80,
=> unreachable, // Handled above.
}),
);
@@ -3697,7 +3704,9 @@ pub fn cMaxIntAlignment(target: *const Target) u16 {
.ez80,
=> 1,
- .msp430, .x86_16 => 2,
+ .msp430,
+ .x86_16,
+ => 2,
.arc,
.arceb,
@@ -3766,14 +3775,18 @@ pub fn cMaxIntAlignment(target: *const Target) u16 {
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 = .{} },
+ .windows,
+ .uefi,
+ => .{ .x86_64_win = .{} },
else => switch (target.abi) {
- .gnux32, .muslx32 => .{ .x86_64_x32 = .{} },
+ .gnux32, .muslx32, .x32 => .{ .x86_64_x32 = .{} },
else => .{ .x86_64_sysv = .{} },
},
},
.x86 => switch (target.os.tag) {
- .windows, .uefi => .{ .x86_win = .{} },
+ .windows,
+ .uefi,
+ => .{ .x86_win = .{} },
else => .{ .x86_sysv = .{} },
},
.x86_16 => .{ .x86_16_cdecl = .{} },
@@ -3789,7 +3802,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
.hard => .{ .arm_aapcs_vfp = .{} },
},
.mips64, .mips64el => switch (target.abi) {
- .gnuabin32, .muslabin32 => .{ .mips64_n32 = .{} },
+ .gnuabin32, .muslabin32, .abin32 => .{ .mips64_n32 = .{} },
else => .{ .mips64_n64 = .{} },
},
.mips, .mipsel => .{ .mips_o32 = .{} },
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
@@ -1171,7 +1171,7 @@ const LinuxThreadImpl = struct {
[len] "{ecx}" (self.mapped.len),
),
.x86_64 => asm volatile (switch (target.abi) {
- .gnux32, .muslx32 =>
+ .gnux32, .muslx32, .x32 =>
\\ movl $0x4000000b, %%eax # SYS_munmap
\\ syscall
\\ movl $0x4000003c, %%eax # SYS_exit
@@ -1286,7 +1286,7 @@ const LinuxThreadImpl = struct {
[len] "{$5}" (self.mapped.len),
),
.mips64, .mips64el => asm volatile (switch (target.abi) {
- .gnuabin32, .muslabin32 =>
+ .gnuabin32, .muslabin32, .abin32 =>
\\ li $v0, 6011 # SYS_munmap
\\ syscall
\\ li $v0, 6058 # SYS_exit
diff --git a/lib/std/debug/Dwarf/expression.zig b/lib/std/debug/Dwarf/expression.zig
@@ -1158,7 +1158,7 @@ test "basics" {
// TODO: Test fbreg (once implemented): mock a DIE and point compile_unit.frame_base at it
- mem.writeInt(usize, reg_bytes[0..@sizeOf(usize)], 0xee, native_endian);
+ mem.writeInt(std.debug.cpu_context.Native.Gpr, reg_bytes[0..@sizeOf(std.debug.cpu_context.Native.Gpr)], 0xee, native_endian);
(try regNative(&cpu_context, fp_reg_num)).* = 1;
(try regNative(&cpu_context, ip_reg_num)).* = 2;
@@ -1566,7 +1566,7 @@ test "basics" {
context = .{ .cpu_context = &cpu_context };
const reg_bytes = try cpu_context.dwarfRegisterBytes(0);
- mem.writeInt(usize, reg_bytes[0..@sizeOf(usize)], 0xee, native_endian);
+ mem.writeInt(std.debug.cpu_context.Native.Gpr, reg_bytes[0..@sizeOf(std.debug.cpu_context.Native.Gpr)], 0xee, native_endian);
var sub_program: std.Io.Writer.Allocating = .init(allocator);
defer sub_program.deinit();
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
@@ -43,7 +43,7 @@ const arch_bits = switch (native_arch) {
.microblaze, .microblazeel => @import("linux/microblaze.zig"),
.mips, .mipsel => @import("linux/mips.zig"),
.mips64, .mips64el => switch (builtin.abi) {
- .gnuabin32, .muslabin32 => @import("linux/mipsn32.zig"),
+ .gnuabin32, .muslabin32, .abin32 => @import("linux/mipsn32.zig"),
else => @import("linux/mips64.zig"),
},
.or1k => @import("linux/or1k.zig"),
@@ -57,7 +57,7 @@ const arch_bits = switch (native_arch) {
.sparc64 => @import("linux/sparc64.zig"),
.x86 => @import("linux/x86.zig"),
.x86_64 => switch (builtin.abi) {
- .gnux32, .muslx32 => @import("linux/x32.zig"),
+ .gnux32, .muslx32, .x32 => @import("linux/x32.zig"),
else => @import("linux/x86_64.zig"),
},
.xtensa, .xtensaeb => @import("linux/xtensa.zig"),
@@ -144,7 +144,7 @@ pub const SYS = switch (native_arch) {
.microblaze, .microblazeel => syscalls.Microblaze,
.mips, .mipsel => syscalls.MipsO32,
.mips64, .mips64el => switch (builtin.abi) {
- .gnuabin32, .muslabin32 => syscalls.MipsN32,
+ .gnuabin32, .muslabin32, .abin32 => syscalls.MipsN32,
else => syscalls.MipsN64,
},
.or1k => syscalls.OpenRisc,
@@ -158,7 +158,7 @@ pub const SYS = switch (native_arch) {
.sparc64 => syscalls.Sparc64,
.x86 => syscalls.X86,
.x86_64 => switch (builtin.abi) {
- .gnux32, .muslx32 => syscalls.X32,
+ .gnux32, .muslx32, .x32 => syscalls.X32,
else => syscalls.X64,
},
.xtensa, .xtensaeb => syscalls.Xtensa,
@@ -1828,8 +1828,10 @@ pub fn lseek(fd: fd_t, offset: off_t, whence: u32) u64 {
return switch (builtin.abi) {
.gnuabin32,
.muslabin32,
+ .abin32,
.gnux32,
.muslx32,
+ .x32,
=> syscall_lseek(fd, offset, whence),
else => syscall3(.lseek, @as(u32, @bitCast(fd)), @as(u64, @bitCast(offset)), whence),
};
@@ -2006,7 +2008,7 @@ pub const F = struct {
const SETLKW = 35;
},
.mips64, .mips64el => switch (native_abi) {
- .gnuabin32, .muslabin32 => struct {
+ .gnuabin32, .muslabin32, .abin32 => struct {
const GETLK = 33;
const SETLK = 34;
const SETLKW = 35;
@@ -3187,7 +3189,7 @@ pub fn tee(src: fd_t, dest: fd_t, len: usize, flags: u32) usize {
}
pub const Sysinfo = switch (native_abi) {
- .gnux32, .muslx32 => extern struct {
+ .gnux32, .muslx32, .x32 => extern struct {
/// Seconds since boot
uptime: i64,
/// 1, 5, and 15 minute load averages
@@ -10753,11 +10755,11 @@ pub const AUDIT = struct {
.mips => .MIPS,
.mipsel => .MIPSEL,
.mips64 => switch (native_abi) {
- .gnuabin32, .muslabin32 => .MIPS64N32,
+ .gnuabin32, .muslabin32, .abin32 => .MIPS64N32,
else => .MIPS64,
},
.mips64el => switch (native_abi) {
- .gnuabin32, .muslabin32 => .MIPSEL64N32,
+ .gnuabin32, .muslabin32, .abin32 => .MIPSEL64N32,
else => .MIPSEL64,
},
.or1k => .OPENRISC,
diff --git a/lib/std/os/linux/mipsn32.zig b/lib/std/os/linux/mipsn32.zig
@@ -219,8 +219,8 @@ pub fn clone() callconv(.naked) u32 {
\\ move $fp, $zero
\\ move $ra, $zero
\\
- \\ ld $t9, 0($sp)
- \\ ld $a0, 4($sp)
+ \\ lw $t9, 0($sp)
+ \\ lw $a0, 4($sp)
\\ jalr $t9
\\
\\ move $a0, $v0
diff --git a/lib/std/pie.zig b/lib/std/pie.zig
@@ -162,7 +162,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
:
: .{ .lr = true }),
.mips64, .mips64el => switch (builtin.abi) {
- .gnuabin32, .muslabin32 => asm volatile (
+ .gnuabin32, .muslabin32, .abin32 => asm volatile (
\\ .weak _DYNAMIC
\\ .hidden _DYNAMIC
\\ bal 1f
diff --git a/lib/std/start.zig b/lib/std/start.zig
@@ -373,7 +373,7 @@ fn _start() callconv(.naked) noreturn {
\\ jalr $t9
,
.mips64, .mips64el => switch (builtin.abi) {
- .gnuabin32, .muslabin32 =>
+ .gnuabin32, .muslabin32, .abin32 =>
\\ move $fp, $zero
\\ bal 1f
\\ .gpword .
diff --git a/lib/std/zig/LibCDirs.zig b/lib/std/zig/LibCDirs.zig
@@ -282,6 +282,8 @@ fn libCGenericName(target: *const std.Target) [:0]const u8 {
=> return "musl",
.eabi,
.eabihf,
+ .abin32,
+ .x32,
.ilp32,
.android,
.androideabi,
diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig
@@ -104,7 +104,7 @@ pub fn getExternalExecutor(io: Io, candidate: *const std.Target, options: GetExt
=> .{ .qemu = switch (t) {
.x86 => "qemu-i386",
.x86_64 => switch (candidate.abi) {
- .gnux32, .muslx32 => return bad_result,
+ .gnux32, .muslx32, .x32 => return bad_result,
else => "qemu-x86_64",
},
else => "qemu-" ++ @tagName(t),
@@ -146,7 +146,7 @@ pub fn getExternalExecutor(io: Io, candidate: *const std.Target, options: GetExt
.powerpc64 => "qemu-ppc64",
.powerpc64le => "qemu-ppc64le",
.mips64, .mips64el => switch (candidate.abi) {
- .gnuabin32, .muslabin32 => if (t == .mips64el) "qemu-mipsn32el" else "qemu-mipsn32",
+ .gnuabin32, .muslabin32, .abin32 => if (t == .mips64el) "qemu-mipsn32el" else "qemu-mipsn32",
else => "qemu-" ++ @tagName(t),
},
// TODO: Actually check the SuperH version.
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
@@ -285,6 +285,8 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
.ilp32 => "unknown",
.eabi => "eabi",
.eabihf => "eabihf",
+ .abin32 => "unknown",
+ .x32 => "muslx32", // https://github.com/ziglang/zig/issues/25649
.android => "android",
.androideabi => "androideabi",
.musl => switch (target.os.tag) {
@@ -377,11 +379,11 @@ pub fn dataLayout(target: *const std.Target) []const u8 {
.mips => "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64",
.mipsel => "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64",
.mips64 => switch (target.abi) {
- .gnuabin32, .muslabin32 => "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
+ .gnuabin32, .muslabin32, .abin32 => "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
else => "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
},
.mips64el => switch (target.abi) {
- .gnuabin32, .muslabin32 => "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
+ .gnuabin32, .muslabin32, .abin32 => "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
else => "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
},
.m68k => "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16",
@@ -446,7 +448,7 @@ pub fn dataLayout(target: *const std.Target) []const u8 {
.x86_64 => if (target.os.tag.isDarwin() or target.ofmt == .macho)
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
else switch (target.abi) {
- .gnux32, .muslx32 => "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
+ .gnux32, .muslx32, .x32 => "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
else => if ((target.os.tag == .windows or target.os.tag == .uefi) and target.ofmt == .coff)
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
else
diff --git a/src/link/Lld.zig b/src/link/Lld.zig
@@ -1295,21 +1295,21 @@ fn getLDMOption(target: *const std.Target) ?[]const u8 {
},
.mips64 => switch (target.os.tag) {
.freebsd => switch (target.abi) {
- .gnuabin32, .muslabin32 => "elf32btsmipn32_fbsd",
+ .gnuabin32, .muslabin32, .abin32 => "elf32btsmipn32_fbsd",
else => "elf64btsmip_fbsd",
},
else => switch (target.abi) {
- .gnuabin32, .muslabin32 => "elf32btsmipn32",
+ .gnuabin32, .muslabin32, .abin32 => "elf32btsmipn32",
else => "elf64btsmip",
},
},
.mips64el => switch (target.os.tag) {
.freebsd => switch (target.abi) {
- .gnuabin32, .muslabin32 => "elf32ltsmipn32_fbsd",
+ .gnuabin32, .muslabin32, .abin32 => "elf32ltsmipn32_fbsd",
else => "elf64ltsmip_fbsd",
},
else => switch (target.abi) {
- .gnuabin32, .muslabin32 => "elf32ltsmipn32",
+ .gnuabin32, .muslabin32, .abin32 => "elf32ltsmipn32",
else => "elf64ltsmip",
},
},
@@ -1336,7 +1336,7 @@ fn getLDMOption(target: *const std.Target) ?[]const u8 {
else => "elf_i386",
},
.x86_64 => switch (target.abi) {
- .gnux32, .muslx32 => "elf32_x86_64",
+ .gnux32, .muslx32, .x32 => "elf32_x86_64",
else => "elf_x86_64",
},
else => null,
diff --git a/src/target.zig b/src/target.zig
@@ -164,7 +164,10 @@ pub fn hasValgrindSupport(target: *const std.Target, backend: std.lang.CompilerB
else => false,
},
.x86_64 => switch (target.os.tag) {
- .linux => target.abi != .gnux32 and target.abi != .muslx32,
+ .linux => switch (target.abi) {
+ .gnux32, .muslx32, .x32 => false,
+ else => true,
+ },
.freebsd, .illumos => true,
.windows => !ofmt_c_msvc,
else => false,
@@ -700,7 +703,7 @@ pub fn llvmMachineAbi(target: *const std.Target) ?[:0]const u8 {
},
.mips, .mipsel => "o32",
.mips64, .mips64el => switch (target.abi) {
- .gnuabin32, .muslabin32 => "n32",
+ .gnuabin32, .muslabin32, .abin32 => "n32",
else => "n64",
},
.powerpc64 => if (target.os.tag == .ps3) "elfv1" else "elfv2",
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig
@@ -1145,7 +1145,7 @@ test "arrays and vectors with big integers" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
- if (builtin.zig_backend == .stage2_llvm and (builtin.abi == .gnuabin32 or builtin.abi == .muslabin32)) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/23805
+ if (builtin.zig_backend == .stage2_llvm and (builtin.abi == .gnuabin32 or builtin.abi == .muslabin32 or builtin.abi == .abin32)) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/23805
inline for (.{ u65528, u65529, u65535 }) |Int| {
var a: [1]Int = undefined;
diff --git a/test/llvm_targets.zig b/test/llvm_targets.zig
@@ -159,6 +159,7 @@ const targets = [_]std.Target.Query{
.{ .cpu_arch = .mipsel, .os_tag = .rtems, .abi = .eabihf },
.{ .cpu_arch = .mips64, .os_tag = .freestanding, .abi = .none },
+ .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .abin32 },
.{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .gnuabi64 },
.{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .gnuabin32 },
.{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .muslabi64 },
@@ -167,6 +168,7 @@ const targets = [_]std.Target.Query{
.{ .cpu_arch = .mips64, .os_tag = .openbsd, .abi = .none },
.{ .cpu_arch = .mips64el, .os_tag = .freestanding, .abi = .none },
+ .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .abin32 },
.{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .gnuabi64 },
.{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .gnuabin32 },
.{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .muslabi64 },
@@ -331,6 +333,7 @@ const targets = [_]std.Target.Query{
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .muslx32 },
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .none },
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .ohos },
+ .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .x32 },
.{ .cpu_arch = .x86_64, .os_tag = .maccatalyst, .abi = .none },
.{ .cpu_arch = .x86_64, .os_tag = .macos, .abi = .none },
.{ .cpu_arch = .x86_64, .os_tag = .netbsd, .abi = .none },
diff --git a/test/tests.zig b/test/tests.zig
@@ -625,6 +625,14 @@ const module_test_targets = blk: {
.target = .{
.cpu_arch = .mips64,
.os_tag = .linux,
+ .abi = .abin32,
+ },
+ .extra_target = true,
+ },
+ .{
+ .target = .{
+ .cpu_arch = .mips64,
+ .os_tag = .linux,
.abi = .muslabi64,
},
.link_libc = true,
@@ -687,6 +695,14 @@ const module_test_targets = blk: {
.target = .{
.cpu_arch = .mips64el,
.os_tag = .linux,
+ .abi = .abin32,
+ },
+ .extra_target = true,
+ },
+ .{
+ .target = .{
+ .cpu_arch = .mips64el,
+ .os_tag = .linux,
.abi = .muslabi64,
},
.link_libc = true,
@@ -1149,18 +1165,17 @@ const module_test_targets = blk: {
.target = .{
.cpu_arch = .x86_64,
.os_tag = .linux,
- .abi = .gnu,
+ .abi = .x32,
},
- .link_libc = true,
+ .extra_target = true,
},
.{
.target = .{
.cpu_arch = .x86_64,
.os_tag = .linux,
- .abi = .gnux32,
+ .abi = .musl,
},
.link_libc = true,
- .extra_target = true,
},
.{
.target = .{
@@ -1168,7 +1183,9 @@ const module_test_targets = blk: {
.os_tag = .linux,
.abi = .musl,
},
+ .linkage = .dynamic,
.link_libc = true,
+ .extra_target = true,
},
.{
.target = .{
@@ -1176,9 +1193,9 @@ const module_test_targets = blk: {
.os_tag = .linux,
.abi = .musl,
},
- .linkage = .dynamic,
.link_libc = true,
- .extra_target = true,
+ .use_llvm = true,
+ .use_lld = false,
},
.{
.target = .{
@@ -1203,11 +1220,18 @@ const module_test_targets = blk: {
.target = .{
.cpu_arch = .x86_64,
.os_tag = .linux,
- .abi = .musl,
+ .abi = .gnu,
},
.link_libc = true,
- .use_llvm = true,
- .use_lld = false,
+ },
+ .{
+ .target = .{
+ .cpu_arch = .x86_64,
+ .os_tag = .linux,
+ .abi = .gnux32,
+ },
+ .link_libc = true,
+ .extra_target = true,
},
// Darwin Targets