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:
src/common/cpu/recompiler/ppc64 and mips64 built with PPC_BE and
MIPS_BE) read and write guest memory with the host's byte-reversed loads and stores, and compare in it with
snx_cas128's. The helpers and the tests that set and check lanes read and write a lane as a number through
SNX_VS and its kin in cpu.h, which swap on a big-endian host.common/utilities/endian.h
(snx_ld_le32, snx_st_le64 and their kin), which compile to plain copies on a little-endian host.scripts/le-unchanged.sh builds a base commit and the working tree on a little-endian machine and lists every
object whose code differs, and whether the recompiler's output for an AArch64 program changed.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.
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:
gr16/gr32/gr64 and gw16/gw32/gw64 (memory/mem.h) for a guest address, endian.h's snx_ld_le32 and
kin for a pointer into guest memory, and snx_le32_array and kin for a structure of words copied out of it or
about to be copied in. Bitfields over guest words are shifts and masks of the converted word.docs/platforms/nx/ipc.md): the generated dispatchers convert raw arguments and outputs, so a handler's are host
numbers, while buffers keep the guest's order and the handler converts what it reads in them. The kernel converts
the HIPC and CMIF headers and descriptors, and the compare-and-swaps on guest words (mutex tags, condition
variables, address arbitration) take converted operands.guest_vulkan) is refused on a big-endian host, and the game's own driver runs:
gpu/gvk passes Vulkan's structures, SPIR-V words and the numbers in them in the guest's byte order.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.