feat(build): add ANYPS5_GUEST_LIFTED to build the libraries for ps5lift #15799

Closed
oberonlift wants to merge 12 commits from upstream-pr/15799 into main
oberonlift commented 2026-11-04 16:23:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oberonlift on 2026-11-04T16:23:53Z.


Merge after #15798. Until the PRs before it merge, this PR also shows their changes; oberonlift/AnyPS5#9 shows only its own.

ps5lift is a static recompiler for PS5 executables: it lifts a game's x86-64 code to LLVM IR and compiles it ahead of time to aarch64, which runs on Linux against AnyPS5's own libraries with no interpreter or JIT. It runs AnyPS5's PS5-style test programs and a homebrew media player to its home screen; commercial games are not playable yet. Branch ps5lift-preview merges all of its PRs (how to try it); native Apple Silicon support is coming along fast. It is a separate approach from the ARM64 compiler in #5021; #1835 has an introduction.

This is 3 of 8 PRs that let AnyPS5's libraries run a lifted program; the lifter itself follows them.

x86-64: unchanged. The option is off by default, and with it off nothing is compiled differently, apart from a const_cast that libc's std::error_category code now takes in every build and that GCC compiles to the same object.

What

A build option that compiles the libraries for a guest that ps5lift has recompiled to aarch64.

  • ANYPS5_GUEST_LIFTED defines the macro for every target under core/libs, so the libs target builds all 368 libraries for a lifted guest on an aarch64 host, including those that need generated and configured headers. It needs Linux and Clang; configuring it otherwise stops with an error.
  • GuestCpu.hpp gets its lifted half: the helpers call GuestCpu*_nid_no_patch functions, which ps5lift's runtime implements on the guest's emulated CPU state, so the fenv functions, the timestamp counter, cpuid and xgetbv see the guest's FPU and the PS5's CPU.
  • ANYPS5_LIFTED_RUNTIME names ps5lift's runtime (#15798), which provides the GuestCpu functions. libc links it publicly, so every library that links libc gets it.
  • In lifted builds libc's x86-only helpers build portably: the soft-float builtins compute through <cfenv> and pick NaN results as x86 does, lrint and llrint raise invalid out of range and inexact when they round, as cvtsd2si does, the 16-byte atomics use __atomic_compare_exchange_n, Bessel uses std::sqrt and std::fma, and the call-trace thunks and the setjmp/longjmp assembly are left to the host runtime, which owns the guest registers. Direct builds are unchanged.
  • libc's std::error_category code casts a vtable entry away from const before it reinterprets it in every build, as Apple builds already did; Clang rejects the other form.
  • The FFmpeg package follows CMAKE_SYSTEM_PROCESSOR instead of always being the x86-64 one. A processor with no package, and MinGW on arm64, which has none either, stop the configuration.
  • In a lifted build the libraries' RPATH also names the runtime's directory, and the test programs under core/libs link the runtime and core/libs/tests/LiftedEmptyProgram.cpp, which hands it an empty program.
  • libSceNKWebKit leaves ForwardExports.cpp out of lifted builds. Its exports are x86 jmps to the exports they alias, and a lifted guest reaches an export only through an import bridge generated from its C declaration, which these aliases don't have; the debt file lists the gap.
  • CI: the workflow configures AnyPS5 with ANYPS5_GUEST_LIFTED on GitHub's Linux arm64 runner and runs the tests that ps5lift/tests/lifted_tests.txt names on lavapipe; ps5lift/tools/lifted_tests.py builds the files their commands name and runs them with ctest. The list holds the 101 tests whose programs do not link libc.

#5021 also changes some of the same files: JumpBuffer.cpp.

Tested

Compiled for x86-64 Linux before and after this PR (GCC 13, same flags): all 154 objects it reaches are byte-identical.

On a DGX Spark (aarch64 Linux, NVIDIA GB10, LLVM 18), with all eight PRs and ps5lift on top: every library builds for a lifted program, 2,285 of AnyPS5's own tests pass in that build on lavapipe, and ps5lift's 69 tests pass, among them its libc, exceptions, kernel, fiber and module-loading fixtures and upstream's libc test programs.

