authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-06-18 12:45:27+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-06-18 12:45:27+02:00
logcfeab9258739f44b73542952b3ca62c1187669e1
tree6de84e36a111e1f82674ebcf29b08afd6e0bf6de
parent14bc6f5917ae94902cdf209e3ac9af908b506795
parent7853cd1e008b003f2881947615832249d2e0711e

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

16 files changed, 160 insertions(+), 105 deletions(-)

lib/std/Build/Configuration.zig+6
......@@ -2271,6 +2271,8 @@ pub const TargetQuery = struct {
22712271 gnux32,
22722272 eabi,
22732273 eabihf,
2274 abin32,
2275 x32,
22742276 ilp32,
22752277 android,
22762278 androideabi,
......@@ -2304,6 +2306,8 @@ pub const TargetQuery = struct {
23042306 .gnux32 => .gnux32,
23052307 .eabi => .eabi,
23062308 .eabihf => .eabihf,
2309 .abin32 => .abin32,
2310 .x32 => .x32,
23072311 .ilp32 => .ilp32,
23082312 .android => .android,
23092313 .androideabi => .androideabi,
......@@ -2337,6 +2341,8 @@ pub const TargetQuery = struct {
23372341 .gnux32 => .gnux32,
23382342 .eabi => .eabi,
23392343 .eabihf => .eabihf,
2344 .abin32 => .abin32,
2345 .x32 => .x32,
23402346 .ilp32 => .ilp32,
23412347 .android => .android,
23422348 .androideabi => .androideabi,
lib/std/Target.zig+80-67
......@@ -796,6 +796,8 @@ pub const Abi = enum {
796796 gnux32,
797797 eabi,
798798 eabihf,
799 abin32,
800 x32,
799801 ilp32,
800802 android,
801803 androideabi,
......@@ -887,8 +889,12 @@ pub const Abi = enum {
887889 => .muslabi64,
888890
889891 // No musl support.
892 .alpha,
890893 .arc,
891894 .arceb,
895 .or1k,
896 .sparc,
897 .sparc64,
892898 => .gnu,
893899 .csky,
894900 => .gnueabi,
......@@ -2920,10 +2926,17 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
29202926
29212927pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
29222928 switch (abi) {
2923 .gnux32, .muslx32, .gnuabin32, .muslabin32, .ilp32 => return 32,
2924 .gnuabi64, .muslabi64 => return 64,
2929 .gnux32,
2930 .muslx32,
2931 .x32,
2932 .gnuabin32,
2933 .muslabin32,
2934 .abin32,
2935 .ilp32,
2936 => return 32,
29252937 else => {},
29262938 }
2939
29272940 return switch (cpu_arch) {
29282941 .avr,
29292942 .msp430,
......@@ -3002,12 +3015,12 @@ pub fn ptrBitWidth(target: *const Target) u16 {
30023015pub fn stackAlignment(target: *const Target) u16 {
30033016 // Overrides for when the stack alignment is not equal to the pointer width.
30043017 switch (target.cpu.arch) {
3005 .ez80,
3006 => return 1,
3007 .m68k,
3008 => return 2,
3009 .amdgcn,
3010 => return 4,
3018 .ez80 => return 1,
3019
3020 .m68k => return 2,
3021
3022 .amdgcn => return 4,
3023
30113024 .arm,
30123025 .armeb,
30133026 .hppa,
......@@ -3018,6 +3031,7 @@ pub fn stackAlignment(target: *const Target) u16 {
30183031 .thumb,
30193032 .thumbeb,
30203033 => return 8,
3034
30213035 .aarch64,
30223036 .aarch64_be,
30233037 .alpha,
......@@ -3034,18 +3048,23 @@ pub fn stackAlignment(target: *const Target) u16 {
30343048 .wasm64,
30353049 .x86_64,
30363050 => return 16,
3051
30373052 // Some of the following prongs should really be testing the ABI, but our current `Abi` enum
30383053 // can't handle that level of nuance yet.
30393054 .powerpc64,
30403055 .powerpc64le,
30413056 => if (target.os.tag == .linux) return 16,
3057
30423058 .riscv32,
30433059 .riscv32be,
30443060 .riscv64,
30453061 .riscv64be,
30463062 => if (!target.cpu.has(.riscv, .e)) return 16,
3063
30473064 .x86 => if (target.os.tag != .windows and target.os.tag != .uefi) return 16,
3065
30483066 .kvx => return 32,
3067
30493068 else => {},
30503069 }
30513070
......@@ -3148,7 +3167,9 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) u16 {
31483167pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
31493168 switch (target.os.tag) {
31503169 .freestanding, .other => switch (target.cpu.arch) {
3151 .msp430, .x86_16 => switch (c_type) {
3170 .msp430,
3171 .x86_16,
3172 => switch (c_type) {
31523173 .char => return 8,
31533174 .short, .ushort, .int, .uint => return 16,
31543175 .float, .long, .ulong => return 32,
......@@ -3160,12 +3181,14 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
31603181 .long, .ulong, .float, .double, .longdouble => return 32,
31613182 .longlong, .ulonglong => return 64,
31623183 },
3163 .mips64, .mips64el => switch (c_type) {
3184 .mips64,
3185 .mips64el,
3186 => switch (c_type) {
31643187 .char => return 8,
31653188 .short, .ushort => return 16,
31663189 .int, .uint, .float => return 32,
31673190 .long, .ulong => switch (target.abi) {
3168 .gnuabin32, .muslabin32 => return 32,
3191 .abin32 => return 32,
31693192 else => return 64,
31703193 },
31713194 .longlong, .ulonglong, .double => return 64,
......@@ -3176,7 +3199,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
31763199 .short, .ushort => return 16,
31773200 .int, .uint, .float => return 32,
31783201 .long, .ulong => switch (target.abi) {
3179 .gnux32, .muslx32 => return 32,
3202 .x32 => return 32,
31803203 else => return 64,
31813204 },
31823205 .longlong, .ulonglong, .double => return 64,
......@@ -3189,25 +3212,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
31893212 .long, .ulong => return target.ptrBitWidth(),
31903213 .longlong, .ulonglong, .double => return 64,
31913214 .longdouble => switch (target.cpu.arch) {
3192 .x86 => switch (target.abi) {
3193 .android => return 64,
3194 else => return 80,
3195 },
3196
3197 .powerpc,
3198 .powerpcle,
3199 .powerpc64,
3200 .powerpc64le,
3201 => switch (target.abi) {
3202 .musl,
3203 .muslabin32,
3204 .muslabi64,
3205 .musleabi,
3206 .musleabihf,
3207 .muslx32,
3208 => return 64,
3209 else => return 128,
3210 },
3215 .x86 => return 80,
32113216
32123217 .alpha,
32133218 .riscv32,
......@@ -3216,6 +3221,10 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
32163221 .riscv64be,
32173222 .aarch64,
32183223 .aarch64_be,
3224 .powerpc,
3225 .powerpcle,
3226 .powerpc64,
3227 .powerpc64le,
32193228 .s390x,
32203229 .sparc64,
32213230 .wasm32,
......@@ -3249,23 +3258,25 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
32493258 .wasi,
32503259 .emscripten,
32513260 => switch (target.cpu.arch) {
3252 .mips64, .mips64el => switch (c_type) {
3261 .mips64,
3262 .mips64el,
3263 => switch (c_type) {
32533264 .char => return 8,
32543265 .short, .ushort => return 16,
32553266 .int, .uint, .float => return 32,
32563267 .long, .ulong => switch (target.abi) {
3257 .gnuabin32, .muslabin32 => return 32,
3268 .gnuabin32, .muslabin32, .abin32 => return 32,
32583269 else => return 64,
32593270 },
32603271 .longlong, .ulonglong, .double => return 64,
3261 .longdouble => if (target.os.tag == .freebsd) return 64 else return 128,
3272 .longdouble => return 128,
32623273 },
32633274 .x86_64 => switch (c_type) {
32643275 .char => return 8,
32653276 .short, .ushort => return 16,
32663277 .int, .uint, .float => return 32,
32673278 .long, .ulong => switch (target.abi) {
3268 .gnux32, .muslx32 => return 32,
3279 .gnux32, .muslx32, .x32 => return 32,
32693280 else => return 64,
32703281 },
32713282 .longlong, .ulonglong, .double => return 64,
......@@ -3286,15 +3297,11 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
32863297 .powerpc,
32873298 .powerpcle,
32883299 => switch (target.abi) {
3289 .musl,
3290 .muslabin32,
3291 .muslabi64,
3292 .musleabi,
3293 .musleabihf,
3294 .muslx32,
3295 => return 64,
3300 .musleabi, .musleabihf => return 64,
32963301 else => switch (target.os.tag) {
3297 .freebsd, .netbsd, .openbsd => return 64,
3302 .netbsd,
3303 .openbsd,
3304 => return 64,
32983305 else => return 128,
32993306 },
33003307 },
......@@ -3302,15 +3309,11 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33023309 .powerpc64,
33033310 .powerpc64le,
33043311 => switch (target.abi) {
3305 .musl,
3306 .muslabin32,
3307 .muslabi64,
3308 .musleabi,
3309 .musleabihf,
3310 .muslx32,
3311 => return 64,
3312 .musl => return 64,
33123313 else => switch (target.os.tag) {
3313 .freebsd, .openbsd => return 64,
3314 .freebsd,
3315 .openbsd,
3316 => return 64,
33143317 else => return 128,
33153318 },
33163319 },
......@@ -3346,7 +3349,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33463349 .long, .ulong => return 32,
33473350 .longlong, .ulonglong, .double => return 64,
33483351 .longdouble => switch (target.abi) {
3349 .gnu, .ilp32 => return 80,
3352 .gnu => return 80,
33503353 else => return 64,
33513354 },
33523355 },
......@@ -3357,7 +3360,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
33573360 .long, .ulong => return 32,
33583361 .longlong, .ulonglong, .double => return 64,
33593362 .longdouble => switch (target.abi) {
3360 .gnu, .ilp32 => return 80,
3363 .gnu => return 80,
33613364 else => return 64,
33623365 },
33633366 },
......@@ -3476,12 +3479,14 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
34763479pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
34773480 // Overrides for unusual alignments
34783481 switch (target.cpu.arch) {
3479 .avr, .ez80 => return 1,
3482 .avr,
3483 .ez80,
3484 => return 1,
34803485 .x86 => switch (target.os.tag) {
34813486 .windows, .uefi => switch (c_type) {
34823487 .longlong, .ulonglong, .double => return 8,
34833488 .longdouble => switch (target.abi) {
3484 .gnu, .ilp32 => return 4,
3489 .gnu => return 4,
34853490 else => return 8,
34863491 },
34873492 else => {},
......@@ -3506,8 +3511,6 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
35063511 return @min(
35073512 std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
35083513 @as(u16, switch (target.cpu.arch) {
3509 .ez80 => 1,
3510
35113514 .msp430,
35123515 .x86_16,
35133516 => 2,
......@@ -3575,6 +3578,7 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
35753578 => 16,
35763579
35773580 .avr,
3581 .ez80,
35783582 => unreachable, // Handled above.
35793583 }),
35803584 );
......@@ -3587,11 +3591,13 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
35873591 .longdouble => return 4,
35883592 else => {},
35893593 },
3590 .avr, .ez80 => return 1,
3594 .avr,
3595 .ez80,
3596 => return 1,
35913597 .x86 => switch (target.os.tag) {
35923598 .windows, .uefi => switch (c_type) {
35933599 .longdouble => switch (target.abi) {
3594 .gnu, .ilp32 => return 4,
3600 .gnu => return 4,
35953601 else => return 8,
35963602 },
35973603 else => {},
......@@ -3619,9 +3625,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
36193625 return @min(
36203626 std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
36213627 @as(u16, switch (target.cpu.arch) {
3622 .ez80 => 1,
3623
3624 .x86_16, .msp430 => 2,
3628 .x86_16,
3629 .msp430,
3630 => 2,
36253631
36263632 .arc,
36273633 .arceb,
......@@ -3686,6 +3692,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
36863692 => 16,
36873693
36883694 .avr,
3695 .ez80,
36893696 => unreachable, // Handled above.
36903697 }),
36913698 );
......@@ -3697,7 +3704,9 @@ pub fn cMaxIntAlignment(target: *const Target) u16 {
36973704 .ez80,
36983705 => 1,
36993706
3700 .msp430, .x86_16 => 2,
3707 .msp430,
3708 .x86_16,
3709 => 2,
37013710
37023711 .arc,
37033712 .arceb,
......@@ -3766,14 +3775,18 @@ pub fn cMaxIntAlignment(target: *const Target) u16 {
37663775pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention {
37673776 return switch (target.cpu.arch) {
37683777 .x86_64 => switch (target.os.tag) {
3769 .windows, .uefi => .{ .x86_64_win = .{} },
3778 .windows,
3779 .uefi,
3780 => .{ .x86_64_win = .{} },
37703781 else => switch (target.abi) {
3771 .gnux32, .muslx32 => .{ .x86_64_x32 = .{} },
3782 .gnux32, .muslx32, .x32 => .{ .x86_64_x32 = .{} },
37723783 else => .{ .x86_64_sysv = .{} },
37733784 },
37743785 },
37753786 .x86 => switch (target.os.tag) {
3776 .windows, .uefi => .{ .x86_win = .{} },
3787 .windows,
3788 .uefi,
3789 => .{ .x86_win = .{} },
37773790 else => .{ .x86_sysv = .{} },
37783791 },
37793792 .x86_16 => .{ .x86_16_cdecl = .{} },
......@@ -3789,7 +3802,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
37893802 .hard => .{ .arm_aapcs_vfp = .{} },
37903803 },
37913804 .mips64, .mips64el => switch (target.abi) {
3792 .gnuabin32, .muslabin32 => .{ .mips64_n32 = .{} },
3805 .gnuabin32, .muslabin32, .abin32 => .{ .mips64_n32 = .{} },
37933806 else => .{ .mips64_n64 = .{} },
37943807 },
37953808 .mips, .mipsel => .{ .mips_o32 = .{} },
lib/std/Thread.zig+2-2
......@@ -1171,7 +1171,7 @@ const LinuxThreadImpl = struct {
11711171 [len] "{ecx}" (self.mapped.len),
11721172 ),
11731173 .x86_64 => asm volatile (switch (target.abi) {
1174 .gnux32, .muslx32 =>
1174 .gnux32, .muslx32, .x32 =>
11751175 \\ movl $0x4000000b, %%eax # SYS_munmap
11761176 \\ syscall
11771177 \\ movl $0x4000003c, %%eax # SYS_exit
......@@ -1286,7 +1286,7 @@ const LinuxThreadImpl = struct {
12861286 [len] "{$5}" (self.mapped.len),
12871287 ),
12881288 .mips64, .mips64el => asm volatile (switch (target.abi) {
1289 .gnuabin32, .muslabin32 =>
1289 .gnuabin32, .muslabin32, .abin32 =>
12901290 \\ li $v0, 6011 # SYS_munmap
12911291 \\ syscall
12921292 \\ li $v0, 6058 # SYS_exit
lib/std/debug/Dwarf/expression.zig+2-2
......@@ -1158,7 +1158,7 @@ test "basics" {
11581158
11591159 // TODO: Test fbreg (once implemented): mock a DIE and point compile_unit.frame_base at it
11601160
1161 mem.writeInt(usize, reg_bytes[0..@sizeOf(usize)], 0xee, native_endian);
1161 mem.writeInt(std.debug.cpu_context.Native.Gpr, reg_bytes[0..@sizeOf(std.debug.cpu_context.Native.Gpr)], 0xee, native_endian);
11621162 (try regNative(&cpu_context, fp_reg_num)).* = 1;
11631163 (try regNative(&cpu_context, ip_reg_num)).* = 2;
11641164
......@@ -1566,7 +1566,7 @@ test "basics" {
15661566 context = .{ .cpu_context = &cpu_context };
15671567
15681568 const reg_bytes = try cpu_context.dwarfRegisterBytes(0);
1569 mem.writeInt(usize, reg_bytes[0..@sizeOf(usize)], 0xee, native_endian);
1569 mem.writeInt(std.debug.cpu_context.Native.Gpr, reg_bytes[0..@sizeOf(std.debug.cpu_context.Native.Gpr)], 0xee, native_endian);
15701570
15711571 var sub_program: std.Io.Writer.Allocating = .init(allocator);
15721572 defer sub_program.deinit();
lib/std/os/linux.zig+10-8
......@@ -43,7 +43,7 @@ const arch_bits = switch (native_arch) {
4343 .microblaze, .microblazeel => @import("linux/microblaze.zig"),
4444 .mips, .mipsel => @import("linux/mips.zig"),
4545 .mips64, .mips64el => switch (builtin.abi) {
46 .gnuabin32, .muslabin32 => @import("linux/mipsn32.zig"),
46 .gnuabin32, .muslabin32, .abin32 => @import("linux/mipsn32.zig"),
4747 else => @import("linux/mips64.zig"),
4848 },
4949 .or1k => @import("linux/or1k.zig"),
......@@ -57,7 +57,7 @@ const arch_bits = switch (native_arch) {
5757 .sparc64 => @import("linux/sparc64.zig"),
5858 .x86 => @import("linux/x86.zig"),
5959 .x86_64 => switch (builtin.abi) {
60 .gnux32, .muslx32 => @import("linux/x32.zig"),
60 .gnux32, .muslx32, .x32 => @import("linux/x32.zig"),
6161 else => @import("linux/x86_64.zig"),
6262 },
6363 .xtensa, .xtensaeb => @import("linux/xtensa.zig"),
......@@ -144,7 +144,7 @@ pub const SYS = switch (native_arch) {
144144 .microblaze, .microblazeel => syscalls.Microblaze,
145145 .mips, .mipsel => syscalls.MipsO32,
146146 .mips64, .mips64el => switch (builtin.abi) {
147 .gnuabin32, .muslabin32 => syscalls.MipsN32,
147 .gnuabin32, .muslabin32, .abin32 => syscalls.MipsN32,
148148 else => syscalls.MipsN64,
149149 },
150150 .or1k => syscalls.OpenRisc,
......@@ -158,7 +158,7 @@ pub const SYS = switch (native_arch) {
158158 .sparc64 => syscalls.Sparc64,
159159 .x86 => syscalls.X86,
160160 .x86_64 => switch (builtin.abi) {
161 .gnux32, .muslx32 => syscalls.X32,
161 .gnux32, .muslx32, .x32 => syscalls.X32,
162162 else => syscalls.X64,
163163 },
164164 .xtensa, .xtensaeb => syscalls.Xtensa,
......@@ -1828,8 +1828,10 @@ pub fn lseek(fd: fd_t, offset: off_t, whence: u32) u64 {
18281828 return switch (builtin.abi) {
18291829 .gnuabin32,
18301830 .muslabin32,
1831 .abin32,
18311832 .gnux32,
18321833 .muslx32,
1834 .x32,
18331835 => syscall_lseek(fd, offset, whence),
18341836 else => syscall3(.lseek, @as(u32, @bitCast(fd)), @as(u64, @bitCast(offset)), whence),
18351837 };
......@@ -2006,7 +2008,7 @@ pub const F = struct {
20062008 const SETLKW = 35;
20072009 },
20082010 .mips64, .mips64el => switch (native_abi) {
2009 .gnuabin32, .muslabin32 => struct {
2011 .gnuabin32, .muslabin32, .abin32 => struct {
20102012 const GETLK = 33;
20112013 const SETLK = 34;
20122014 const SETLKW = 35;
......@@ -3187,7 +3189,7 @@ pub fn tee(src: fd_t, dest: fd_t, len: usize, flags: u32) usize {
31873189}
31883190
31893191pub const Sysinfo = switch (native_abi) {
3190 .gnux32, .muslx32 => extern struct {
3192 .gnux32, .muslx32, .x32 => extern struct {
31913193 /// Seconds since boot
31923194 uptime: i64,
31933195 /// 1, 5, and 15 minute load averages
......@@ -10753,11 +10755,11 @@ pub const AUDIT = struct {
1075310755 .mips => .MIPS,
1075410756 .mipsel => .MIPSEL,
1075510757 .mips64 => switch (native_abi) {
10756 .gnuabin32, .muslabin32 => .MIPS64N32,
10758 .gnuabin32, .muslabin32, .abin32 => .MIPS64N32,
1075710759 else => .MIPS64,
1075810760 },
1075910761 .mips64el => switch (native_abi) {
10760 .gnuabin32, .muslabin32 => .MIPSEL64N32,
10762 .gnuabin32, .muslabin32, .abin32 => .MIPSEL64N32,
1076110763 else => .MIPSEL64,
1076210764 },
1076310765 .or1k => .OPENRISC,
lib/std/os/linux/mipsn32.zig+2-2
......@@ -219,8 +219,8 @@ pub fn clone() callconv(.naked) u32 {
219219 \\ move $fp, $zero
220220 \\ move $ra, $zero
221221 \\
222 \\ ld $t9, 0($sp)
223 \\ ld $a0, 4($sp)
222 \\ lw $t9, 0($sp)
223 \\ lw $a0, 4($sp)
224224 \\ jalr $t9
225225 \\
226226 \\ move $a0, $v0
lib/std/pie.zig+1-1
......@@ -162,7 +162,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
162162 :
163163 : .{ .lr = true }),
164164 .mips64, .mips64el => switch (builtin.abi) {
165 .gnuabin32, .muslabin32 => asm volatile (
165 .gnuabin32, .muslabin32, .abin32 => asm volatile (
166166 \\ .weak _DYNAMIC
167167 \\ .hidden _DYNAMIC
168168 \\ bal 1f
lib/std/start.zig+1-1
......@@ -373,7 +373,7 @@ fn _start() callconv(.naked) noreturn {
373373 \\ jalr $t9
374374 ,
375375 .mips64, .mips64el => switch (builtin.abi) {
376 .gnuabin32, .muslabin32 =>
376 .gnuabin32, .muslabin32, .abin32 =>
377377 \\ move $fp, $zero
378378 \\ bal 1f
379379 \\ .gpword .
lib/std/zig/LibCDirs.zig+2
......@@ -282,6 +282,8 @@ fn libCGenericName(target: *const std.Target) [:0]const u8 {
282282 => return "musl",
283283 .eabi,
284284 .eabihf,
285 .abin32,
286 .x32,
285287 .ilp32,
286288 .android,
287289 .androideabi,
lib/std/zig/system.zig+2-2
......@@ -104,7 +104,7 @@ pub fn getExternalExecutor(io: Io, candidate: *const std.Target, options: GetExt
104104 => .{ .qemu = switch (t) {
105105 .x86 => "qemu-i386",
106106 .x86_64 => switch (candidate.abi) {
107 .gnux32, .muslx32 => return bad_result,
107 .gnux32, .muslx32, .x32 => return bad_result,
108108 else => "qemu-x86_64",
109109 },
110110 else => "qemu-" ++ @tagName(t),
......@@ -146,7 +146,7 @@ pub fn getExternalExecutor(io: Io, candidate: *const std.Target, options: GetExt
146146 .powerpc64 => "qemu-ppc64",
147147 .powerpc64le => "qemu-ppc64le",
148148 .mips64, .mips64el => switch (candidate.abi) {
149 .gnuabin32, .muslabin32 => if (t == .mips64el) "qemu-mipsn32el" else "qemu-mipsn32",
149 .gnuabin32, .muslabin32, .abin32 => if (t == .mips64el) "qemu-mipsn32el" else "qemu-mipsn32",
150150 else => "qemu-" ++ @tagName(t),
151151 },
152152 // TODO: Actually check the SuperH version.
src/codegen/llvm.zig+5-3
......@@ -285,6 +285,8 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
285285 .ilp32 => "unknown",
286286 .eabi => "eabi",
287287 .eabihf => "eabihf",
288 .abin32 => "unknown",
289 .x32 => "muslx32", // https://github.com/ziglang/zig/issues/25649
288290 .android => "android",
289291 .androideabi => "androideabi",
290292 .musl => switch (target.os.tag) {
......@@ -377,11 +379,11 @@ pub fn dataLayout(target: *const std.Target) []const u8 {
377379 .mips => "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64",
378380 .mipsel => "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64",
379381 .mips64 => switch (target.abi) {
380 .gnuabin32, .muslabin32 => "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
382 .gnuabin32, .muslabin32, .abin32 => "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
381383 else => "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
382384 },
383385 .mips64el => switch (target.abi) {
384 .gnuabin32, .muslabin32 => "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
386 .gnuabin32, .muslabin32, .abin32 => "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
385387 else => "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
386388 },
387389 .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 {
446448 .x86_64 => if (target.os.tag.isDarwin() or target.ofmt == .macho)
447449 "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
448450 else switch (target.abi) {
449 .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",
451 .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",
450452 else => if ((target.os.tag == .windows or target.os.tag == .uefi) and target.ofmt == .coff)
451453 "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
452454 else
src/link/Lld.zig+5-5
......@@ -1295,21 +1295,21 @@ fn getLDMOption(target: *const std.Target) ?[]const u8 {
12951295 },
12961296 .mips64 => switch (target.os.tag) {
12971297 .freebsd => switch (target.abi) {
1298 .gnuabin32, .muslabin32 => "elf32btsmipn32_fbsd",
1298 .gnuabin32, .muslabin32, .abin32 => "elf32btsmipn32_fbsd",
12991299 else => "elf64btsmip_fbsd",
13001300 },
13011301 else => switch (target.abi) {
1302 .gnuabin32, .muslabin32 => "elf32btsmipn32",
1302 .gnuabin32, .muslabin32, .abin32 => "elf32btsmipn32",
13031303 else => "elf64btsmip",
13041304 },
13051305 },
13061306 .mips64el => switch (target.os.tag) {
13071307 .freebsd => switch (target.abi) {
1308 .gnuabin32, .muslabin32 => "elf32ltsmipn32_fbsd",
1308 .gnuabin32, .muslabin32, .abin32 => "elf32ltsmipn32_fbsd",
13091309 else => "elf64ltsmip_fbsd",
13101310 },
13111311 else => switch (target.abi) {
1312 .gnuabin32, .muslabin32 => "elf32ltsmipn32",
1312 .gnuabin32, .muslabin32, .abin32 => "elf32ltsmipn32",
13131313 else => "elf64ltsmip",
13141314 },
13151315 },
......@@ -1336,7 +1336,7 @@ fn getLDMOption(target: *const std.Target) ?[]const u8 {
13361336 else => "elf_i386",
13371337 },
13381338 .x86_64 => switch (target.abi) {
1339 .gnux32, .muslx32 => "elf32_x86_64",
1339 .gnux32, .muslx32, .x32 => "elf32_x86_64",
13401340 else => "elf_x86_64",
13411341 },
13421342 else => null,
src/target.zig+5-2
......@@ -164,7 +164,10 @@ pub fn hasValgrindSupport(target: *const std.Target, backend: std.lang.CompilerB
164164 else => false,
165165 },
166166 .x86_64 => switch (target.os.tag) {
167 .linux => target.abi != .gnux32 and target.abi != .muslx32,
167 .linux => switch (target.abi) {
168 .gnux32, .muslx32, .x32 => false,
169 else => true,
170 },
168171 .freebsd, .illumos => true,
169172 .windows => !ofmt_c_msvc,
170173 else => false,
......@@ -700,7 +703,7 @@ pub fn llvmMachineAbi(target: *const std.Target) ?[:0]const u8 {
700703 },
701704 .mips, .mipsel => "o32",
702705 .mips64, .mips64el => switch (target.abi) {
703 .gnuabin32, .muslabin32 => "n32",
706 .gnuabin32, .muslabin32, .abin32 => "n32",
704707 else => "n64",
705708 },
706709 .powerpc64 => if (target.os.tag == .ps3) "elfv1" else "elfv2",
test/behavior/basic.zig+1-1
......@@ -1145,7 +1145,7 @@ test "arrays and vectors with big integers" {
11451145 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
11461146 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
11471147 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
1148 if (builtin.zig_backend == .stage2_llvm and (builtin.abi == .gnuabin32 or builtin.abi == .muslabin32)) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/23805
1148 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
11491149
11501150 inline for (.{ u65528, u65529, u65535 }) |Int| {
11511151 var a: [1]Int = undefined;
test/llvm_targets.zig+3
......@@ -159,6 +159,7 @@ const targets = [_]std.Target.Query{
159159 .{ .cpu_arch = .mipsel, .os_tag = .rtems, .abi = .eabihf },
160160
161161 .{ .cpu_arch = .mips64, .os_tag = .freestanding, .abi = .none },
162 .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .abin32 },
162163 .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .gnuabi64 },
163164 .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .gnuabin32 },
164165 .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .muslabi64 },
......@@ -167,6 +168,7 @@ const targets = [_]std.Target.Query{
167168 .{ .cpu_arch = .mips64, .os_tag = .openbsd, .abi = .none },
168169
169170 .{ .cpu_arch = .mips64el, .os_tag = .freestanding, .abi = .none },
171 .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .abin32 },
170172 .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .gnuabi64 },
171173 .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .gnuabin32 },
172174 .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .muslabi64 },
......@@ -331,6 +333,7 @@ const targets = [_]std.Target.Query{
331333 .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .muslx32 },
332334 .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .none },
333335 .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .ohos },
336 .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .x32 },
334337 .{ .cpu_arch = .x86_64, .os_tag = .maccatalyst, .abi = .none },
335338 .{ .cpu_arch = .x86_64, .os_tag = .macos, .abi = .none },
336339 .{ .cpu_arch = .x86_64, .os_tag = .netbsd, .abi = .none },
test/tests.zig+33-9
......@@ -621,6 +621,14 @@ const module_test_targets = blk: {
621621 .abi = .none,
622622 },
623623 },
624 .{
625 .target = .{
626 .cpu_arch = .mips64,
627 .os_tag = .linux,
628 .abi = .abin32,
629 },
630 .extra_target = true,
631 },
624632 .{
625633 .target = .{
626634 .cpu_arch = .mips64,
......@@ -683,6 +691,14 @@ const module_test_targets = blk: {
683691 .abi = .none,
684692 },
685693 },
694 .{
695 .target = .{
696 .cpu_arch = .mips64el,
697 .os_tag = .linux,
698 .abi = .abin32,
699 },
700 .extra_target = true,
701 },
686702 .{
687703 .target = .{
688704 .cpu_arch = .mips64el,
......@@ -1149,18 +1165,17 @@ const module_test_targets = blk: {
11491165 .target = .{
11501166 .cpu_arch = .x86_64,
11511167 .os_tag = .linux,
1152 .abi = .gnu,
1168 .abi = .x32,
11531169 },
1154 .link_libc = true,
1170 .extra_target = true,
11551171 },
11561172 .{
11571173 .target = .{
11581174 .cpu_arch = .x86_64,
11591175 .os_tag = .linux,
1160 .abi = .gnux32,
1176 .abi = .musl,
11611177 },
11621178 .link_libc = true,
1163 .extra_target = true,
11641179 },
11651180 .{
11661181 .target = .{
......@@ -1168,7 +1183,9 @@ const module_test_targets = blk: {
11681183 .os_tag = .linux,
11691184 .abi = .musl,
11701185 },
1186 .linkage = .dynamic,
11711187 .link_libc = true,
1188 .extra_target = true,
11721189 },
11731190 .{
11741191 .target = .{
......@@ -1176,9 +1193,9 @@ const module_test_targets = blk: {
11761193 .os_tag = .linux,
11771194 .abi = .musl,
11781195 },
1179 .linkage = .dynamic,
11801196 .link_libc = true,
1181 .extra_target = true,
1197 .use_llvm = true,
1198 .use_lld = false,
11821199 },
11831200 .{
11841201 .target = .{
......@@ -1203,11 +1220,18 @@ const module_test_targets = blk: {
12031220 .target = .{
12041221 .cpu_arch = .x86_64,
12051222 .os_tag = .linux,
1206 .abi = .musl,
1223 .abi = .gnu,
12071224 },
12081225 .link_libc = true,
1209 .use_llvm = true,
1210 .use_lld = false,
1226 },
1227 .{
1228 .target = .{
1229 .cpu_arch = .x86_64,
1230 .os_tag = .linux,
1231 .abi = .gnux32,
1232 },
1233 .link_libc = true,
1234 .extra_target = true,
12111235 },
12121236
12131237 // Darwin Targets