authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-05 16:59:05+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-06 01:28:56+02:00
logddc815e3d88d32b8f3df0610ee59c8d34b8ff8eb
tree4fb46f586dc07351b0e98d902d3cae847d86b0b0
parentbd23e9a744b3a43aab468b9f5e24b4c63e7c25d3

drop support for powerpc64 ELF v1

* ELF v1 on powerpc64 is only barely kept on life support in a couple of Linux distros. I don't anticipate that this will last much longer. * Most of the Linux world has moved to powerpc64le which requires ELF v2. * Some Linux distros have even started supporting powerpc64 with ELF v2. * The BSD world has long since moved to ELF v2. * We have no actual linking support for ELF v1. * ELF v1 had confused DWARF register mappings which is becoming a problem in our DWARF code in std.debug. It's clear that ELF v1 is on its way out, and we never fully supported it anyway. So let's not waste any time or energy on it going forward. closes #5927

3 files changed, 5 insertions(+), 21 deletions(-)

lib/std/Target.zig+3-3
...@@ -2463,9 +2463,9 @@ pub const DynamicLinker = struct {...@@ -2463,9 +2463,9 @@ pub const DynamicLinker = struct {
2463 => init("/lib/ld.so.1"),2463 => init("/lib/ld.so.1"),
2464 else => none,2464 else => none,
2465 },2465 },
2466 // TODO: ELFv2 ABI (`/lib64/ld64.so.2`) opt-in support.2466 .powerpc64,
2467 .powerpc64 => if (abi == .gnu) init("/lib64/ld64.so.1") else none,2467 .powerpc64le,
2468 .powerpc64le => if (abi == .gnu) init("/lib64/ld64.so.2") else none,2468 => if (abi == .gnu) init("/lib64/ld64.so.2") else none,
24692469
2470 .riscv32,2470 .riscv32,
2471 .riscv64,2471 .riscv64,
src/target.zig+1-17
...@@ -631,14 +631,6 @@ pub fn isDynamicAMDGCNFeature(target: *const std.Target, feature: std.Target.Cpu...@@ -631,14 +631,6 @@ pub fn isDynamicAMDGCNFeature(target: *const std.Target, feature: std.Target.Cpu
631}631}
632632
633pub fn llvmMachineAbi(target: *const std.Target) ?[:0]const u8 {633pub fn llvmMachineAbi(target: *const std.Target) ?[:0]const u8 {
634 // LLD does not support ELFv1. Rather than having LLVM produce ELFv1 code and then linking it
635 // into a broken ELFv2 binary, just force LLVM to use ELFv2 as well. This will break when glibc
636 // is linked as glibc only supports ELFv2 for little endian, but there's nothing we can do about
637 // that. With this hack, `powerpc64-linux-none` will at least work.
638 //
639 // Once our self-hosted linker can handle both ABIs, this hack should go away.
640 if (target.cpu.arch == .powerpc64) return "elfv2";
641
642 return switch (target.cpu.arch) {634 return switch (target.cpu.arch) {
643 .arm, .armeb, .thumb, .thumbeb => "aapcs",635 .arm, .armeb, .thumb, .thumbeb => "aapcs",
644 .loongarch64 => switch (target.abi) {636 .loongarch64 => switch (target.abi) {
...@@ -656,15 +648,7 @@ pub fn llvmMachineAbi(target: *const std.Target) ?[:0]const u8 {...@@ -656,15 +648,7 @@ pub fn llvmMachineAbi(target: *const std.Target) ?[:0]const u8 {
656 .gnuabin32, .muslabin32 => "n32",648 .gnuabin32, .muslabin32 => "n32",
657 else => "n64",649 else => "n64",
658 },650 },
659 .powerpc64 => switch (target.os.tag) {651 .powerpc64, .powerpc64le => "elfv2", // We do not support ELFv1.
660 .freebsd => if (target.os.version_range.semver.isAtLeast(.{ .major = 13, .minor = 0, .patch = 0 }) orelse false)
661 "elfv2"
662 else
663 "elfv1",
664 .openbsd => "elfv2",
665 else => if (target.abi.isMusl()) "elfv2" else "elfv1",
666 },
667 .powerpc64le => "elfv2",
668 .riscv64, .riscv64be => if (target.cpu.has(.riscv, .e))652 .riscv64, .riscv64be => if (target.cpu.has(.riscv, .e))
669 "lp64e"653 "lp64e"
670 else if (target.cpu.has(.riscv, .d))654 else if (target.cpu.has(.riscv, .d))
test/tests.zig+1-1
...@@ -801,7 +801,7 @@ const test_targets = blk: {...@@ -801,7 +801,7 @@ const test_targets = blk: {
801 .link_libc = true,801 .link_libc = true,
802 .extra_target = true,802 .extra_target = true,
803 },803 },
804 // Requires ELFv1 linker support.804 // glibc's build-many-glibcs.py currently only builds this target for ELFv1.
805 // .{805 // .{
806 // .target = .{806 // .target = .{
807 // .cpu_arch = .powerpc64,807 // .cpu_arch = .powerpc64,