fix(libkernel): expose earlier guest modules to Mach-O imports #8481

Closed
ycarogabriel-lgtm wants to merge 1 commit from upstream-pr/8481 into main
ycarogabriel-lgtm commented 2026-10-20 13:26:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycarogabriel-lgtm on 2026-10-20T13:26:49Z.


What

On macOS, load guest Mach-O modules with host RTLD_GLOBAL so a later relinked module can bind an import from a dependency loaded earlier. Preserve the guest's RTLD_LOCAL behavior for dlsym(RTLD_DEFAULT, ...) by checking the owning dyld image before returning a symbol. Linux and Windows paths keep their existing flag handling.

This extracts the module-visibility change and its focused dynamic-loader check from the former integration PR #7332. The known host limitation is recorded in the libkernel technical-debt entry.

Tested

  • Apple M1, macOS 26.6.2, x86-64 under Rosetta 2: ctest --test-dir build-mac -R '^guest_dynamic_loader$' passed at integration head b5fddb65c, which contains this change. The full non-GPU suite on its preceding integration head passed 842/843; the cold patched_libraries timeout passed alone.
  • This branch is one commit on current main; python3 tools/check_conventions.py --base origin/main passed. A standalone macOS build on main is blocked by its unchanged libc/General.cpp until #4627 (Apple time and stat fields) is integrated. The test was not rerun standalone on this branch.
  • No title was run locally. Linux and Windows were not tested locally; no GPU code changed.

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: #4627 for the macOS libc build; #7201 or its successor for the host module foundation
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4936444562 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8481). Originally posted by [ycarogabriel-lgtm](https://github.com/ycarogabriel-lgtm) on 2026-10-20T13:26:49Z. --- ### What On macOS, load guest Mach-O modules with host `RTLD_GLOBAL` so a later relinked module can bind an import from a dependency loaded earlier. Preserve the guest's `RTLD_LOCAL` behavior for `dlsym(RTLD_DEFAULT, ...)` by checking the owning dyld image before returning a symbol. Linux and Windows paths keep their existing flag handling. This extracts the module-visibility change and its focused dynamic-loader check from the former integration PR #7332. The known host limitation is recorded in the libkernel technical-debt entry. ### Tested <!-- 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. --> - Apple M1, macOS 26.6.2, x86-64 under Rosetta 2: `ctest --test-dir build-mac -R '^guest_dynamic_loader$'` passed at integration head `b5fddb65c`, which contains this change. The full non-GPU suite on its preceding integration head passed 842/843; the cold `patched_libraries` timeout passed alone. - This branch is one commit on current `main`; `python3 tools/check_conventions.py --base origin/main` passed. A standalone macOS build on `main` is blocked by its unchanged `libc/General.cpp` until #4627 (Apple time and stat fields) is integrated. The test was not rerun standalone on this branch. - No title was run locally. Linux and Windows were not tested locally; no GPU code changed. ### 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: #4627 for the macOS libc build; #7201 or its successor for the host module foundation - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-20 13:27:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T13:27: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:6291959619 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8481#issuecomment-6291959619). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T13:27: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!8481
No description provided.