authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-09-05 01:12:53+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-09-05 01:15:33+02:00
log19895834b9c00caff29ad8b9173d1845314104c4
tree70c8c05a35cf063dd554e06aced5ed2e3db39475
parentf87dd43c1285d38d7a0f3092f6487bf1e1f4faa6
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

compiler: Force ELFv2 for powerpc64.

LLD does not support ELFv1. By forcing ELFv2, we can at least build working binaries for triples like `powerpc64-linux-none`.

1 files changed, 8 insertions(+), 1 deletions(-)

src/target.zig+8-1
......@@ -381,6 +381,14 @@ pub fn addrSpaceCastIsValid(
381381}
382382
383383pub fn llvmMachineAbi(target: std.Target) ?[:0]const u8 {
384 // LLD does not support ELFv1. Rather than having LLVM produce ELFv1 code and then linking it
385 // into a broken ELFv2 binary, just force LLVM to use ELFv2 as well. This will break when glibc
386 // is linked as glibc only supports ELFv2 for little endian, but there's nothing we can do about
387 // that. With this hack, `powerpc64-linux-none` will at least work.
388 //
389 // Once our self-hosted linker can handle both ABIs, this hack should go away.
390 if (target.cpu.arch == .powerpc64) return "elfv2";
391
384392 const have_float = switch (target.abi) {
385393 .gnueabihf, .musleabihf, .eabihf => true,
386394 else => false,
......@@ -409,7 +417,6 @@ pub fn llvmMachineAbi(target: std.Target) ?[:0]const u8 {
409417 return "ilp32";
410418 }
411419 },
412 //TODO add ARM, Mips, and PowerPC
413420 else => return null,
414421 }
415422}