Skip to content

feat(relinker): add opt-in PEXT and PDEP lowering for Rosetta - #189

Open
Thimo188 wants to merge 5 commits into
mainfrom
upstream-pr/12678
Open

Thimo188 wants to merge 5 commits into
mainfrom
upstream-pr/12678

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#12678, originally opened by Mherberts.

Source commit: 72bd72605cd2760a3fbf0df015e84d096c8d6c4b. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

Add the explicit --lower-bit-permutation option for scalar 32/64-bit PEXT/PDEP lowering with --to-rosetta. Default Rosetta output keeps the native instructions. Register masks and eligible RSP-relative masks are lowered; unsupported memory forms remain native. Both executable and bundled-module conversion receive the option.

The older-host motivation has published probe evidence: kiaramaldonado's merged #7953 includes raw PDEP Illegal instruction: 4 and PEXT Illegal instruction: 4 results from an Apple M2 running macOS 14.8.9, using isolated x86-64 processes built with Apple clang 15.0.0. Modern M1/M5 reports execute the instructions, which is why this remains opt-in. This is an independent measurement, not a new run on my Windows host; no converted title or performance gain is claimed.

Resolved current-main conflicts while preserving --omit-unavailable-dependencies alongside the lowering option. Merge-order dependencies: boykopovar#11525 first, as requested by its author, and boykopovar#15032 before this PR to avoid competing edits to guest-builder option propagation. This PR waits behind both. On the later rebase, retain boykopovar#11525's data-range argument to Convert, boykopovar#15032's function-symbol-root option, and this PR's lowering option; these implement separate behavior.

Tested

Head 72bd72605c, merged with main 04a9eb4fa2. Windows x64, MinGW GCC 13.2.0, Python 3.13.15, Ninja Release, ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON.

  • Complete relinker-only build passed.
  • Seven focused CTests passed: andn_lowering, masked_store_lowering, relinker_conversion, amd64_only_windows, bit_permutation_lowering, cli_args, amd64_only_converter.
  • Five of the twelve selected CTests did not pass locally: the two red-zone executables could not be started, and guest_intel_trampolines, to_rosetta, bit_permutation_conversion were blocked when Windows Application Control refused the compiled relinker (WinError 4551). Hosted CI subsequently passed on this head: Linux, Windows (686/686 tests), macOS arm64, macOS x86-64 and Linux ASan. Build run. No Windows security setting was changed.
  • Conventions against upstream/main and git diff --check upstream/main...HEAD passed. The required comparison against the fork's outdated origin/main also ran and reports six unrelated upstream commit-subject errors plus existing debt-length warnings.

Independent earlier execution coverage: rooklz's review ran 65,856 generated-stub cases under Rosetta on an M5 with macOS 26.2 and killed 25 mutants. That review predates this integration update. No local Mac/Rosetta run, old-M2 retest, retail-title test or full product build.

Independent update on this exact head: TechLevelZero's AMD run merged 72bd726 onto main 5b1d381 and reports 1,076 passed, seven skipped and four failures already present or unstable on main, with no new Vulkan validation IDs. Host: AMD Radeon RX 6300, Mesa 25.2.8, Ubuntu 26.04.1. This is contributor-reported coverage, not a local run.

Review audit on 2026-11-05, exact head 72bd72605cd2760a3fbf0df015e84d096c8d6c4b: all four hosted relinker configurations (Linux, Windows, macOS arm64 and macOS x86-64), relinker ASan, eligibility, conventions and labels have successful completed checks; full product jobs were skipped by workflow policy. The published older-host evidence and the Usage-column correction are present in this head. The requested review changes are ready for reassessment.

Current overlap boykopovar#15032 is option plumbing in CliArgs.cpp, GuestImage.hpp, GuestModuleBuilder.cpp and Conversion.cpp; it implements function-symbol roots, not PEXT/PDEP. Its merge order is recorded on the checklist. Manually inspected the newly listed base-conflicting boykopovar#6149 (module-args test source), boykopovar#13486 (zero finalizers/stub-window safety), boykopovar#15245 (executable exports), boykopovar#14001 (program-header-table bounds) and boykopovar#15651 (section links/entry sizes); these do not implement this lowering or TLS image comparison. Older manual checks remain historical evidence, not a claim that base-conflicting PRs merge cleanly.

Checklist

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants