test(libkernel): build the __tls_get_addr test only on Linux and Windows #10885

Merged
imellag merged 1 commit from upstream-pr/10885 into main 2026-10-26 21:33:11 +00:00
imellag commented 2026-10-25 07:28:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-25T07:28:01Z.


What

core/libs/tests/GuestTlsGetAddr.cpp doesn't compile on macOS. Outside Windows it includes <link.h> and finds the host's TLS module with dl_iterate_phdr, and macOS has neither:

GuestTlsGetAddr.cpp:11:10: fatal error: 'link.h' file not found

Of the steps that fail on current main on macOS, it is the only one that didn't fail on main 3fcb5e4d76; the test was added after that, in cf27259538. On macOS the test couldn't pass anyway: there __tls_get_addr calls NotImplemented_nid_no_patch, because the macOS relinker binds guest modules to Aps5GuestTlsGetAddr_nid_no_patch and no library defines the guest TLS runtime yet. The libkernel debt file already records this.

This change registers the test only on Windows and Linux, the two hosts the test is written for, with the same if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") condition that libkernel's CMakeLists.txt already uses for other tests. Nothing changes on Windows and Linux. The __tls_get_addr entry in docs/dev/debt/libkernel.md already records that it throws on macOS, so the debt file is unchanged.

I didn't implement __tls_get_addr on macOS here. On macOS it is part of the guest TLS runtime (Aps5GuestTlsRegister, Aps5GuestTlsAllocate, Aps5GuestTlsGetAddr), and two versions of that already exist: one in #7201 (libc/src/specifics/macos/GuestRuntime.cpp) and one in mugurc's macOS series (8b52faaba5, "feat(libkernel): thread-local storage for Mach-O guests"). The test can come back on macOS with a Mach-O case once one of them is merged.

Tested

Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86-64 Release (-DCMAKE_OSX_ARCHITECTURES=x86_64, Ninja, BUILD_TESTING=ON).

  • On main 61fc572cee alone: compared with main 3fcb5e4d76, the only new failed step is GuestTlsGetAddr.cpp.o.
  • On main plus the open macOS build PRs and the parts of mugurc's series that #7201 also carries: without this change, everything builds except this test. With it, the whole build completes (cmake --build, exit 0), and ctest -N no longer lists guest_tls_get_addr.

Not built on Linux or Windows. The condition keeps the test registered there exactly as before.

check_conventions.py --base upstream/main passes. pr_overlap.py reports no conflicting lines. Of the pull requests it couldn't compare, only #7201 touches guest TLS, and it doesn't change this test or its CMake registration.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5002751037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10885). Originally posted by [imellag](https://github.com/imellag) on 2026-10-25T07:28:01Z. --- ### What `core/libs/tests/GuestTlsGetAddr.cpp` doesn't compile on macOS. Outside Windows it includes `<link.h>` and finds the host's TLS module with `dl_iterate_phdr`, and macOS has neither: ``` GuestTlsGetAddr.cpp:11:10: fatal error: 'link.h' file not found ``` Of the steps that fail on current `main` on macOS, it is the only one that didn't fail on `main` `3fcb5e4d76`; the test was added after that, in `cf27259538`. On macOS the test couldn't pass anyway: there `__tls_get_addr` calls `NotImplemented_nid_no_patch`, because the macOS relinker binds guest modules to `Aps5GuestTlsGetAddr_nid_no_patch` and no library defines the guest TLS runtime yet. The libkernel debt file already records this. This change registers the test only on Windows and Linux, the two hosts the test is written for, with the same `if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux")` condition that libkernel's `CMakeLists.txt` already uses for other tests. Nothing changes on Windows and Linux. The `__tls_get_addr` entry in `docs/dev/debt/libkernel.md` already records that it throws on macOS, so the debt file is unchanged. I didn't implement `__tls_get_addr` on macOS here. On macOS it is part of the guest TLS runtime (`Aps5GuestTlsRegister`, `Aps5GuestTlsAllocate`, `Aps5GuestTlsGetAddr`), and two versions of that already exist: one in #7201 (`libc/src/specifics/macos/GuestRuntime.cpp`) and one in mugurc's macOS series (`8b52faaba5`, "feat(libkernel): thread-local storage for Mach-O guests"). The test can come back on macOS with a Mach-O case once one of them is merged. ### Tested Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86-64 Release (`-DCMAKE_OSX_ARCHITECTURES=x86_64`, Ninja, `BUILD_TESTING=ON`). - **On `main` `61fc572cee` alone:** compared with `main` `3fcb5e4d76`, the only new failed step is `GuestTlsGetAddr.cpp.o`. - **On `main` plus the open macOS build PRs and the parts of mugurc's series that #7201 also carries:** without this change, everything builds except this test. With it, the whole build completes (`cmake --build`, exit 0), and `ctest -N` no longer lists `guest_tls_get_addr`. Not built on Linux or Windows. The condition keeps the test registered there exactly as before. `check_conventions.py --base upstream/main` passes. `pr_overlap.py` reports no conflicting lines. Of the pull requests it couldn't compare, only #7201 touches guest TLS, and it doesn't change this test or its CMake registration. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 07:53:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T07:53:19Z.

Review: APPROVED


Reviewed the updated head b2c32d8d5d against current main. The change now only gates guest_tls_get_addr test registration to Windows and Linux; the adjacent debt entry was removed, so #9461 no longer overlaps this diff. The CMake condition matches the existing host gating pattern in this file. git diff --check and check_conventions.py pass locally. The PR reports a successful macOS build/CTest listing from the author; hosted Linux and Windows product jobs are skipped, so I am not claiming those ran here. No remaining blocking issue found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642143162 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10885#pullrequestreview-5642143162). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T07:53:19Z. **Review:** APPROVED --- Reviewed the updated head b2c32d8d5d3a25c92b37ca19b04d5ef93ba6376b against current main. The change now only gates guest_tls_get_addr test registration to Windows and Linux; the adjacent debt entry was removed, so #9461 no longer overlaps this diff. The CMake condition matches the existing host gating pattern in this file. git diff --check and check_conventions.py pass locally. The PR reports a successful macOS build/CTest listing from the author; hosted Linux and Windows product jobs are skipped, so I am not claiming those ran here. No remaining blocking issue found.
THEMANnt commented 2026-10-26 19:16:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T19:16:22Z.

Review: APPROVED


Reviewed b2c32d8d5d3a25c92b37ca19b04d5ef93ba6376b. Approve; no actionable finding in this focused review.

The __tls_get_addr executable, linkage and CTest properties are gated together for Linux or Windows. Apple no longer registers a fixture for an unavailable platform path; Windows keeps its library search-path property.

Validation: Executed head/base CMake branches for Darwin, Linux and Windows. Candidate omits the target/test only on Darwin and retains the Windows environment property.

Scope / next step: Configuration behavior was tested; no new guest TLS runtime execution or macOS build is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5657677697 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10885#pullrequestreview-5657677697). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-26T19:16:22Z. **Review:** APPROVED --- Reviewed `b2c32d8d5d3a25c92b37ca19b04d5ef93ba6376b`. Approve; no actionable finding in this focused review. The __tls_get_addr executable, linkage and CTest properties are gated together for Linux or Windows. Apple no longer registers a fixture for an unavailable platform path; Windows keeps its library search-path property. **Validation:** Executed head/base CMake branches for Darwin, Linux and Windows. Candidate omits the target/test only on Darwin and retains the Windows environment property. **Scope / next step:** Configuration behavior was tested; no new guest TLS runtime execution or macOS build is claimed.
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!10885
No description provided.