I got it working!
this is absolutely nuts that I was able to get this to work in only a few minutes!
I had to install the following packages (debian)
sudo apt install qemu-system-ppc qemu-utils binfmt-support qemu-user-static
and this is my build command:
zig build -fqemu -Dtarget=powerpc64-linux test --summary all
And I got the following output (I put a small warning when my test ran in big endian:
const native_endian = @import("builtin").target.cpu.arch.endian();
test "mem layout packed struct" {
const Pack = packed struct(u48) {
num1: u16 = 0x1234,
num2: u16 = 0x5678,
num3: u9 = 0b1_00000000,
num4: bool = true,
pad: u6 = 0,
};
const memory: [6]u8 = @bitCast(Pack{});
switch (native_endian) {
.big => {
try std.testing.expectEqual(
[6]u8{ 0x03, 0x00, 0x56, 0x78, 0x12, 0x34 },
memory,
);
std.log.warn("ran big endian test!", .{});
},
.little => {
try std.testing.expectEqual(
[6]u8{ 0x34, 0x12, 0x78, 0x56, 0x00, 0x03 },
memory,
);
std.log.warn("ran little endian test!", .{});
},
}
}
test
└─ run test stderr
[default] (warn): ran big endian test!
Build Summary: 5/5 steps succeeded; 7/7 tests passed
test success
├─ run test 4 passed 28ms MaxRSS:8M
│ └─ zig test Debug powerpc64-linux cached 8ms MaxRSS:36M
└─ run test 3 passed 23ms MaxRSS:8M
└─ zig test Debug powerpc64-linux cached 8ms MaxRSS:36M
again, this is nuts that zig can do this!!!