test(libs): give patched_libraries the MinGW runtime on its PATH #10101

Merged
JJenkx merged 1 commit from upstream-pr/10101 into main 2026-10-26 14:33:32 +00:00
JJenkx commented 2026-10-23 09:07:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-23T09:07:42Z.


What

patched_libraries loads each patched .prx with LoadLibraryExW(..., LOAD_WITH_ALTERED_SEARCH_PATH). With that flag, Windows resolves a library's own dependencies (libstdc++-6.dll, libgcc_s_seh-1.dll, libwinpthread-1.dll) from the .prx's directory and then PATH. It does not use the test executable's directory, which is where the build copies the MinGW runtime.

So the test passes only when the caller's PATH starts with the toolchain's bin. Run from any other shell, it fails, or it loads whichever libstdc++ comes first on PATH.

On MinGW the test now prepends the compiler's directory to its PATH through ENVIRONMENT_MODIFICATION, as other tests in core/libs/CMakeLists.txt do for the directories their libraries load from. Linux and macOS are unchanged.

Tested

Windows 11 Enterprise 22H2 (10.0.22621), MinGW-w64 GCC 15.2 UCRT r7, Release. ctest -R '^patched_libraries$', run once with PATH set to only the Windows system directories, PowerShell and CMake, then once with the toolchain's bin prepended:

head system-only PATH toolchain PATH
main 513ca7e558 fails: libc.prx: LoadLibraryEx failed with error 126, likewise libkernel.prx, libkernel_sys.prx and others passes
this PR eef6cb8061 (rebased on 513ca7e558) passes passes

tools/check_conventions.py passes. Not tested: Clang/MSVC builds (the change is under if(MINGW)), Linux and macOS (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 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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4980452326 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10101). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-23T09:07:42Z. --- ### What `patched_libraries` loads each patched `.prx` with `LoadLibraryExW(..., LOAD_WITH_ALTERED_SEARCH_PATH)`. With that flag, Windows resolves a library's own dependencies (`libstdc++-6.dll`, `libgcc_s_seh-1.dll`, `libwinpthread-1.dll`) from the `.prx`'s directory and then `PATH`. It does not use the test executable's directory, which is where the build copies the MinGW runtime. So the test passes only when the caller's `PATH` starts with the toolchain's `bin`. Run from any other shell, it fails, or it loads whichever `libstdc++` comes first on `PATH`. On MinGW the test now prepends the compiler's directory to its `PATH` through `ENVIRONMENT_MODIFICATION`, as other tests in `core/libs/CMakeLists.txt` do for the directories their libraries load from. Linux and macOS are unchanged. ### Tested Windows 11 Enterprise 22H2 (10.0.22621), MinGW-w64 GCC 15.2 UCRT r7, Release. `ctest -R '^patched_libraries$'`, run once with `PATH` set to only the Windows system directories, PowerShell and CMake, then once with the toolchain's `bin` prepended: | head | system-only `PATH` | toolchain `PATH` | |---|---|---| | `main` `513ca7e558` | fails: `libc.prx: LoadLibraryEx failed with error 126`, likewise `libkernel.prx`, `libkernel_sys.prx` and others | passes | | this PR `eef6cb8061` (rebased on `513ca7e558`) | passes | passes | `tools/check_conventions.py` passes. Not tested: Clang/MSVC builds (the change is under `if(MINGW)`), Linux and macOS (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 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 (Claude Code)
MarcZX10 commented 2026-10-23 10:33:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T10:33:02Z.

Review: DISMISSED


The test change matches the failure mechanism described: patched_libraries loads the .prx with LOAD_WITH_ALTERED_SEARCH_PATH, and on MinGW this update prepends the compiler's runtime directory to that test's PATH. The author's controlled Windows results distinguish the system-only path from the toolchain path. The exact-head conventions check and git diff --check pass; hosted eligibility, intake, conventions and labels pass. Build jobs are skipped by repository policy.

Please update this branch from current main and rerun patched_libraries with both controlled PATH setups on the refreshed base. The exact-head sync check reports 1 ahead/56 behind, and core/libs/CMakeLists.txt changed on both sides since the merge base (including #9037 and #9141). The pairwise merge is currently clean, but the PR's reported comparison uses main 21554447d0, not the current merged CMake context, and its checklist says it is based on current main. Please correct that line after refreshing. I could not run the MinGW/Windows regression from this Linux environment.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5627044733 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10101#pullrequestreview-5627044733). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T10:33:02Z. **Review:** DISMISSED --- The test change matches the failure mechanism described: `patched_libraries` loads the `.prx` with `LOAD_WITH_ALTERED_SEARCH_PATH`, and on MinGW this update prepends the compiler's runtime directory to that test's `PATH`. The author's controlled Windows results distinguish the system-only path from the toolchain path. The exact-head conventions check and `git diff --check` pass; hosted eligibility, intake, conventions and labels pass. Build jobs are skipped by repository policy. Please update this branch from current `main` and rerun `patched_libraries` with both controlled `PATH` setups on the refreshed base. The exact-head sync check reports 1 ahead/56 behind, and `core/libs/CMakeLists.txt` changed on both sides since the merge base (including #9037 and #9141). The pairwise merge is currently clean, but the PR's reported comparison uses main `21554447d0`, not the current merged CMake context, and its checklist says it is based on current main. Please correct that line after refreshing. I could not run the MinGW/Windows regression from this Linux environment.
THEMANnt commented 2026-10-25 07:24:56 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed eef6cb8061b3be28f942c9ff96b466aaf9f78aec against author merge base 513ca7e5585edd6e84b47e61328729588a7afe9d.

Approve. No actionable findings in the MinGW test-environment change.

The compiler directory is derived from the configured C++ compiler and prepended to PATH only for patched_libraries under MinGW. This supplies runtime dependencies to libraries loaded by the test without changing its executable arguments or non-MinGW configurations. Reviewed the complete patch and surrounding registration.

Validation: four real CMake/CTest fixture configurations used the exact head/baseline property blocks and a compiler-directory path containing spaces. Both head configurations passed their conditional PATH assertions; baseline MinGW failed the missing-prefix assertion as expected and baseline non-MinGW passed. Conventions, whitespace and registration passed. These fixtures validate CTest environment wiring, not actual patched-library DLL loading; no full pinned library/application run is claimed. Hosted native jobs were skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642063482 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10101#pullrequestreview-5642063482). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-25T07:24:56Z. **Review:** APPROVED --- Reviewed `eef6cb8061b3be28f942c9ff96b466aaf9f78aec` against author merge base `513ca7e5585edd6e84b47e61328729588a7afe9d`. Approve. No actionable findings in the MinGW test-environment change. The compiler directory is derived from the configured C++ compiler and prepended to PATH only for patched_libraries under MinGW. This supplies runtime dependencies to libraries loaded by the test without changing its executable arguments or non-MinGW configurations. Reviewed the complete patch and surrounding registration. Validation: four real CMake/CTest fixture configurations used the exact head/baseline property blocks and a compiler-directory path containing spaces. Both head configurations passed their conditional PATH assertions; baseline MinGW failed the missing-prefix assertion as expected and baseline non-MinGW passed. Conventions, whitespace and registration passed. These fixtures validate CTest environment wiring, not actual patched-library DLL loading; no full pinned library/application run is claimed. Hosted native jobs were skipped.
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!10101
No description provided.