Add a riscv64 cross build, generalizing the loongarch64 one

The pieces were nearly all in place already - CMakeLists has detected
riscv64 and set RISCV64 since the backend landed - so this is mostly a
matter of not hardcoding loongarch64 in the cross-build plumbing:

- setup-loongarch64-cross.sh becomes setup-cross.sh <target>, taking the
  triple and dynamic linker name from the argument.
- b.sh gains --riscv64, and the GL stub block is keyed off a compiler
  variable rather than a loongarch64-only flag.
- New cmake/Toolchains/riscv64-linux-gnu.cmake, mirroring the existing one.

The SDL carve-out moves from LOONGARCH64_DEVICE to a new HEADLESS_CROSS
option set by b.sh. That flag was keyed off the target architecture, which
is also true when building natively on such a machine - harmless so far,
but riscv64 hardware that people actually build PPSSPP on exists, and it
should still get the normal SDL frontend.

Both toolchain files now find qemu rather than assuming the static build:
Debian ships the static binaries in qemu-user-static and the dynamic ones
in qemu-user, and only the latter is available on some releases. Neither
being present is fine too - it just means no compile-check programs run.

Verified by a clean loongarch64 build; riscv64 is untested so far, the
toolchain isn't installed here yet.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-09-19 11:52:16 -06:00
1 parent ba06b454f3
commit 9a29bf84d8
6 files changed
+129 -46

No files matched your search

+12 -5
View File
@@ -279,6 +279,13 @@ jobs:
args: ./b.sh --loongarch64 PPSSPPHeadless
id: loongarch64
- os: ubuntu-26.04
extra: riscv64
cc: gcc
cxx: g++
args: ./b.sh --riscv64 PPSSPPHeadless
id: riscv64
- os: macos-latest
extra: test
cc: clang
@@ -318,7 +325,7 @@ jobs:
ndk-version: r29
- name: Install Linux dependencies
if: runner.os == 'Linux' && matrix.extra != 'android' && matrix.extra != 'loongarch64'
if: runner.os == 'Linux' && matrix.extra != 'android' && matrix.extra != 'loongarch64' && matrix.extra != 'riscv64'
run: |
sudo apt-get update -y -qq
sudo apt-get install libsdl3-dev libgl1-mesa-dev libglu1-mesa-dev libsdl3-ttf-dev libfontconfig1-dev libcurl4-openssl-dev
@@ -327,12 +334,12 @@ jobs:
if: runner.os == 'macOS' && matrix.id == 'macos'
run: brew install sdl3 sdl3_ttf
- name: Install loongarch64 cross-compilation dependencies
if: matrix.extra == 'loongarch64'
- name: Install cross-compilation dependencies
if: matrix.extra == 'loongarch64' || matrix.extra == 'riscv64'
run: |
sudo apt-get update -y -qq
sudo apt-get install -y gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu binutils-loongarch64-linux-gnu libgl-dev libglu1-mesa-dev
sudo cmake/scripts/setup-loongarch64-cross.sh
sudo apt-get install -y gcc-14-${{ matrix.extra }}-linux-gnu g++-14-${{ matrix.extra }}-linux-gnu binutils-${{ matrix.extra }}-linux-gnu libgl-dev libglu1-mesa-dev
sudo cmake/scripts/setup-cross.sh ${{ matrix.extra }}
- name: Install iOS dependencies
if: matrix.id == 'ios'