fix(agc): exclude tests and tools from the shader cache guard when the source path holds regex characters #1105

Merged
orbz22 merged 1 commit from upstream-pr/1105 into main 2026-10-08 06:45:37 +00:00
orbz22 commented 2026-10-07 12:01:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-07T12:01:19Z.


What

core/libs/prx/libSceAgcDriver/CMakeLists.txt excluded tests/ and tools/ from the shader cache guard sources with REGEX "^${CMAKE_CURRENT_SOURCE_DIR}/(tests|tools)/". The source path is embedded in the regex unescaped, so a checkout under a path with regex metacharacters (here C:/Local Disk (D)/..., where (D) is a group matching D) never matches. The test sources stay in the guard list and the build stops at ShaderCacheVersion.hpp:

Shader disk cache key check failed:
  core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp brings the ShaderRecompiler namespace in whole, ...

The glob is now RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" and the filter matches only ^(tests|tools)/. add_shader_recompiler already resolves relative guard sources with BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}", so the list it receives is unchanged.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), CMake 4.4.4, Ninja 1.13.2.

  • Source under C:/Local Disk (D)/...: target ShaderCacheVersion.hpp fails on main, builds with this change; no tests/ or tools/ entry left in the guard list.
  • Source under C:/dev/AnyPS5: guard list (171 entries) and SourceVersion (0x596145c397a258c4) are identical before and after the change, and identical to the build under Local Disk (D).
  • Full build and ctest with -DBUILD_TESTING=ON: 389/389 passed.

