fix(build): stage linked prx runtimes next to Windows test executables #8043

Closed
plokmklo wants to merge 2 commits from upstream-pr/8043 into main
plokmklo commented 2026-10-19 18:39:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by plokmklo on 2026-10-19T18:39:56Z.


What

A test whose executable imports a .prx but whose add_test registration lacks the WIN32 ENVIRONMENT_MODIFICATION PATH prepend never reaches main(): the loader resolves lib*.prx imports to the patched copy in libs/ (or fails to find one), shows 0xC0000139 on a modal dialog, and ctest reports a timeout instead of a readable failure. The prepend is manual boilerplate repeated ~570 times across ~95 CMakeLists.txt files, every new registration must remember it, and Linux/macOS authors cannot see the breakage (rpath covers them).

add_test_executable now stages every linked prx runtime artifact next to the test executable via RUNTIME_OUTPUT / $<TARGET_RUNTIME_DLLS:...> on Windows (guarded to CMake >= 3.21; older CMake keeps today's behaviour). The executable's own directory outranks PATH in the Windows DLL search order, so a missing prepend stops mattering, the modal-dialog hang disappears, and hand-running a test exe needs no environment setup. Existing ENVIRONMENT_MODIFICATION prepends stay harmless.

Tested

Ubuntu 24.04: full configure + the libkernel/avplayer/relinker test targets build and pass unchanged on Linux (the branch is a no-op there by construction). The Windows behaviour is exactly the mechanism proposed in #7637 and cannot be exercised in this sandbox; CI's Windows matrix is the verification.

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: #7637
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4925661895 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8043). Originally posted by [plokmklo](https://github.com/plokmklo) on 2026-10-19T18:39:56Z. --- ### What A test whose executable imports a `.prx` but whose `add_test` registration lacks the WIN32 `ENVIRONMENT_MODIFICATION` PATH prepend never reaches `main()`: the loader resolves `lib*.prx` imports to the patched copy in `libs/` (or fails to find one), shows `0xC0000139` on a modal dialog, and ctest reports a timeout instead of a readable failure. The prepend is manual boilerplate repeated ~570 times across ~95 CMakeLists.txt files, every new registration must remember it, and Linux/macOS authors cannot see the breakage (rpath covers them). `add_test_executable` now stages every linked prx runtime artifact next to the test executable via `RUNTIME_OUTPUT` / `$<TARGET_RUNTIME_DLLS:...>` on Windows (guarded to CMake >= 3.21; older CMake keeps today's behaviour). The executable's own directory outranks `PATH` in the Windows DLL search order, so a missing prepend stops mattering, the modal-dialog hang disappears, and hand-running a test exe needs no environment setup. Existing `ENVIRONMENT_MODIFICATION` prepends stay harmless. ### Tested Ubuntu 24.04: full configure + the libkernel/avplayer/relinker test targets build and pass unchanged on Linux (the branch is a no-op there by construction). The Windows behaviour is exactly the mechanism proposed in #7637 and cannot be exercised in this sandbox; CI's Windows matrix is the verification. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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 - [ ] Depends on: none - [x] Fixes: #7637 - [ ] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-19 21:40:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T21:40:45Z.


The overlap with #7645 appears substantive: both PRs address #7637 by staging linked .prx runtimes beside Windows test executables from add_test_executable. #7645 is still open, includes a CMake 3.21 gate with the older PATH behavior retained below that version, and has reported Windows direct-run and test-suite coverage. Could you update the PR body to acknowledge this overlap and clarify the intended coordination or any behavior this PR adds beyond #7645? The current body also leaves Depends on and Unblocks unchecked, and the latest conventions check is failing.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278009621 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8043#issuecomment-6278009621). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T21:40:45Z. --- The overlap with #7645 appears substantive: both PRs address #7637 by staging linked `.prx` runtimes beside Windows test executables from `add_test_executable`. #7645 is still open, includes a CMake 3.21 gate with the older PATH behavior retained below that version, and has reported Windows direct-run and test-suite coverage. Could you update the PR body to acknowledge this overlap and clarify the intended coordination or any behavior this PR adds beyond #7645? The current body also leaves `Depends on` and `Unblocks` unchecked, and the latest conventions check is failing.
wachi35676 commented 2026-10-19 23:17:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T23:17:57Z.


Verdict: defect (the change has no effect)

RUNTIME_OUTPUT is not a CMake target property, so set_target_properties(... RUNTIME_OUTPUT "$<TARGET_RUNTIME_DLLS:...>") only stores a user property that nothing reads. No DLL is staged next to the test executable. cmake --help-property-list (CMake 4.3.1) has no RUNTIME_OUTPUT entry. $<TARGET_RUNTIME_DLLS> only takes effect when a command uses it, for example a POST_BUILD copy or install(FILES ...).

Reproduced on Windows 11 Home 10.0.26300 with WinLibs GCC 15.2.0 r7, CMake 4.3.1 and Ninja. The test project has a SHARED library libdep.prx with RUNTIME_OUTPUT_DIRECTORY libs/, and an executable t in tests/ that links it. The executable gets the exact block from this PR:

variant contents of tests/ after build run tests/t.exe
this PR's RUNTIME_OUTPUT property only t.exe exit 127, libdep.prx: cannot open shared object file
plus add_custom_command(TARGET t POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:t> $<TARGET_FILE_DIR:t> COMMAND_EXPAND_LISTS) libdep.prx, t.exe exit 0

The PR says Windows behaviour "cannot be exercised in this sandbox" and leaves verification to CI. CI still passes because every existing test has the ENVIRONMENT_MODIFICATION PATH prepend, so CI cannot show whether this change works. A test registration without the prepend still behaves as described in #7637.

A POST_BUILD copy as in the second row does what the PR describes for this case. Executables that link no .prx would give it an empty list, which needs handling.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6279478900 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8043#issuecomment-6279478900). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-19T23:17:57Z. --- Verdict: defect (the change has no effect) `RUNTIME_OUTPUT` is not a CMake target property, so `set_target_properties(... RUNTIME_OUTPUT "$<TARGET_RUNTIME_DLLS:...>")` only stores a user property that nothing reads. No DLL is staged next to the test executable. `cmake --help-property-list` (CMake 4.3.1) has no `RUNTIME_OUTPUT` entry. `$<TARGET_RUNTIME_DLLS>` only takes effect when a command uses it, for example a `POST_BUILD` copy or `install(FILES ...)`. Reproduced on Windows 11 Home 10.0.26300 with WinLibs GCC 15.2.0 r7, CMake 4.3.1 and Ninja. The test project has a `SHARED` library `libdep.prx` with `RUNTIME_OUTPUT_DIRECTORY libs/`, and an executable `t` in `tests/` that links it. The executable gets the exact block from this PR: | variant | contents of `tests/` after build | run `tests/t.exe` | |---|---|---| | this PR's `RUNTIME_OUTPUT` property only | `t.exe` | exit 127, `libdep.prx: cannot open shared object file` | | plus `add_custom_command(TARGET t POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:t> $<TARGET_FILE_DIR:t> COMMAND_EXPAND_LISTS)` | `libdep.prx`, `t.exe` | exit 0 | The PR says Windows behaviour "cannot be exercised in this sandbox" and leaves verification to CI. CI still passes because every existing test has the `ENVIRONMENT_MODIFICATION` PATH prepend, so CI cannot show whether this change works. A test registration without the prepend still behaves as described in #7637. A `POST_BUILD` copy as in the second row does what the PR describes for this case. Executables that link no `.prx` would give it an empty list, which needs handling. AI-assisted: yes (Claude Code); results above were run on this machine.
oneandonlydean commented 2026-10-20 04:39:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T04:39:10Z.


@plokmklo thanks for picking up #7637. Unfortunately the new line doesn't stage anything: RUNTIME_OUTPUT isn't a CMake property (cmake --help-property RUNTIME_OUTPUT says so; the real ones are RUNTIME_OUTPUT_DIRECTORY and RUNTIME_OUTPUT_NAME). set_target_properties stores an unknown name as a user property without complaint, so the $<TARGET_RUNTIME_DLLS:...> value is never used.

I checked it with a small project cross-built for Windows with llvm-mingw (a SHARED dependency with a .prx suffix, plus a test executable in the same shape as add_test_executable). With this PR's line, the test directory holds only the .exe. With the copy that CMake's TARGET_RUNTIME_DLLS documentation describes, the .prx lands next to it:

add_custom_command(TARGET ${target} POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E copy_if_different
          $<TARGET_RUNTIME_DLLS:${target}> $<TARGET_FILE_DIR:${target}>
  COMMAND_EXPAND_LISTS)

Two things to watch:

  • A test that links no SHARED target expands that to copy_if_different <dir>, which fails. Use -E copy -t <dir> ... (CMake 3.26+), or wrap the command in $<$<BOOL:$<TARGET_RUNTIME_DLLS:${target}>>:...>.
  • Please check that the staged file is the unpatched build output that the PATH prepend points at (the TARGET_FILE_DIR of libkernel and the others), not the patched copy in libs/ that #7637 says causes 0xC0000139.

A Windows test that passes without the PATH prepend would show the fix works.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6283514598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8043#issuecomment-6283514598). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T04:39:10Z. --- @plokmklo thanks for picking up #7637. Unfortunately the new line doesn't stage anything: `RUNTIME_OUTPUT` isn't a CMake property (`cmake --help-property RUNTIME_OUTPUT` says so; the real ones are `RUNTIME_OUTPUT_DIRECTORY` and `RUNTIME_OUTPUT_NAME`). `set_target_properties` stores an unknown name as a user property without complaint, so the `$<TARGET_RUNTIME_DLLS:...>` value is never used. I checked it with a small project cross-built for Windows with llvm-mingw (a SHARED dependency with a `.prx` suffix, plus a test executable in the same shape as `add_test_executable`). With this PR's line, the test directory holds only the `.exe`. With the copy that CMake's `TARGET_RUNTIME_DLLS` documentation describes, the `.prx` lands next to it: ```cmake add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:${target}> $<TARGET_FILE_DIR:${target}> COMMAND_EXPAND_LISTS) ``` Two things to watch: - A test that links no SHARED target expands that to `copy_if_different <dir>`, which fails. Use `-E copy -t <dir> ...` (CMake 3.26+), or wrap the command in `$<$<BOOL:$<TARGET_RUNTIME_DLLS:${target}>>:...>`. - Please check that the staged file is the unpatched build output that the PATH prepend points at (the `TARGET_FILE_DIR` of libkernel and the others), not the patched copy in `libs/` that #7637 says causes 0xC0000139. A Windows test that passes without the PATH prepend would show the fix works.
THEMANnt commented 2026-10-25 07:41:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T07:41:02Z.

Review: CHANGES_REQUESTED


Reviewed 8187dbafdaf967188067be8bd0dfe01a82894957 against author merge base e90a1d180268a1135ae70748c661a2830ce3f8ec.

Changes requested: the added target property does not stage any runtime dependencies.

CMakeLists.txt:19 — consume TARGET_RUNTIME_DLLS in a real staging command. RUNTIME_OUTPUT is not a CMake runtime-copy property. Setting this custom property to a generator expression does not add a build rule, change the executable directory or copy a DLL. There is no project consumer for this property. Windows tests therefore still lack their linked .prx dependencies despite this patch's stated purpose. Add an appropriate post-build copy/staging operation with correct list/empty-list handling and test both linked and standalone executables.

Validation: CMake 4.3.1 identifies RUNTIME_OUTPUT as an unknown property. Disposable Windows projects used each revision's exact add_test_executable helper and WindowsTestExit wrapper, with a linked .prx emitted to a different directory (paths contain spaces). Both builds succeeded but neither staged the dependency; linked executables exited 0xC0000135. Manually copying only the .prx made both executables exit0. This demonstrates a no-op proposed fix, not a newly introduced missing-DLL regression. Conventions/whitespace passed; this older registration CLI does not support --scripts. No production source was amended; the manual copy is a reviewer fixture control.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642101298 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8043#pullrequestreview-5642101298). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-25T07:41:02Z. **Review:** CHANGES_REQUESTED --- Reviewed `8187dbafdaf967188067be8bd0dfe01a82894957` against author merge base `e90a1d180268a1135ae70748c661a2830ce3f8ec`. Changes requested: the added target property does not stage any runtime dependencies. **CMakeLists.txt:19 — consume TARGET_RUNTIME_DLLS in a real staging command.** RUNTIME_OUTPUT is not a CMake runtime-copy property. Setting this custom property to a generator expression does not add a build rule, change the executable directory or copy a DLL. There is no project consumer for this property. Windows tests therefore still lack their linked .prx dependencies despite this patch's stated purpose. Add an appropriate post-build copy/staging operation with correct list/empty-list handling and test both linked and standalone executables. Validation: CMake 4.3.1 identifies RUNTIME_OUTPUT as an unknown property. Disposable Windows projects used each revision's exact add_test_executable helper and WindowsTestExit wrapper, with a linked .prx emitted to a different directory (paths contain spaces). Both builds succeeded but neither staged the dependency; linked executables exited 0xC0000135. Manually copying only the .prx made both executables exit0. This demonstrates a no-op proposed fix, not a newly introduced missing-DLL regression. Conventions/whitespace passed; this older registration CLI does not support --scripts. No production source was amended; the manual copy is a reviewer fixture control.
THEMANnt commented 2026-10-27 09:33:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-27T09:33:56Z.

Review: COMMENTED


Reviewed 238f7d8e7d — comment; the earlier no-op finding is fixed in the tested fixture.

With the exact updated helper and WindowsTestExit wrapper, CMake 4.3.3 / GCC 15.3 / Ninja built a linked executable and a standalone executable in a path containing spaces. The linked .prx was copied from a separate output directory and both executables exited 0; the old reviewed head did not stage it. The empty dependency list also built successfully.

The hosted Windows job merged this head but skipped the product build and CTest steps, so it does not establish full-project runtime coverage. Please update the description: it still says RUNTIME_OUTPUT and CMake >= 3.21, whereas the patch uses a POST_BUILD copy guarded at 3.26. The Depends on and Unblocks checklist items also remain unchecked.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5664930493 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8043#pullrequestreview-5664930493). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-27T09:33:56Z. **Review:** COMMENTED --- Reviewed 238f7d8e7dc223c8b6ee4bcf4ec4d75670fd1198 — comment; the earlier no-op finding is fixed in the tested fixture. With the exact updated helper and WindowsTestExit wrapper, CMake 4.3.3 / GCC 15.3 / Ninja built a linked executable and a standalone executable in a path containing spaces. The linked .prx was copied from a separate output directory and both executables exited 0; the old reviewed head did not stage it. The empty dependency list also built successfully. The hosted Windows job merged this head but skipped the product build and CTest steps, so it does not establish full-project runtime coverage. Please update the description: it still says RUNTIME_OUTPUT and CMake >= 3.21, whereas the patch uses a POST_BUILD copy guarded at 3.26. The Depends on and Unblocks checklist items also remain unchecked.
MarcZX10 commented 2026-11-21 07:09:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:09:14Z.

Review: APPROVED


Reviewed — looks good

The reviewed change adds a Windows post-build copy of linked runtime DLLs for test executables; the source change is limited to CMakeLists.txt at head 238f7d8e7dc223c8b6ee4bcf4ec4d75670fd1198.

What I ran

Read the prepared PR description, commits, manifest, diff, and the changed top-level CMakeLists.txt; searched for add_test_executable and the runtime DLL staging code with repo_read.py. No build or tests were run.

Results

Check Result Note
Source review passed Changed function inspected
Build and tests not run Windows behavior unverified

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • Windows build and runtime behavior, including the CMake version boundary.
  • The author-reported Ubuntu build and test results.
  • No files were excluded according to the manifest; files.json was unavailable, so exclusions by rule were not independently checked.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003723402 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8043#pullrequestreview-6003723402). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:09:14Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change adds a Windows post-build copy of linked runtime DLLs for test executables; the source change is limited to `CMakeLists.txt` at head `238f7d8e7dc223c8b6ee4bcf4ec4d75670fd1198`. ## What I ran Read the prepared PR description, commits, manifest, diff, and the changed top-level `CMakeLists.txt`; searched for `add_test_executable` and the runtime DLL staging code with `repo_read.py`. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed function inspected | | Build and tests | not run | Windows behavior unverified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified - Windows build and runtime behavior, including the CMake version boundary. - The author-reported Ubuntu build and test results. - No files were excluded according to the manifest; `files.json` was unavailable, so exclusions by rule were not independently checked. ## To get this to a good state Nothing is required.

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!8043
No description provided.