build(audio): link one SDL copy on macOS #11049

Open
imellag wants to merge 3 commits from upstream-pr/11049 into main
imellag commented 2026-10-25 15:11:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-25T15:11:21Z.


What

This is mugurc's 63db337cd8 from his macOS series (ci/macos-series-2, listed on #1). mugurc is co-author of the commit. It sits on #10669, whose --exclude-libs lines it moves into the non-Apple branch.

On macOS the Objective-C runtime registers SDL's classes from every copy in the process. libSceAgcDriver, libSceVideoOut, libSceAudioIn and libSceAudioOut each link SDL2 statically, so a relinked game prints, for each of 14 SDL classes and each extra copy, Class SDL_... is implemented in both ... One of the duplicates must be removed or renamed, and the runtime warns this "may cause spurious casting failures and mysterious crashes".

On Apple, libSceAudioIn and libSceAudioOut now link libSceAgcDriver, which holds the process's SDL, instead of their own copy. Linux and Windows are unchanged.

Tested

Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86-64 Release under Rosetta 2 (-DCMAKE_OSX_ARCHITECTURES=x86_64, Ninja, BUILD_TESTING=ON). main alone doesn't build the libraries on macOS, so the tree is main 61fc572cee with #10423, the open macOS build PRs (#10366, #10419, #10552, #7631, #7804, #4630, #10540, #10659, #10660, #10669, #10676), #10889, #10898 and the parts of mugurc's series that #7201 also carries. Planet of Lana (PPSA19450) is relinked with that tree's relinker (--macos --to-rosetta).

  • Without this PR: 42 duplicate class warnings in the first 40 s of Lana, 14 each for libSceAudioIn, libSceAudioOut and libSceVideoOut against libSceAgcDriver.
  • With it: 14, all for libSceVideoOut, which still links its own copy. Moving it the same way is a follow-up. The Lana runs in #11047 and #11048 were made with this change.
  • ctest -R audio (51 tests) passes without and with it.

Linux and Windows: not built; the change only adds an if(APPLE) branch.

check_conventions.py --base upstream/main passes. pr_overlap.py reports no conflict; it couldn't compare #7201 and #5021 on the two CMake files, because both conflict with main.

#7201 (the whole macOS port) and #5021 (the native ARM64 AOT draft) carry their own versions of these functions. #7201's head (6687cbac29, 2026-10-16) conflicts with main, needs a rebase anyway, and is being split into smaller PRs such as #10552 and #10419. #5021 is a draft of more than 43,000 lines that conflicts with main and says no merge into main is implied. If either lands first with these functions, this PR is not needed and I will close it.