A full build under a path with spaces still fails at FreeType's ftver.rc, because MinGW windres passes -I paths to cc1 with backslash-escaped spaces. That is outside this repository and not addressed here.

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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4772309672 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1105). Originally posted by [orbz22](https://github.com/orbz22) on 2026-10-07T12:01:19Z. --- ### What `core/libs/prx/libSceAgcDriver/CMakeLists.txt` excluded `tests/` and `tools/` from the shader cache guard sources with `REGEX "^${CMAKE_CURRENT_SOURCE_DIR}/(tests|tools)/"`. The source path is embedded in the regex unescaped, so a checkout under a path with regex metacharacters (here `C:/Local Disk (D)/...`, where `(D)` is a group matching `D`) never matches. The test sources stay in the guard list and the build stops at `ShaderCacheVersion.hpp`: ``` Shader disk cache key check failed: core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp brings the ShaderRecompiler namespace in whole, ... ``` The glob is now `RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"` and the filter matches only `^(tests|tools)/`. `add_shader_recompiler` already resolves relative guard sources with `BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"`, so the list it receives is unchanged. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), CMake 4.4.4, Ninja 1.13.2. - Source under `C:/Local Disk (D)/...`: target `ShaderCacheVersion.hpp` fails on `main`, builds with this change; no `tests/` or `tools/` entry left in the guard list. - Source under `C:/dev/AnyPS5`: guard list (171 entries) and `SourceVersion` (`0x596145c397a258c4`) are identical before and after the change, and identical to the build under `Local Disk (D)`. - Full build and `ctest` with `-DBUILD_TESTING=ON`: 389/389 passed. A full build under a path with spaces still fails at FreeType's `ftver.rc`, because MinGW `windres` passes `-I` paths to `cc1` with backslash-escaped spaces. That is outside this repository and not addressed here. ### 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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Dextroid17 commented 2026-10-08 02:00:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T02:00:07Z.

Review: COMMENTED


Reproduced the bug and verified the fix on Linux, using cmake -P so both regexes can be exercised without a full build.

The bug is real, and it is exactly what you describe. With a source directory containing a regex metacharacter, as in Local Disk (D):

OLD leaves: .../Local Disk (D)/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
            .../Local Disk (D)/core/libs/prx/libSceAgcDriver/tests/Recorder.cpp      ← not excluded
            .../Local Disk (D)/core/libs/prx/libSceAgcDriver/tools/g.cpp            ← not excluded
NEW leaves: Execution/src/Pm4.cpp                                                   ← both excluded

The (D) becomes a capture group inside the pattern, so the literal directory never matches and the guard keeps the test and tool sources. Correct root cause: a path was being used as a pattern, so any metacharacter in the checkout location silently changed the meaning.

It is also behaviour-preserving where the old form worked, which is the half I wanted to confirm before saying yes — on a path with no metacharacters, both filters leave exactly the same list (only Execution/src/Pm4.cpp). So this cannot regress a normal checkout.

Your resolution claim is correct, and I checked it rather than taking it. In core/shader/recompiler/CMakeLists.txt:

foreach(source IN LISTS shaderCache_GUARD_SOURCES)
    get_filename_component(source "${source}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

That is an exact inverse of the new RELATIVE glob, and since add_shader_recompiler is called from the agc directory, CMAKE_CURRENT_SOURCE_DIR there is the agc directory — so the round-trip is identity. Confirmed by building the guard target as well: shader_recompiler_agc_driver configures and links on Linux with no error, so the relative list is resolved rather than passed through unresolved.

One small note, not a request: the filter is now correct because the glob next to it is RELATIVE. If a later caller ever feeds absolute paths into the same list, ^(tests|tools)/ quietly stops excluding anything. They are adjacent lines, so this is more of a comment than a hazard.

This is a comment, not an approval — I have no merge rights here.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5450532770 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1105#pullrequestreview-5450532770). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-08T02:00:07Z. **Review:** COMMENTED --- Reproduced the bug and verified the fix on Linux, using `cmake -P` so both regexes can be exercised without a full build. **The bug is real, and it is exactly what you describe.** With a source directory containing a regex metacharacter, as in `Local Disk (D)`: ``` OLD leaves: .../Local Disk (D)/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp .../Local Disk (D)/core/libs/prx/libSceAgcDriver/tests/Recorder.cpp ← not excluded .../Local Disk (D)/core/libs/prx/libSceAgcDriver/tools/g.cpp ← not excluded NEW leaves: Execution/src/Pm4.cpp ← both excluded ``` The `(D)` becomes a capture group inside the pattern, so the literal directory never matches and the guard keeps the test and tool sources. Correct root cause: a *path* was being used as a *pattern*, so any metacharacter in the checkout location silently changed the meaning. **It is also behaviour-preserving where the old form worked**, which is the half I wanted to confirm before saying yes — on a path with no metacharacters, both filters leave exactly the same list (only `Execution/src/Pm4.cpp`). So this cannot regress a normal checkout. **Your resolution claim is correct, and I checked it rather than taking it.** In `core/shader/recompiler/CMakeLists.txt`: ```cmake foreach(source IN LISTS shaderCache_GUARD_SOURCES) get_filename_component(source "${source}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") ``` That is an exact inverse of the new `RELATIVE` glob, and since `add_shader_recompiler` is called from the agc directory, `CMAKE_CURRENT_SOURCE_DIR` there is the agc directory — so the round-trip is identity. Confirmed by building the guard target as well: `shader_recompiler_agc_driver` configures and links on Linux with no error, so the relative list is resolved rather than passed through unresolved. One small note, not a request: the filter is now correct *because* the glob next to it is `RELATIVE`. If a later caller ever feeds absolute paths into the same list, `^(tests|tools)/` quietly stops excluding anything. They are adjacent lines, so this is more of a comment than a hazard. This is a comment, not an approval — I have no merge rights here. Written with AI assistance.
adriadam10 commented 2026-10-08 06:45:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T06:45:34Z.


Checked: add_shader_recompiler resolves the relative guard sources against CMAKE_CURRENT_SOURCE_DIR (core/shader/recompiler/CMakeLists.txt:178), so the resulting list is unchanged. Full build and ctest on top of current main: 419/419 passed; CI green. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6054145339 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1105#issuecomment-6054145339). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T06:45:34Z. --- Checked: `add_shader_recompiler` resolves the relative guard sources against `CMAKE_CURRENT_SOURCE_DIR` (`core/shader/recompiler/CMakeLists.txt:178`), so the resulting list is unchanged. Full build and ctest on top of current main: 419/419 passed; CI green. Merging.
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!1105
No description provided.