Big-endian hosts

AArch64 is little-endian, so on a big-endian host guest memory keeps the guest's byte order and everything that reads or writes a guest value as a number converts it:

Arch POWER's big-endian glibc is ELFv2, as LLD links it. Its preset (linux-ppc64-elfv2-cross, SNX_PPC64_ELFV2) builds for ELFv2 with -mabi=elfv2, every runtime and the launcher. Its system root is pkgforge's Arch image of the architecture with GCC's runtime installed into it, as the appimage-cross job makes it.

What was run under qemu-ppc64: the Linux runtime's tests (gnuabi_*, endian, cas128), tools/gnuabi_diff.py --suite all against qemu-aarch64 (the CPU suite covers SIMD, floating point, exclusives and unaligned accesses), a glibc program, and the AArch64-hosted GCC 16.2 compiling a C file with a glibc system root.

The Switch runtime

Everything the Switch runtime reads or writes in guest memory as a number converts it, with converting helpers that compile to nothing on a little-endian host:

The build (the Arch POWER system root of the appimage-cross job, with GCC's runtime and SDL3 installed):

export SNX_SYSROOT=/path/to/arch-power-ppc64
cmake --preset linux-ppc64-elfv2-cross -DSNX_SYSTEM_SDL3=ON
cmake --build --preset linux-ppc64-elfv2-cross
ctest --preset linux-ppc64-elfv2-cross -j"$(nproc)"

The Vita and Game Boy Advance runtimes are ported the same way. Their guests are little-endian Arm, and what reads or writes guest memory as a number goes through endian.h: vita_read16, vita_read32 and their writes (vita/runtime/process.h) for a guest address, and snx_ld_le32 and its kin for the loader's files, GXP programs, the HLE's structures and the GBA's bus, video memory and wave RAM. Network order and the trophy pack stay big-endian (snx_ld_be32). The Vita renderer's push constants are swapped to little-endian for the device, and the GBA's frame is a texture of packed 0xAABBGGRR words (SDL_PIXELFORMAT_ABGR8888) in either order. Their tests pass under qemu-ppc64, jsmolka's GBA test ROMs among them: their modules are linked by the backend's linker, as the Switch's are. No Vita or GBA game has run on a big-endian machine yet.

The 3DS runtime is built too, as the AppImage carries every runtime, but it isn't ported: its board, services and GPU read the guest's memory as host numbers, so it doesn't run 3DS games on a big-endian host.

A rebuild that runs CMake again needs the preset's PKG_CONFIG_LIBDIR and PKG_CONFIG_SYSROOT_DIR in the environment: cmake --build --preset sets them, a plain cmake --build of the folder doesn't, and SDL then finds the build machine's Wayland and DRM.


Made from docs/hosts/ppc64.md at 69237645142c. GPL-3.0-or-later.