Checklist

  • Based on current main; no other open PR implements the same functions (except #7201 and #5021, see the end of Tested)
  • 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: #10669 (its commit is the first one on this branch)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5005925186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11049). Originally posted by [imellag](https://github.com/imellag) on 2026-10-25T15:11:21Z. --- ### What This is mugurc's `63db337cd8` from his macOS series (`ci/macos-series-2`, listed on #1). mugurc is co-author of the commit. It sits on #10669, whose `--exclude-libs` lines it moves into the non-Apple branch. On macOS the Objective-C runtime registers SDL's classes from every copy in the process. `libSceAgcDriver`, `libSceVideoOut`, `libSceAudioIn` and `libSceAudioOut` each link SDL2 statically, so a relinked game prints, for each of 14 SDL classes and each extra copy, `Class SDL_... is implemented in both ... One of the duplicates must be removed or renamed`, and the runtime warns this "may cause spurious casting failures and mysterious crashes". On Apple, `libSceAudioIn` and `libSceAudioOut` now link `libSceAgcDriver`, which holds the process's SDL, instead of their own copy. Linux and Windows are unchanged. ### Tested Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86-64 Release under Rosetta 2 (`-DCMAKE_OSX_ARCHITECTURES=x86_64`, Ninja, `BUILD_TESTING=ON`). `main` alone doesn't build the libraries on macOS, so the tree is `main` `61fc572cee` with #10423, the open macOS build PRs (#10366, #10419, #10552, #7631, #7804, #4630, #10540, #10659, #10660, #10669, #10676), #10889, #10898 and the parts of mugurc's series that #7201 also carries. Planet of Lana (PPSA19450) is relinked with that tree's relinker (`--macos --to-rosetta`). - **Without this PR:** 42 duplicate class warnings in the first 40 s of Lana, 14 each for `libSceAudioIn`, `libSceAudioOut` and `libSceVideoOut` against `libSceAgcDriver`. - **With it:** 14, all for `libSceVideoOut`, which still links its own copy. Moving it the same way is a follow-up. The Lana runs in #11047 and #11048 were made with this change. - `ctest -R audio` (51 tests) passes without and with it. Linux and Windows: not built; the change only adds an `if(APPLE)` branch. `check_conventions.py --base upstream/main` passes. `pr_overlap.py` reports no conflict; it couldn't compare #7201 and #5021 on the two CMake files, because both conflict with `main`. #7201 (the whole macOS port) and #5021 (the native ARM64 AOT draft) carry their own versions of these functions. #7201's head (`6687cbac29`, 2026-10-16) conflicts with `main`, needs a rebase anyway, and is being split into smaller PRs such as #10552 and #10419. #5021 is a draft of more than 43,000 lines that conflicts with `main` and says no merge into `main` is implied. If either lands first with these functions, this PR is not needed and I will close it. ### 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 (except #7201 and #5021, see the end of Tested) - [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: #10669 (its commit is the first one on this branch) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 15:15:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:15:16Z.

Review: APPROVED


Reviewed exact head afdd82c67b3372af27242bbfcec44374010fbf31. The Apple-only link changes make AudioIn and AudioOut depend on the existing AgcDriver shared target, whose own link line owns SDL2-static; their non-Apple SDL links remain unchanged. #10669 is still open and is correctly named as the dependency. The author reports the macOS duplicate-class warnings dropping from 42 to 14, with the remaining 14 coming from VideoOut, plus 51 audio tests passing. Hosted conventions/intake/eligibility checks pass; platform build jobs are skipped by path policy. I reviewed the CMake dependency and overlap context; I could not run the Apple build here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643821624 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11049#pullrequestreview-5643821624). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T15:15:16Z. **Review:** APPROVED --- Reviewed exact head `afdd82c67b3372af27242bbfcec44374010fbf31`. The Apple-only link changes make AudioIn and AudioOut depend on the existing AgcDriver shared target, whose own link line owns SDL2-static; their non-Apple SDL links remain unchanged. #10669 is still open and is correctly named as the dependency. The author reports the macOS duplicate-class warnings dropping from 42 to 14, with the remaining 14 coming from VideoOut, plus 51 audio tests passing. Hosted conventions/intake/eligibility checks pass; platform build jobs are skipped by path policy. I reviewed the CMake dependency and overlap context; I could not run the Apple build here.
MarcZX10 commented 2026-10-25 15:33:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:33:22Z.

Review: APPROVED


Reviewed exact head afdd82c67b3372af27242bbfcec44374010fbf31. On Apple, AudioIn and AudioOut now depend on the existing libSceAgcDriver shared target, which owns SDL2-static; the non-Apple SDL links remain unchanged. The PR declares its dependency on #10669. The author reports 42 duplicate Objective-C SDL class warnings before and 14 after (the remaining 14 are from VideoOut, outside this PR), and 51 audio tests passing on macOS x86-64 under Rosetta. Hosted conventions, eligibility, intake, labels and report checks pass; platform build jobs are skipped by path policy. I could not independently rerun the Apple build or audio tests on this Linux host.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643879478 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11049#pullrequestreview-5643879478). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T15:33:22Z. **Review:** APPROVED --- Reviewed exact head `afdd82c67b3372af27242bbfcec44374010fbf31`. On Apple, AudioIn and AudioOut now depend on the existing `libSceAgcDriver` shared target, which owns `SDL2-static`; the non-Apple SDL links remain unchanged. The PR declares its dependency on #10669. The author reports 42 duplicate Objective-C SDL class warnings before and 14 after (the remaining 14 are from VideoOut, outside this PR), and 51 audio tests passing on macOS x86-64 under Rosetta. Hosted conventions, eligibility, intake, labels and report checks pass; platform build jobs are skipped by path policy. I could not independently rerun the Apple build or audio tests on this Linux host.
THEMANnt commented 2026-10-26 19:17:18 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed afdd82c67b3372af27242bbfcec44374010fbf31. Pending review.

CMake linkage branches are verified; native macOS SDL behavior remains unverified in this review.

Validation: Executed the submitted AudioIn/AudioOut CMake on head and base across Darwin/Linux/Windows branches. Darwin uses libSceAgcDriver and drops the extra SDL2-static/exclude-libs linkage; the Linux/Windows link commands retain their old behavior.

Scope / next step: This does not prove Mach-O symbol resolution or Objective-C class identity. The author describes a combined macOS-series run; I did not independently execute or certify that integration. Native Apple evidence remains the limit on approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5657688383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11049#pullrequestreview-5657688383). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-26T19:17:18Z. **Review:** COMMENTED --- Reviewed `afdd82c67b3372af27242bbfcec44374010fbf31`. Pending review. CMake linkage branches are verified; native macOS SDL behavior remains unverified in this review. **Validation:** Executed the submitted AudioIn/AudioOut CMake on head and base across Darwin/Linux/Windows branches. Darwin uses libSceAgcDriver and drops the extra SDL2-static/exclude-libs linkage; the Linux/Windows link commands retain their old behavior. **Scope / next step:** This does not prove Mach-O symbol resolution or Objective-C class identity. The author describes a combined macOS-series run; I did not independently execute or certify that integration. Native Apple evidence remains the limit on approval.
MarcZX10 commented 2026-11-20 10:04:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T10:04:00Z.

Review: COMMENTED


Reviewed — comments

The diff directs the two audio libraries to link libSceAgcDriver on Apple and adds that dependency to the timing test; I could not verify the reported builds or runtime behavior.

What I ran

Reviewed head 978f05f4427bb05cc914c12756c62c0d2ab688d0. No build or tests were run. I read the prepared description, commits, manifest, diff, both changed CMake files, the root CMake configuration, and the AgcDriver target definition using repo_read.py.

Results

Check Result Note
Diff and changed files passed Both changed files read
Build and tests not run Author reports macOS testing
Runtime behavior not run No independent relink or launch

Findings

Blocking

None.

Non-blocking

  • The change creates a dependency from both audio libraries to libSceAgcDriver, which itself links SDL2-static (per its CMake target definition). This appears to centralize SDL on Apple as described. The reported macOS build and runtime checks were not independently reproduced.

Not verified

Linux and Windows builds, the reported macOS build and ctest -R audio run, and the game relink/runtime warning counts were not independently verified. files.json was not available through the reader; the manifest lists both changed files as included, and both were read. No other excluded changed files were listed in the manifest.

To get this to a good state

Nothing is required. Optional: retain macOS build and runtime evidence for the integration that supplies this target dependency.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5990893263 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11049#pullrequestreview-5990893263). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T10:04:00Z. **Review:** COMMENTED --- # Reviewed — comments The diff directs the two audio libraries to link `libSceAgcDriver` on Apple and adds that dependency to the timing test; I could not verify the reported builds or runtime behavior. ## What I ran Reviewed head `978f05f4427bb05cc914c12756c62c0d2ab688d0`. No build or tests were run. I read the prepared description, commits, manifest, diff, both changed CMake files, the root CMake configuration, and the AgcDriver target definition using `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | Both changed files read | | Build and tests | not run | Author reports macOS testing | | Runtime behavior | not run | No independent relink or launch | ## Findings ### Blocking None. ### Non-blocking - The change creates a dependency from both audio libraries to `libSceAgcDriver`, which itself links `SDL2-static` (per its CMake target definition). This appears to centralize SDL on Apple as described. The reported macOS build and runtime checks were not independently reproduced. ## Not verified Linux and Windows builds, the reported macOS build and `ctest -R audio` run, and the game relink/runtime warning counts were not independently verified. `files.json` was not available through the reader; the manifest lists both changed files as included, and both were read. No other excluded changed files were listed in the manifest. ## To get this to a good state Nothing is required. Optional: retain macOS build and runtime evidence for the integration that supplies this target dependency.
malekaifa commented 2026-11-23 02:41:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-23T02:41:58Z.

Review: CHANGES_REQUESTED


@imellag I confirmed the Nov. 20 blocker against current head 978f05f4427bb05cc914c12756c62c0d2ab688d0. On Apple this PR makes libSceAudioIn and libSceAudioOut share the SDL copy from libSceAgcDriver, but AudioIn still calls SDL_InitSubSystem(SDL_INIT_AUDIO) under its own g_mutex, while AudioOut calls InitializeSdlAudio_nid_no_patch() under a different static initialization mutex. That leaves concurrent AudioIn/AudioOut opens able to enter SDL audio initialization independently on the same SDL instance. Romannachwievor reproduced failures/crashes with concurrent real-CoreAudio starts and 0 failures after routing Apple AudioIn through InitializeSdlAudio_nid_no_patch(). Please fold that serialization into this PR (the proposed Apple-only AudioIn -> libSceAudioOut link has no reverse dependency) and retain the existing audio-target build/test coverage. This is also a prerequisite blocker for #24341. AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6015986846 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11049#pullrequestreview-6015986846). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-11-23T02:41:58Z. **Review:** CHANGES_REQUESTED --- @imellag I confirmed the Nov. 20 blocker against current head `978f05f4427bb05cc914c12756c62c0d2ab688d0`. On Apple this PR makes libSceAudioIn and libSceAudioOut share the SDL copy from libSceAgcDriver, but AudioIn still calls `SDL_InitSubSystem(SDL_INIT_AUDIO)` under its own `g_mutex`, while AudioOut calls `InitializeSdlAudio_nid_no_patch()` under a different static initialization mutex. That leaves concurrent AudioIn/AudioOut opens able to enter SDL audio initialization independently on the same SDL instance. Romannachwievor reproduced failures/crashes with concurrent real-CoreAudio starts and 0 failures after routing Apple AudioIn through `InitializeSdlAudio_nid_no_patch()`. Please fold that serialization into this PR (the proposed Apple-only AudioIn -> libSceAudioOut link has no reverse dependency) and retain the existing audio-target build/test coverage. This is also a prerequisite blocker for #24341. AI-assisted: yes
ligmaSec commented 2026-12-03 13:43:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:43:26Z.

Review: COMMENTED


The Linux integration build passed the three selected audio CTests covering default input, resampling, and AudioOut2 timing. The Apple-specific link path remains outside this run.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170956449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11049#pullrequestreview-6170956449). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:43:26Z. **Review:** COMMENTED --- The Linux integration build passed the three selected audio CTests covering default input, resampling, and AudioOut2 timing. The Apple-specific link path remains outside this run. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/11049:upstream-pr/11049'
git switch 'upstream-pr/11049'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/11049'
git switch 'upstream-pr/11049'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/11049'
git switch 'upstream-pr/11049'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/11049'
git switch 'main'
git merge --squash 'upstream-pr/11049'
git switch 'main'
git merge --ff-only 'upstream-pr/11049'
git switch 'main'
git merge 'upstream-pr/11049'
git push origin 'main'
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!11049
No description provided.