Skip to content

Commit

Permalink
Merge pull request #21310 from alexrp/ppc64-tests
Browse files Browse the repository at this point in the history
Force ELFv2 for PPC64 and add `powerpc64-linux-(none,musl)` to CI
  • Loading branch information
andrewrk committed Sep 6, 2024
2 parents b230e4f + ee3efe8 commit 1511a41
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ pub fn addrSpaceCastIsValid(
}

pub fn llvmMachineAbi(target: std.Target) ?[:0]const u8 {
// 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
// that. With this hack, `powerpc64-linux-none` will at least work.
//
// Once our self-hosted linker can handle both ABIs, this hack should go away.
if (target.cpu.arch == .powerpc64) return "elfv2";

const have_float = switch (target.abi) {
.gnueabihf, .musleabihf, .eabihf => true,
else => false,
Expand Down Expand Up @@ -409,7 +417,6 @@ pub fn llvmMachineAbi(target: std.Target) ?[:0]const u8 {
return "ilp32";
}
},
//TODO add ARM, Mips, and PowerPC
else => return null,
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/behavior/union.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ test "reinterpret packed union" {
try comptime S.doTheTest();

if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; // TODO
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21050
if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21050
if (builtin.cpu.arch.isWasm()) return error.SkipZigTest; // TODO
try S.doTheTest();
Expand Down
1 change: 1 addition & 0 deletions test/behavior/vector.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@ test "store vector with memset" {
.mips64el,
.riscv64,
.powerpc,
.powerpc64,
=> {
// LLVM 16 ERROR: "Converting bits to bytes lost precision"
// https://github.com/ziglang/zig/issues/16177
Expand Down
24 changes: 24 additions & 0 deletions test/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,30 @@ const test_targets = blk: {
// .link_libc = true,
//},

.{
.target = .{
.cpu_arch = .powerpc64,
.os_tag = .linux,
.abi = .none,
},
},
.{
.target = .{
.cpu_arch = .powerpc64,
.os_tag = .linux,
.abi = .musl,
},
.link_libc = true,
},
// Requires ELFv1 linker support.
// .{
// .target = .{
// .cpu_arch = .powerpc64,
// .os_tag = .linux,
// .abi = .gnu,
// },
// .link_libc = true,
// },
.{
.target = .{
.cpu_arch = .powerpc64le,
Expand Down

0 comments on commit 1511a41

Please sign in to comment.