commit 9f2f6aaef519fe37a6936653bbd01b69b1f65a2f (tree)
parent 8c5542bd38c4c78139d4f18b83cd8d52e3e71a83
Author: Alex Rønne Petersen <alex@alexrp.com>
Date: Fri, 13 Mar 2026 05:33:42 +0100
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.
Diffstat:
6 files changed, 7 insertions(+), 20 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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" },