From 9f2f6aaef519fe37a6936653bbd01b69b1f65a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Fri, 13 Mar 2026 05:33:42 +0100 Subject: [PATCH] drop support for powerpc64-linux-gnu glibc has never officially supported ELFv2 on big-endian PowerPC, and we do not (and likely never will) support linking ELFv1. So just drop this target instead of pretending we actually have anything resembling usable support for it. This is a dying target anyway; IBM have been pushing people to powerpc64le for years now, and most distros have dropped big endian. glibc headers and abilists are not updated as part of this; I'll just let that happen automatically on the next glibc update. Size savings are expected to be very minimal anyway since there's large overlap between powerpc64 and powerpc64le. This commit also fixes a couple of bad assumptions in std.Target: * The dynamic linker path should be /lib64/ld64.so.1. We should get this right even if the Zig compiler doesn't support the target. * cCallingConvention() was picking powerpc64_elf_v2 only for musl targets. In reality, for the targets we support in std.Target, it should pick v2 for all except powerpc64-linux-gnu. Finally, this switches LLVM codegen to use ELFv2 data layout for all targets except ps3. --- lib/std/Target.zig | 11 +++++------ lib/std/zig/target.zig | 3 +-- src/target.zig | 2 +- test/llvm_targets.zig | 1 - test/tests.zig | 9 --------- tools/process_headers.zig | 1 - 6 files changed, 7 insertions(+), 20 deletions(-) diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 509528b76bec732edd323b5e25b1d2e5903f7ee0..815c2776a563a378c8dfc434faad904dacae7465 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -2682,9 +2682,8 @@ pub const DynamicLinker = struct { else => none, }, - .powerpc64, - .powerpc64le, - => if (abi == .gnu) init("/lib64/ld64.so.2") else none, + .powerpc64 => if (abi == .gnu) init("/lib64/ld64.so.1") else none, + .powerpc64le => if (abi == .gnu) init("/lib64/ld64.so.2") else none, .riscv32, .riscv64, @@ -3741,10 +3740,10 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention .riscv32, .riscv32be => .{ .riscv32_ilp32 = .{} }, .sparc64 => .{ .sparc64_sysv = .{} }, .sparc => .{ .sparc_sysv = .{} }, - .powerpc64 => if (target.abi.isMusl()) - .{ .powerpc64_elf_v2 = .{} } + .powerpc64 => if (target.abi.isGnu()) + .{ .powerpc64_elf = .{} } else - .{ .powerpc64_elf = .{} }, + .{ .powerpc64_elf_v2 = .{} }, .powerpc64le => .{ .powerpc64_elf_v2 = .{} }, .powerpc, .powerpcle => .{ .powerpc_sysv = .{} }, .wasm32, .wasm64 => .{ .wasm_mvp = .{} }, diff --git a/lib/std/zig/target.zig b/lib/std/zig/target.zig index 430db3c343a174898b664dbbd8d4e834f83b7e2b..463d854c8489d419f68a75050466a9e0224a6470 100644 --- a/lib/std/zig/target.zig +++ b/lib/std/zig/target.zig @@ -84,7 +84,6 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .powerpc, .os = .netbsd, .abi = .eabihf, .os_ver = .{ .major = 1, .minor = 4, .patch = 0 } }, .{ .arch = .powerpc, .os = .openbsd, .abi = .eabihf, .os_ver = .{ .major = 2, .minor = 8, .patch = 0 } }, .{ .arch = .powerpc64, .os = .freebsd, .abi = .none, .os_ver = .{ .major = 8, .minor = 0, .patch = 0 } }, - .{ .arch = .powerpc64, .os = .linux, .abi = .gnu, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } }, .{ .arch = .powerpc64, .os = .linux, .abi = .musl, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } }, .{ .arch = .powerpc64, .os = .openbsd, .abi = .none, .os_ver = .{ .major = 6, .minor = 8, .patch = 0 } }, .{ .arch = .powerpc64le, .os = .freebsd, .abi = .none, .os_ver = .{ .major = 13, .minor = 0, .patch = 0 } }, @@ -245,7 +244,7 @@ pub fn glibcArchNameHeaders(arch: std.Target.Cpu.Arch) [:0]const u8 { .arm, .armeb => "arm", .loongarch64 => "loongarch", .mips, .mipsel, .mips64, .mips64el => "mips", - .powerpc, .powerpc64, .powerpc64le => "powerpc", + .powerpc, .powerpc64le => "powerpc", .riscv32, .riscv64 => "riscv", .sparc, .sparc64 => "sparc", .x86, .x86_64 => "x86", diff --git a/src/target.zig b/src/target.zig index 47957d34a8ad49f4dc61f186a0f3c282ba57674c..871a5982395f29d4a6f9eabadb634fa33c1efdfa 100644 --- a/src/target.zig +++ b/src/target.zig @@ -695,7 +695,7 @@ pub fn llvmMachineAbi(target: *const std.Target) ?[:0]const u8 { .gnuabin32, .muslabin32 => "n32", else => "n64", }, - .powerpc64, .powerpc64le => "elfv2", // We do not support ELFv1. + .powerpc64, .powerpc64le => if (target.os.tag == .ps3) "elfv1" else "elfv2", .riscv64, .riscv64be => if (target.cpu.has(.riscv, .e)) "lp64e" else if (target.cpu.has(.riscv, .d)) diff --git a/test/llvm_targets.zig b/test/llvm_targets.zig index 6084acb85ea4bc956b50641eb2c5d25dc3f15fe6..7dba86fae797a41e1c48b2d915f72af43fb07263 100644 --- a/test/llvm_targets.zig +++ b/test/llvm_targets.zig @@ -205,7 +205,6 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .powerpc64, .os_tag = .freebsd, .abi = .none }, .{ .cpu_arch = .powerpc64, .os_tag = .freestanding, .abi = .none }, - .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .gnu }, .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .musl }, .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .none }, .{ .cpu_arch = .powerpc64, .os_tag = .openbsd, .abi = .none }, diff --git a/test/tests.zig b/test/tests.zig index 6750f2b7dedb20c412de91d169fefadbfb69b5e6..7bbeb9f89f41a9cb3daeab8aae3425fbcb4a5fee 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -837,15 +837,6 @@ const module_test_targets = blk: { .link_libc = true, .extra_target = true, }, - // glibc's build-many-glibcs.py currently only builds this target for ELFv1. - // .{ - // .target = .{ - // .cpu_arch = .powerpc64, - // .os_tag = .linux, - // .abi = .gnu, - // }, - // .link_libc = true, - // }, .{ .target = .{ .cpu_arch = .powerpc64le, diff --git a/tools/process_headers.zig b/tools/process_headers.zig index 33199fa07d96404f3f4e0378ffa33050fd0cbcdf..80e30c46833e395353787cec50ed45ae35bf0fef 100644 --- a/tools/process_headers.zig +++ b/tools/process_headers.zig @@ -49,7 +49,6 @@ const glibc_targets = [_]LibCTarget{ .{ .arch = .mips64el, .abi = .gnuabin32, .dest = "mips-linux-gnu" }, .{ .arch = .powerpc, .abi = .gnueabi, .dest = "powerpc-linux-gnu" }, .{ .arch = .powerpc, .abi = .gnueabihf, .dest = "powerpc-linux-gnu" }, - .{ .arch = .powerpc64, .abi = .gnu, .dest = "powerpc-linux-gnu" }, .{ .arch = .powerpc64le, .abi = .gnu, .dest = "powerpc-linux-gnu" }, .{ .arch = .riscv32, .abi = .gnu, .dest = "riscv-linux-gnu" }, .{ .arch = .riscv64, .abi = .gnu, .dest = "riscv-linux-gnu" }, -- 2.54.0