diff options
| -rw-r--r-- | lib/compiler/aro/aro/target.zig | 17 | ||||
| -rw-r--r-- | lib/std/Target.zig | 28 | ||||
| -rw-r--r-- | lib/std/os/linux.zig | 12 | ||||
| -rw-r--r-- | lib/std/zig/LibCDirs.zig | 2 | ||||
| -rw-r--r-- | lib/std/zig/system.zig | 16 | ||||
| -rw-r--r-- | lib/std/zig/target.zig | 2 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 2 | ||||
| -rw-r--r-- | src/link/Elf.zig | 8 | ||||
| -rw-r--r-- | src/target.zig | 10 | ||||
| -rw-r--r-- | test/llvm_targets.zig | 4 |
10 files changed, 74 insertions, 27 deletions
diff --git a/lib/compiler/aro/aro/target.zig b/lib/compiler/aro/aro/target.zig index 0768e781eb..5e5a793632 100644 --- a/lib/compiler/aro/aro/target.zig +++ b/lib/compiler/aro/aro/target.zig @@ -437,9 +437,18 @@ pub fn ldEmulationOption(target: std.Target, arm_endianness: ?std.builtin.Endian .loongarch64 => "elf64loongarch", .mips => "elf32btsmip", .mipsel => "elf32ltsmip", - .mips64 => if (target.abi == .gnuabin32) "elf32btsmipn32" else "elf64btsmip", - .mips64el => if (target.abi == .gnuabin32) "elf32ltsmipn32" else "elf64ltsmip", - .x86_64 => if (target.abi == .gnux32 or target.abi == .muslx32) "elf32_x86_64" else "elf_x86_64", + .mips64 => switch (target.abi) { + .gnuabin32, .muslabin32 => "elf32btsmipn32", + else => "elf64btsmip", + }, + .mips64el => switch (target.abi) { + .gnuabin32, .muslabin32 => "elf32ltsmipn32", + else => "elf64ltsmip", + }, + .x86_64 => switch (target.abi) { + .gnux32, .muslx32 => "elf32_x86_64", + else => "elf_x86_64", + }, .ve => "elf64ve", .csky => "cskyelf_linux", else => null, @@ -691,6 +700,8 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 { .android => "android", .androideabi => "androideabi", .musl => "musl", + .muslabin32 => "muslabin32", + .muslabi64 => "muslabi64", .musleabi => "musleabi", .musleabihf => "musleabihf", .muslx32 => "muslx32", diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 4610d11c01..6d95533b33 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -761,6 +761,8 @@ pub const Abi = enum { android, androideabi, musl, + muslabin32, + muslabi64, musleabi, musleabihf, muslx32, @@ -931,6 +933,8 @@ pub const Abi = enum { pub inline fn isMusl(abi: Abi) bool { return switch (abi) { .musl, + .muslabin32, + .muslabi64, .musleabi, .musleabihf, .muslx32, @@ -2287,9 +2291,9 @@ pub const DynamicLinker = struct { .mips64, .mips64el, => |arch| initFmt("/lib/ld-musl-mips{s}{s}{s}.so.1", .{ - // TODO: `n32` ABI support in LLVM 20. switch (abi) { - .musl => "64", + .muslabi64 => "64", + .muslabin32 => "n32", else => return none, }, if (mips.featureSetHas(cpu.features, .mips64r6)) "r6" else "", @@ -2584,8 +2588,8 @@ pub fn standardDynamicLinkerPath(target: Target) DynamicLinker { pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 { switch (abi) { - .gnux32, .muslx32, .gnuabin32, .gnuilp32, .ilp32 => return 32, - .gnuabi64 => return 64, + .gnux32, .muslx32, .gnuabin32, .muslabin32, .gnuilp32, .ilp32 => return 32, + .gnuabi64, .muslabi64 => return 64, else => {}, } return switch (cpu.arch) { @@ -2788,7 +2792,10 @@ pub fn cTypeBitSize(target: Target, c_type: CType) u16 { .char => return 8, .short, .ushort => return 16, .int, .uint, .float => return 32, - .long, .ulong => return if (target.abi != .gnuabin32) 64 else 32, + .long, .ulong => switch (target.abi) { + .gnuabin32, .muslabin32 => return 32, + else => return 64, + }, .longlong, .ulonglong, .double => return 64, .longdouble => return 128, }, @@ -2821,6 +2828,8 @@ pub fn cTypeBitSize(target: Target, c_type: CType) u16 { .powerpc64le, => switch (target.abi) { .musl, + .muslabin32, + .muslabi64, .musleabi, .musleabihf, .muslx32, @@ -2876,7 +2885,10 @@ pub fn cTypeBitSize(target: Target, c_type: CType) u16 { .char => return 8, .short, .ushort => return 16, .int, .uint, .float => return 32, - .long, .ulong => return if (target.abi != .gnuabin32) 64 else 32, + .long, .ulong => switch (target.abi) { + .gnuabin32, .muslabin32 => return 32, + else => return 64, + }, .longlong, .ulonglong, .double => return 64, .longdouble => if (target.os.tag == .freebsd) return 64 else return 128, }, @@ -2907,6 +2919,8 @@ pub fn cTypeBitSize(target: Target, c_type: CType) u16 { .powerpcle, => switch (target.abi) { .musl, + .muslabin32, + .muslabi64, .musleabi, .musleabihf, .muslx32, @@ -2921,6 +2935,8 @@ pub fn cTypeBitSize(target: Target, c_type: CType) u16 { .powerpc64le, => switch (target.abi) { .musl, + .muslabin32, + .muslabi64, .musleabi, .musleabihf, .muslx32, diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index bccbba5aed..f563264f07 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -136,10 +136,10 @@ pub const SYS = switch (@import("builtin").cpu.arch) { .loongarch64 => syscalls.LoongArch64, .m68k => syscalls.M68k, .mips, .mipsel => syscalls.MipsO32, - .mips64, .mips64el => if (builtin.abi == .gnuabin32) - syscalls.MipsN32 - else - syscalls.MipsN64, + .mips64, .mips64el => switch (builtin.abi) { + .gnuabin32, .muslabin32 => syscalls.MipsN32, + else => syscalls.MipsN64, + }, .powerpc, .powerpcle => syscalls.PowerPC, .powerpc64, .powerpc64le => syscalls.PowerPC64, .s390x => syscalls.S390x, @@ -8657,11 +8657,11 @@ pub const AUDIT = struct { .mips => .MIPS, .mipsel => .MIPSEL, .mips64 => switch (native_abi) { - .gnuabin32 => .MIPS64N32, + .gnuabin32, .muslabin32 => .MIPS64N32, else => .MIPS64, }, .mips64el => switch (native_abi) { - .gnuabin32 => .MIPSEL64N32, + .gnuabin32, .muslabin32 => .MIPSEL64N32, else => .MIPSEL64, }, .powerpc => .PPC, diff --git a/lib/std/zig/LibCDirs.zig b/lib/std/zig/LibCDirs.zig index 536ef7ab71..43c4c5d28f 100644 --- a/lib/std/zig/LibCDirs.zig +++ b/lib/std/zig/LibCDirs.zig @@ -232,6 +232,8 @@ fn libCGenericName(target: std.Target) [:0]const u8 { .gnuilp32, => return "glibc", .musl, + .muslabin32, + .muslabi64, .musleabi, .musleabihf, .muslx32, diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 15392d34f1..5eee0a38df 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -91,16 +91,16 @@ pub fn getExternalExecutor( .mips => Executor{ .qemu = "qemu-mips" }, .mipsel => Executor{ .qemu = "qemu-mipsel" }, .mips64 => Executor{ - .qemu = if (candidate.abi == .gnuabin32) - "qemu-mipsn32" - else - "qemu-mips64", + .qemu = switch (candidate.abi) { + .gnuabin32, .muslabin32 => "qemu-mipsn32", + else => "qemu-mips64", + }, }, .mips64el => Executor{ - .qemu = if (candidate.abi == .gnuabin32) - "qemu-mipsn32el" - else - "qemu-mips64el", + .qemu = switch (candidate.abi) { + .gnuabin32, .muslabin32 => "qemu-mipsn32el", + else => "qemu-mips64el", + }, }, .powerpc => Executor{ .qemu = "qemu-ppc" }, .powerpc64 => Executor{ .qemu = "qemu-ppc64" }, diff --git a/lib/std/zig/target.zig b/lib/std/zig/target.zig index 46ac895dcd..110c2ec321 100644 --- a/lib/std/zig/target.zig +++ b/lib/std/zig/target.zig @@ -99,6 +99,7 @@ pub fn canBuildLibC(target: std.Target) bool { pub fn muslArchName(arch: std.Target.Cpu.Arch, abi: std.Target.Abi) [:0]const u8 { return switch (abi) { + .muslabin32 => "mipsn32", .muslx32 => "x32", else => switch (arch) { .arm, .armeb, .thumb, .thumbeb => "arm", @@ -129,6 +130,7 @@ pub fn muslArchNameHeaders(arch: std.Target.Cpu.Arch) [:0]const u8 { pub fn muslAbiNameHeaders(abi: std.Target.Abi) [:0]const u8 { return switch (abi) { + .muslabin32 => "mipsn32", .muslx32 => "muslx32", else => "musl", }; diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index fc7d26a815..0a1073efcf 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -270,6 +270,8 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 { .android => "android", .androideabi => "androideabi", .musl => "musl", + .muslabin32 => "musl", // Should be muslabin32 in LLVM 20. + .muslabi64 => "musl", // Should be muslabi64 in LLVM 20. .musleabi => "musleabi", .musleabihf => "musleabihf", .muslx32 => "muslx32", diff --git a/src/link/Elf.zig b/src/link/Elf.zig index ccc9e24bf6..840ea02f5d 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -4100,21 +4100,21 @@ fn getLDMOption(target: std.Target) ?[]const u8 { }, .mips64 => switch (target.os.tag) { .freebsd => switch (target.abi) { - .gnuabin32 => "elf32btsmipn32_fbsd", + .gnuabin32, .muslabin32 => "elf32btsmipn32_fbsd", else => "elf64btsmip_fbsd", }, else => switch (target.abi) { - .gnuabin32 => "elf32btsmipn32", + .gnuabin32, .muslabin32 => "elf32btsmipn32", else => "elf64btsmip", }, }, .mips64el => switch (target.os.tag) { .freebsd => switch (target.abi) { - .gnuabin32 => "elf32ltsmipn32_fbsd", + .gnuabin32, .muslabin32 => "elf32ltsmipn32_fbsd", else => "elf64ltsmip_fbsd", }, else => switch (target.abi) { - .gnuabin32 => "elf32ltsmipn32", + .gnuabin32, .muslabin32 => "elf32ltsmipn32", else => "elf64ltsmip", }, }, diff --git a/src/target.zig b/src/target.zig index e4f1d28043..2327ff0c4a 100644 --- a/src/target.zig +++ b/src/target.zig @@ -438,6 +438,16 @@ pub fn arePointersLogical(target: std.Target, as: AddressSpace) bool { } pub fn llvmMachineAbi(target: std.Target) ?[:0]const u8 { + // This special-casing should be removed with LLVM 20. + switch (target.cpu.arch) { + .mips, .mipsel => return "o32", + .mips64, .mips64el => return switch (target.abi) { + .gnuabin32, .muslabin32 => "n32", + else => "n64", + }, + else => {}, + } + // LLD does not support ELFv1. Rather than having LLVM produce ELFv1 code and then linking it // into a broken ELFv2 binary, just force LLVM to use ELFv2 as well. This will break when glibc // is linked as glibc only supports ELFv2 for little endian, but there's nothing we can do about diff --git a/test/llvm_targets.zig b/test/llvm_targets.zig index 15ff356fd3..7cf7d3e8d9 100644 --- a/test/llvm_targets.zig +++ b/test/llvm_targets.zig @@ -161,6 +161,8 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .gnuabi64 }, .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .gnuabin32 }, .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .musl }, + .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .muslabi64 }, + .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .muslabin32 }, .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .none }, .{ .cpu_arch = .mips64, .os_tag = .netbsd, .abi = .none }, .{ .cpu_arch = .mips64, .os_tag = .openbsd, .abi = .none }, @@ -170,6 +172,8 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .gnuabi64 }, .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .gnuabin32 }, .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .musl }, + .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .muslabi64 }, + .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .muslabin32 }, .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .none }, .{ .cpu_arch = .mips64el, .os_tag = .netbsd, .abi = .none }, .{ .cpu_arch = .mips64el, .os_tag = .openbsd, .abi = .none }, |
