feat(wasm-aot): translate relinked executables to WebAssembly #9096

Closed
SteelCrab wants to merge 4 commits from upstream-pr/9096 into main
SteelCrab commented 2026-10-21 12:08:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SteelCrab on 2026-10-21T12:08:49Z.


What

Add core/wasm-aot, a Rust translator from relinked x86-64 ELF images to WebAssembly memory64, including relocation/import binding, control flow, integer/SIMD/x87 operations, TLS, guest callbacks and runtime indirect-call patching.

Add synthetic executable fixtures with native and Unicorn CPU oracles and a dedicated Rust CI job. Unsupported instructions fail translation by default; diagnostic --allow-unsupported mode reports them and emits traps. Known limits are recorded in docs/dev/debt/wasm-aot.md.

Extracted prerequisite of #6879. The dependency chain records the requested landing order; the translator and its synthetic tests build directly on main. #10017 is needed when relinker output contains imported data. The two optional Emscripten runtime fixtures are staged here so the later runtime PR does not need translator-source changes.

Tested

Ubuntu 26.04.1 x86-64, GCC 15.2, Clang/libclang 21.1.8, Rust 1.98.0; based on main 47fa6eecf8e7124c88d26ccc37056c13713f7143.

  • cargo test --release --locked --manifest-path core/wasm-aot/Cargo.toml -- --nocapture: 98 passed, 0 failed, 5 explicitly ignored.
  • The executed suite covers synthetic ELF binding/discovery, integer and SIMD instructions, x87 operations/environment slots, exception unwinding, signals and runtime patching, using native and Unicorn oracles.
  • Ignored cases: three private-title asset tests and two Node runtime integration cases requiring linked Emscripten runtimes. They are not counted as passing. The runtime PR's emscripten-runtime job will explicitly execute both runtime cases with --ignored after its prerequisites merge.
  • Code and PR-template Conventions passed; overlap check completed. Its only component overlap is the temporary bundled copy in #6879.
  • CI: WASM AOT / rust-translator installs Clang/libclang and Rust 1.98.0, then runs the same complete asset-independent release/locked test command. The fork workflow needs approval; remote CI is not claimed as passing.
  • No browser/title execution, Windows, macOS or console validation is claimed.

The runtime integration #6879 is temporarily closed. Prerequisites now land one at a time within the contributor open-PR limit, beginning with #10017, which replaces #8899. This PR remains closed while its prerequisites land.

Remote status: Conventions passed. This prerequisite remains closed while its dependencies land in the sequential staging plan. No remote Rust build/test result is claimed. The passing build and test counts above are local results.

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: #9094, #10017
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4951293286 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9096). Originally posted by [SteelCrab](https://github.com/SteelCrab) on 2026-10-21T12:08:49Z. --- ### What Add `core/wasm-aot`, a Rust translator from relinked x86-64 ELF images to WebAssembly memory64, including relocation/import binding, control flow, integer/SIMD/x87 operations, TLS, guest callbacks and runtime indirect-call patching. Add synthetic executable fixtures with native and Unicorn CPU oracles and a dedicated Rust CI job. Unsupported instructions fail translation by default; diagnostic `--allow-unsupported` mode reports them and emits traps. Known limits are recorded in `docs/dev/debt/wasm-aot.md`. Extracted prerequisite of #6879. The dependency chain records the requested landing order; the translator and its synthetic tests build directly on main. #10017 is needed when relinker output contains imported data. The two optional Emscripten runtime fixtures are staged here so the later runtime PR does not need translator-source changes. ### Tested Ubuntu 26.04.1 x86-64, GCC 15.2, Clang/libclang 21.1.8, Rust 1.98.0; based on main `47fa6eecf8e7124c88d26ccc37056c13713f7143`. - `cargo test --release --locked --manifest-path core/wasm-aot/Cargo.toml -- --nocapture`: **98 passed, 0 failed, 5 explicitly ignored**. - The executed suite covers synthetic ELF binding/discovery, integer and SIMD instructions, x87 operations/environment slots, exception unwinding, signals and runtime patching, using native and Unicorn oracles. - Ignored cases: three private-title asset tests and two Node runtime integration cases requiring linked Emscripten runtimes. They are not counted as passing. The runtime PR's `emscripten-runtime` job will explicitly execute both runtime cases with `--ignored` after its prerequisites merge. - Code and PR-template Conventions passed; overlap check completed. Its only component overlap is the temporary bundled copy in #6879. - CI: **WASM AOT / `rust-translator`** installs Clang/libclang and Rust 1.98.0, then runs the same complete asset-independent release/locked test command. The fork workflow needs approval; remote CI is not claimed as passing. - No browser/title execution, Windows, macOS or console validation is claimed. The runtime integration #6879 is temporarily closed. Prerequisites now land one at a time within the contributor open-PR limit, beginning with #10017, which replaces #8899. This PR remains closed while its prerequisites land. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Remote status: [Conventions passed](https://github.com/boykopovar/AnyPS5/actions/runs/39597291476/job/119212654941). This prerequisite remains closed while its dependencies land in the sequential staging plan. No remote Rust build/test result is claimed. The passing build and test counts above are local results. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: #9094, #10017 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
github-actions[bot] commented 2026-10-21 12:09:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T12:09:08Z.


Thank you for your contribution! Authors with no pull requests merged into main can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315541912 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9096#issuecomment-6315541912). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T12:09:08Z. --- Thank you for your contribution! Authors with no pull requests merged into `main` can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

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!9096
No description provided.