fix(libs): build with libc++ #4629

Merged
mugurc merged 1 commit from upstream-pr/4629 into main 2026-10-14 21:46:06 +00:00
mugurc commented 2026-10-12 17:03:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mugurc on 2026-10-12T17:03:10Z.


What

Where Apple clang's libc++ differs from the libstdc++ the sources relied on. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298).

  • std::atomic<std::shared_ptr<T>> is not provided by libc++. AtomicSharedPtr<T> is that type where the library defines __cpp_lib_atomic_shared_ptr (libstdc++ 12 and later, so the Linux and Windows builds) and a mutex-guarded pointer with the same member functions elsewhere. The AGC driver uses it in place of the atomic.
  • std::atomic_ref<const T> is not provided; the page span reads go through a non-const reference.
  • std::filesystem::file_time_type::clock::to_sys is not provided by libc++; std::chrono::file_clock::to_sys is.
  • std::max and std::min do not deduce when uintptr_t and uint64_t differ, as they do on macOS; the guest range arithmetic names the type.
  • <string> and <initializer_list> are included where the sources and tests use them.

Tested

  • macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2. The macOS pull requests are meant to be taken together (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298); with all of them applied on current main, ninja, ninja libs and ctest -j4 on macOS ran 940 tests in the last full run (main 2a5eca11c): 582 passed, 357 were skipped (no Vulkan loader in the environment, no guest address-space arena on macOS) and 1 failed. The failure is guest_socket_read_write, an existing test this series does not touch: after the peer has closed, the write that it expects to fail with EPIPE fails with ECONNRESET or EAGAIN on macOS, in 8 of 60 runs of the test alone.
  • This pull request alone: ShaderUtils.cpp, the SaveData export and the five tests compile on macOS. The AGC driver sources need the other pull requests of the series to compile on macOS (generated shader headers, linux/udmabuf.h, pthread_getattr_np); the lines this one changes in them compile in that context.
  • Linux and Windows: the full build and tests of this pull request merged with the other macOS pull requests of the series (seventeen of them, on main 33ae282e4), run on my fork: 960 tests on Linux and 966 on Windows pass (https://github.com/mugurc/AnyPS5/actions/runs/38256280627). AtomicSharedPtr<T> is std::atomic<std::shared_ptr<T>> there, so the types are unchanged.

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 in TechnicalDebt
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4832575018 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4629). Originally posted by [mugurc](https://github.com/mugurc) on 2026-10-12T17:03:10Z. --- ### What Where Apple clang's libc++ differs from the libstdc++ the sources relied on. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298). - `std::atomic<std::shared_ptr<T>>` is not provided by libc++. `AtomicSharedPtr<T>` is that type where the library defines `__cpp_lib_atomic_shared_ptr` (libstdc++ 12 and later, so the Linux and Windows builds) and a mutex-guarded pointer with the same member functions elsewhere. The AGC driver uses it in place of the atomic. - `std::atomic_ref<const T>` is not provided; the page span reads go through a non-const reference. - `std::filesystem::file_time_type::clock::to_sys` is not provided by libc++; `std::chrono::file_clock::to_sys` is. - `std::max` and `std::min` do not deduce when `uintptr_t` and `uint64_t` differ, as they do on macOS; the guest range arithmetic names the type. - `<string>` and `<initializer_list>` are included where the sources and tests use them. ### Tested - macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2. The macOS pull requests are meant to be taken together (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298); with all of them applied on current `main`, `ninja`, `ninja libs` and `ctest -j4` on macOS ran 940 tests in the last full run (`main` 2a5eca11c): 582 passed, 357 were skipped (no Vulkan loader in the environment, no guest address-space arena on macOS) and 1 failed. The failure is `guest_socket_read_write`, an existing test this series does not touch: after the peer has closed, the write that it expects to fail with `EPIPE` fails with `ECONNRESET` or `EAGAIN` on macOS, in 8 of 60 runs of the test alone. - This pull request alone: `ShaderUtils.cpp`, the SaveData export and the five tests compile on macOS. The AGC driver sources need the other pull requests of the series to compile on macOS (generated shader headers, `linux/udmabuf.h`, `pthread_getattr_np`); the lines this one changes in them compile in that context. - Linux and Windows: the full build and tests of this pull request merged with the other macOS pull requests of the series (seventeen of them, on `main` 33ae282e4), run on my fork: 960 tests on Linux and 966 on Windows pass (https://github.com/mugurc/AnyPS5/actions/runs/38256280627). `AtomicSharedPtr<T>` is `std::atomic<std::shared_ptr<T>>` there, so the types are unchanged. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-12 17:51:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T17:51:40Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#3891 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4156 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4396 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4397 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4422 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4423 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4424 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4520 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4521 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4522 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4523 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4566 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4599 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4718 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4740 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4749 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4760 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#4813 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
#5021 core/libs/prx/libc/include/general/AtomicSharedPtr.hpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129618815 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4629#issuecomment-6129618815). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T17:51:40Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #3891 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4156 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4396 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4397 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4422 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4423 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4424 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4520 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4521 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4522 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4523 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4566 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4599 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4718 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4740 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4749 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4760 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #4813 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` | | #5021 | | | `core/libs/prx/libc/include/general/AtomicSharedPtr.hpp` |
jotitadev commented 2026-10-14 21:07:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T21:07:31Z.

Review: COMMENTED


Checked on Apple M2 Max, macOS 27.2, Xcode 27.0 (Apple clang 21.0.0, -fexperimental-library), x86-64 full build under Rosetta. Head facc03ae9 on main 41cc655b8, with #4627 applied. The merge is clean.

  • In the build, GuestDup, GuestPthreadMutexattr and GuestSchedPriority compile with this PR. On main they fail on std::initializer_list.
  • The AGC sources are not reached in the build until libkernel links, so I compiled the touched files with -fsyntax-only and the ninja command line:
    • libSceAgc/Shader/src/ShaderUtils.cpp: fails on main (incomplete std::basic_string), compiles with the PR.
    • Execution/src/GuestMemory.cpp: on main, two atomic_ref errors plus the two pthread_getattr_np errors. With the PR only the pthread_getattr_np ones remain, as the description says.
    • GuestBufferMemory.cpp (linux/udmabuf.h) and Recorder.cpp (generated _spv.h) still stop on what the description lists for the other PRs.
  • libSceSaveData.native/Export.cpp already compiles on main with this toolchain: Xcode 27's libc++ provides file_time_type::clock::to_sys. The file_clock::to_sys change is harmless here; it matters for older libc++.

Written with AI assistance (Claude Code). I ran the builds above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5524671938 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4629#pullrequestreview-5524671938). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-14T21:07:31Z. **Review:** COMMENTED --- Checked on Apple M2 Max, macOS 27.2, Xcode 27.0 (Apple clang 21.0.0, `-fexperimental-library`), x86-64 full build under Rosetta. Head facc03ae9 on `main` 41cc655b8, with #4627 applied. The merge is clean. - In the build, `GuestDup`, `GuestPthreadMutexattr` and `GuestSchedPriority` compile with this PR. On `main` they fail on `std::initializer_list`. - The AGC sources are not reached in the build until libkernel links, so I compiled the touched files with `-fsyntax-only` and the ninja command line: - `libSceAgc/Shader/src/ShaderUtils.cpp`: fails on `main` (incomplete `std::basic_string`), compiles with the PR. - `Execution/src/GuestMemory.cpp`: on `main`, two `atomic_ref` errors plus the two `pthread_getattr_np` errors. With the PR only the `pthread_getattr_np` ones remain, as the description says. - `GuestBufferMemory.cpp` (`linux/udmabuf.h`) and `Recorder.cpp` (generated `_spv.h`) still stop on what the description lists for the other PRs. - `libSceSaveData.native/Export.cpp` already compiles on `main` with this toolchain: Xcode 27's libc++ provides `file_time_type::clock::to_sys`. The `file_clock::to_sys` change is harmless here; it matters for older libc++. Written with AI assistance (Claude Code). I ran the builds above on my machine.
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!4629
No description provided.