The conventions check passes on this branch.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #15797, #15798
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5157733491 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15799). Originally posted by [oberonlift](https://github.com/oberonlift) on 2026-11-04T16:23:53Z. --- **Merge after #15798.** Until the PRs before it merge, this PR also shows their changes; oberonlift/AnyPS5#9 shows only its own. **ps5lift** is a static recompiler for PS5 executables: it lifts a game's x86-64 code to LLVM IR and compiles it ahead of time to aarch64, which runs on Linux against AnyPS5's own libraries with no interpreter or JIT. It runs AnyPS5's PS5-style test programs and a homebrew media player to its home screen; commercial games are not playable yet. Branch [`ps5lift-preview`](https://github.com/oberonlift/AnyPS5/tree/ps5lift-preview) merges all of its PRs ([how to try it](https://github.com/oberonlift/AnyPS5/blob/ps5lift-preview/PS5LIFT_PREVIEW.md)); native Apple Silicon support is coming along fast. It is a separate approach from the ARM64 compiler in #5021; #1835 has an introduction. This is 3 of 8 PRs that let AnyPS5's libraries run a lifted program; the lifter itself follows them. **x86-64:** unchanged. The option is off by default, and with it off nothing is compiled differently, apart from a `const_cast` that libc's `std::error_category` code now takes in every build and that GCC compiles to the same object. ### What A build option that compiles the libraries for a guest that ps5lift has recompiled to aarch64. - `ANYPS5_GUEST_LIFTED` defines the macro for every target under `core/libs`, so the `libs` target builds all 368 libraries for a lifted guest on an aarch64 host, including those that need generated and configured headers. It needs Linux and Clang; configuring it otherwise stops with an error. - `GuestCpu.hpp` gets its lifted half: the helpers call `GuestCpu*_nid_no_patch` functions, which ps5lift's runtime implements on the guest's emulated CPU state, so the fenv functions, the timestamp counter, `cpuid` and `xgetbv` see the guest's FPU and the PS5's CPU. - `ANYPS5_LIFTED_RUNTIME` names ps5lift's runtime (#15798), which provides the `GuestCpu` functions. libc links it publicly, so every library that links libc gets it. - In lifted builds libc's x86-only helpers build portably: the soft-float builtins compute through `<cfenv>` and pick NaN results as x86 does, `lrint` and `llrint` raise invalid out of range and inexact when they round, as `cvtsd2si` does, the 16-byte atomics use `__atomic_compare_exchange_n`, Bessel uses `std::sqrt` and `std::fma`, and the call-trace thunks and the `setjmp`/`longjmp` assembly are left to the host runtime, which owns the guest registers. Direct builds are unchanged. - libc's `std::error_category` code casts a vtable entry away from `const` before it reinterprets it in every build, as Apple builds already did; Clang rejects the other form. - The FFmpeg package follows `CMAKE_SYSTEM_PROCESSOR` instead of always being the x86-64 one. A processor with no package, and MinGW on arm64, which has none either, stop the configuration. - In a lifted build the libraries' RPATH also names the runtime's directory, and the test programs under `core/libs` link the runtime and `core/libs/tests/LiftedEmptyProgram.cpp`, which hands it an empty program. - libSceNKWebKit leaves `ForwardExports.cpp` out of lifted builds. Its exports are x86 `jmp`s to the exports they alias, and a lifted guest reaches an export only through an import bridge generated from its C declaration, which these aliases don't have; the debt file lists the gap. - **CI**: the workflow configures AnyPS5 with `ANYPS5_GUEST_LIFTED` on GitHub's Linux arm64 runner and runs the tests that `ps5lift/tests/lifted_tests.txt` names on lavapipe; `ps5lift/tools/lifted_tests.py` builds the files their commands name and runs them with ctest. The list holds the 101 tests whose programs do not link libc. #5021 also changes some of the same files: `JumpBuffer.cpp`. ### Tested Compiled for x86-64 Linux before and after this PR (GCC 13, same flags): all 154 objects it reaches are byte-identical. On a DGX Spark (aarch64 Linux, NVIDIA GB10, LLVM 18), with all eight PRs and ps5lift on top: every library builds for a lifted program, 2,285 of AnyPS5's own tests pass in that build on lavapipe, and ps5lift's 69 tests pass, among them its libc, exceptions, kernel, fiber and module-loading fixtures and upstream's libc test programs. The conventions check passes on this branch. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #15797, #15798 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15799
No description provided.