fix(libkernel): include link.h only on Linux in the dynamic loader test #22074

Merged
kurexw merged 1 commit from upstream-pr/22074 into main 2026-11-17 06:37:51 +00:00
kurexw commented 2026-11-17 03:55:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kurexw on 2026-11-17T03:55:18Z.


What

#16922 added #include <link.h> to core/libs/tests/GuestDynamicLoader.cpp in the non-Windows branch. macOS has no <link.h>, so guest_dynamic_loader_tests doesn't compile there:

core/libs/tests/GuestDynamicLoader.cpp:18:10: fatal error: 'link.h' file not found

The only code that uses the header (dl_iterate_phdr in the program-image check) is already inside #ifdef __linux__. This PR puts the include under the same #ifdef __linux__, inside the non-Windows branch. Linux still compiles the same code, and nothing else changes.

Tested

macOS 27.2 on an Apple M4, with Apple clang for an x86-64 build under Rosetta.

  • On main at d642b4efee, the file fails with the error above.
  • With this PR, ninja guest_dynamic_loader_tests builds.
  • ctest -R '^guest_dynamic_loader$' passed in three runs out of three. The Linux-only program-image check isn't compiled on macOS, so it didn't run.
  • I didn't build this on Linux or Windows. On Linux the preprocessed file is unchanged, and Windows takes the other 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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5350293123 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22074). Originally posted by [kurexw](https://github.com/kurexw) on 2026-11-17T03:55:18Z. --- ### What #16922 added `#include <link.h>` to `core/libs/tests/GuestDynamicLoader.cpp` in the non-Windows branch. macOS has no `<link.h>`, so `guest_dynamic_loader_tests` doesn't compile there: ``` core/libs/tests/GuestDynamicLoader.cpp:18:10: fatal error: 'link.h' file not found ``` The only code that uses the header (`dl_iterate_phdr` in the program-image check) is already inside `#ifdef __linux__`. This PR puts the include under the same `#ifdef __linux__`, inside the non-Windows branch. Linux still compiles the same code, and nothing else changes. ### Tested macOS 27.2 on an Apple M4, with Apple clang for an x86-64 build under Rosetta. - On `main` at d642b4efee, the file fails with the error above. - With this PR, `ninja guest_dynamic_loader_tests` builds. - `ctest -R '^guest_dynamic_loader$'` passed in three runs out of three. The Linux-only program-image check isn't compiled on macOS, so it didn't run. - I didn't build this on Linux or Windows. On Linux the preprocessed file is unchanged, and Windows takes the other branch. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PrivacyOnion commented 2026-11-17 04:00:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T04:00:46Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against ccc9633adb:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_dynamic_loader_fixed_base_tests, guest_dynamic_loader_tests built cleanly.
  • CTest (guest_dynamic_loader, guest_dynamic_loader_fixed_base):
    1/2 Test #5242: guest_dynamic_loader ..............   Passed    0.02 sec
    2/2 Test #5243: guest_dynamic_loader_fixed_base ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 2
    
  • Code reading:
    • Verified core/libs/tests/GuestDynamicLoader.cpp conditionally includes <link.h> only when linux is defined inside the non-Windows preprocessor branch
    • Confirmed that dl_iterate_phdr usage in GuestDynamicLoader.cpp is already guarded by #ifdef linux, making the header inclusion match its usage exactly
    • Verified that macOS and non-Linux POSIX environments (which do not provide <link.h>) will no longer encounter fatal compilation errors
    • Checked Windows code paths and confirmed they remain completely unchanged under the #if defined(_WIN32) branch
    • Verified AGENTS.md compliance: conventions passed, no unauthorized comments, no forbidden files added

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5932588423 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22074#pullrequestreview-5932588423). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-17T04:00:46Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `ccc9633adb`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_dynamic_loader_fixed_base_tests`, `guest_dynamic_loader_tests` built cleanly. - **CTest** (`guest_dynamic_loader`, `guest_dynamic_loader_fixed_base`): ``` 1/2 Test #5242: guest_dynamic_loader .............. Passed 0.02 sec 2/2 Test #5243: guest_dynamic_loader_fixed_base ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 2 ``` - **Code reading**: - Verified core/libs/tests/GuestDynamicLoader.cpp conditionally includes <link.h> only when __linux__ is defined inside the non-Windows preprocessor branch - Confirmed that dl_iterate_phdr usage in GuestDynamicLoader.cpp is already guarded by #ifdef __linux__, making the header inclusion match its usage exactly - Verified that macOS and non-Linux POSIX environments (which do not provide <link.h>) will no longer encounter fatal compilation errors - Checked Windows code paths and confirmed they remain completely unchanged under the #if defined(_WIN32) branch - Verified AGENTS.md compliance: conventions passed, no unauthorized comments, no forbidden files added Looks Good To Me
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!22074
No description provided.