From 2cc638a252407f8127e48fe84cc127a20485f726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 25 May 2026 12:51:37 +0200 Subject: [PATCH] Also, let's run it on CI. --- .github/workflows/build.yml | 16 +++++++++++++++- cmake/Toolchains/loongarch64-linux-gnu.cmake | 18 +++++++++--------- cmake/scripts/setup-loongarch64-cross.sh | 2 +- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ffd939117..3f5b865d48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -232,6 +232,13 @@ jobs: args: make -C libretro -f Makefile -j2 id: clang-libretro + - os: ubuntu-latest + extra: loongarch64 + cc: gcc + cxx: g++ + args: ./b.sh --loongarch64 PPSSPPHeadless + id: loongarch64 + - os: macos-latest extra: test cc: clang @@ -278,12 +285,19 @@ jobs: ndk-version: r21e - name: Install Linux dependencies - if: runner.os == 'Linux' && matrix.extra != 'android' + if: runner.os == 'Linux' && matrix.extra != 'android' && matrix.extra != 'loongarch64' run: | sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse" sudo apt-get update -y -qq sudo apt-get install libsdl2-dev libgl1-mesa-dev libglu1-mesa-dev libsdl2-ttf-dev libfontconfig1-dev + - name: Install loongarch64 cross-compilation dependencies + if: matrix.extra == 'loongarch64' + 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 + - name: Install iOS dependencies if: matrix.id == 'ios' run: | diff --git a/cmake/Toolchains/loongarch64-linux-gnu.cmake b/cmake/Toolchains/loongarch64-linux-gnu.cmake index 6338c590fb..b39ed83905 100644 --- a/cmake/Toolchains/loongarch64-linux-gnu.cmake +++ b/cmake/Toolchains/loongarch64-linux-gnu.cmake @@ -14,15 +14,15 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # No X11 in the sysroot; disable the X11 Vulkan path to avoid include-dir errors. set(USING_X11_VULKAN OFF CACHE BOOL "" FORCE) -# Bypass find_package(OpenGL REQUIRED). A stub libGL.so is required so that -# GLEW's static archive can be linked via PLT entries (direct B26 branches to -# address 0 would overflow on LoongArch). -# -# Primary: run cmake/scripts/setup-loongarch64-cross.sh (sudo) once — it -# installs the stub + GL headers into the sysroot. -# Fallback: the stub can also sit in /stublibs/libGL.so; -# b.sh --loongarch64 creates this automatically on first run. -set(OPENGL_LIBRARIES GL CACHE STRING "" FORCE) +# Use legacy GL preference so find_package(OpenGL) looks for a single libGL.so +# rather than the GLVND split (libOpenGL.so + libGLX.so), which we don't have. +# A stub libGL.so + GL headers must be present in the sysroot; they are placed +# there by cmake/scripts/setup-loongarch64-cross.sh (run once with sudo, or +# automatically by the CI install step). +set(OpenGL_GL_PREFERENCE LEGACY CACHE STRING "" FORCE) + +# b.sh also creates a stub in /stublibs/ as a local fallback so the +# linker can resolve GL/GLX calls from GLEW's static archive via PLT entries. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/stublibs" CACHE STRING "" FORCE) diff --git a/cmake/scripts/setup-loongarch64-cross.sh b/cmake/scripts/setup-loongarch64-cross.sh index 395369313b..978dbcebc1 100755 --- a/cmake/scripts/setup-loongarch64-cross.sh +++ b/cmake/scripts/setup-loongarch64-cross.sh @@ -22,7 +22,7 @@ fi # GL headers are platform-independent C headers; copy from the host. echo "Installing GL headers into sysroot..." mkdir -p $SYSROOT/include/GL -for h in gl.h glext.h glcorearb.h; do +for h in gl.h glext.h glcorearb.h glu.h; do [ -f /usr/include/GL/$h ] && cp /usr/include/GL/$h $SYSROOT/include/GL/ && echo " $h" done