From 2d59fffdb77c3eaaf050de1c5e55b27a89c07d50 Mon Sep 17 00:00:00 2001 From: ToyuAU Date: Thu, 8 Oct 2026 16:54:53 +1100 Subject: [PATCH] build(relinker): add a dependency-free conversion build mode --- .github/workflows/build.yml | 38 ++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 26 +++++++++++++++--------- CONTRIBUTING.md | 2 ++ core/relinker/CMakeLists.txt | 2 +- docs/dev/BUILD.md | 19 ++++++++++++++++++ 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e2215f19..357d973f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,44 @@ env: -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache jobs: + relinker: + name: Relinker (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + compiler: g++ + - os: windows-latest + compiler: g++ + - os: macos-latest + compiler: clang++ + env: + WINLIBS_RELEASE: 15.2.0posix-14.0.0-ucrt-r7 + WINLIBS_ZIP: winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v7 + - if: runner.os == 'Windows' + id: toolchain + uses: actions/cache@v6 + with: + path: C:\winlibs + key: ${{ env.WINLIBS_ZIP }} + - if: runner.os == 'Windows' && steps.toolchain.outputs.cache-hit != 'true' + run: | + curl -sSfL -o "$RUNNER_TEMP/winlibs.zip" "https://github.com/brechtsanders/winlibs_mingw/releases/download/$WINLIBS_RELEASE/$WINLIBS_ZIP" + 7z x "$RUNNER_TEMP/winlibs.zip" -oC:/winlibs > /dev/null + - if: runner.os == 'Windows' + run: echo 'C:\winlibs\mingw64\bin' >> "$GITHUB_PATH" + - run: cmake -S . -B build-relinker -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON + - run: cmake --build build-relinker --parallel 3 + - run: ctest --test-dir build-relinker --output-on-failure --timeout 120 + linux: runs-on: ubuntu-latest timeout-minutes: 30 diff --git a/CMakeLists.txt b/CMakeLists.txt index 672b0122f..3d29c38cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ function(add_test_executable target) endfunction() option(BUILD_TESTING "Build and register relinker tests" OFF) +option(ANYPS5_RELINKER_ONLY "Build the relinker without system libraries or third-party dependencies" OFF) if(BUILD_TESTING) enable_testing() if(MINGW) @@ -29,7 +30,22 @@ add_compile_definitions(APS5_ENABLE_TIMING_LOG=$ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++") +if(NOT APPLE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++") +endif() + +if(BUILD_TESTING) + find_package(Python3 QUIET COMPONENTS Interpreter) + if(Python3_Interpreter_FOUND) + add_test(NAME progress_report COMMAND ${Python3_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress.py) + endif() +endif() + +if(ANYPS5_RELINKER_ONLY) + add_subdirectory(core/relinker) + return() +endif() set(SDL_SHARED OFF CACHE BOOL "" FORCE) set(SDL_STATIC ON CACHE BOOL "" FORCE) @@ -72,11 +88,3 @@ add_subdirectory(core/Decoder/Jpeg) add_subdirectory(core/Decoder/Png) add_subdirectory(core/libs) add_subdirectory(core/relinker) - -if(BUILD_TESTING) - find_package(Python3 QUIET COMPONENTS Interpreter) - if(Python3_Interpreter_FOUND) - add_test(NAME progress_report COMMAND ${Python3_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress.py) - endif() -endif() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46e75f4c5..d6e42129b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,6 +18,8 @@ Toolchains are listed in the [build instructions](docs/dev/BUILD.md). +For relinker changes, use the [relinker-only build](docs/dev/BUILD.md#relinker-only) to build and test without third-party submodules, system libraries or a GPU. It also works on macOS. Changes to system libraries or shaders still need the full build and relevant runtime tests. + ``` cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON cmake --build build diff --git a/core/relinker/CMakeLists.txt b/core/relinker/CMakeLists.txt index 62143a8b1..b5ccdf9ba 100644 --- a/core/relinker/CMakeLists.txt +++ b/core/relinker/CMakeLists.txt @@ -279,7 +279,7 @@ if(BUILD_TESTING) ) add_test(NAME strict_nid_filter COMMAND strict_nid_filter_tests) - if(UNIX AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") add_test_executable(to_intel_linux_stubs_tests ${CMAKE_CURRENT_SOURCE_DIR}/relinker/tests/ToIntelLinuxStubsTests.cpp ) diff --git a/docs/dev/BUILD.md b/docs/dev/BUILD.md index 90161520f..2b5eea0f9 100644 --- a/docs/dev/BUILD.md +++ b/docs/dev/BUILD.md @@ -1,5 +1,23 @@ # Build +## Relinker only + +The relinker can be built without initializing submodules or configuring SDL, Vulkan, FFmpeg, FreeType or the shader recompiler. It requires CMake, a C++20 compiler and a build tool. Python 3 enables the Python regression tests. + +```sh +cmake -S . -B build-relinker -G Ninja -DCMAKE_BUILD_TYPE=Release -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON +cmake --build build-relinker --parallel +ctest --test-dir build-relinker --output-on-failure +``` + +This mode builds the conversion tool and its tests on Linux, Windows and macOS, including Apple Silicon. macOS uses AppleClang from the Xcode command-line tools; Windows uses the MinGW-w64 toolchain below. The executable is `build-relinker/core/relinker/relinker` (`relinker.exe` on Windows with Ninja). + +The output remains x86-64 Linux ELF or Windows PE. Converted games need system libraries built for the target OS and a compatible x86-64 host. This mode does not build those libraries or provide macOS game execution. Tests inspect both output formats; execution checks run only on their compatible hosts. + +Use a separate build directory for the full build. + +## Full build + ```sh git submodule update --init --recursive ``` @@ -33,6 +51,7 @@ Project switches accept `ON` or `OFF`: | Flag | Default | Effect | |----------------------------------|---------|--------------------------------------------------| | `-DBUILD_TESTING=ON` | `OFF` | Build and register tests. | +| `-DANYPS5_RELINKER_ONLY=ON` | `OFF` | Build only the relinker and its tests, without third-party dependencies. | | `-DANYPS5_ENABLE_SPIRV_TOOLS=ON` | `OFF` | Enable SPIR-V validation and optimization. | | `-DAPS5_ENABLE_TIMING_LOG=ON` | `OFF` | Compile frame timing logging. | | `-DAPS5_AGC_CREATE_LOG=OFF` | `ON` | Disable successful `sceAgcCreateShader` logging. |