feat(tools): flag Unknown exports whose NID is already a symbol in the tree #6268

Merged
DavidFB-creator merged 2 commits from upstream-pr/6268 into main 2026-10-18 21:27:05 +00:00
DavidFB-creator commented 2026-10-15 08:31:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidFB-creator on 2026-10-15T08:31:12Z.


What

Adds an unknown-nid rule to tools/check_conventions.py. An added APS5_EXPORT("<NID>", name) whose name marks the NID as unknown (the test tools/nid_names.py uses: unknown in the name) is an error when a symbol in core/libs/prx (outside tests/) already gets that NID from nid_patcher: a _nid_postfix name (definition, declaration or call), an APS5_VABI function, or an APS5_ASM_FUNCTION / APS5_SIGNAL_ASM_FUNCTION. NIDs follow ResolveOneName: _nid_postfix and a trailing _nid_disambig<N> are stripped, and _nid_no_patch, _nid_no_patch_cut and SDL_ names get none. The reverse is reported too: an added symbol whose NID is an existing Unknown export.

#5608 exported YNw9Xk5iNWo from libSceVideoOut as a throwing stub, sceVideoOutUnknown_YNw9Xk5iNWo. That is the NID of MouseIsOpen: MouseIsOpen_nid_postfix, which libSceVideoOut imports from libSceMouse for mouse capture. Depending on load order, VideoOut's call reached its own stub and presentation failed with YNw9Xk5iNWo not implemented. #5738 reverted it, and #5936 renamed the helpers to _nid_no_patch. On #5608's merge a3aeaf884, against its first parent, the rule reports:

core/libs/prx/libSceVideoOut/Unimplemented.cpp:10: error: [unknown-nid] An Unknown export has the NID of a symbol in core/libs/prx, so the NID is not unknown: name the export after that symbol, or give an AnyPS5 helper the _nid_no_patch suffix: YNw9Xk5iNWo (sceVideoOutUnknown_YNw9Xk5iNWo) is MouseIsOpen_nid_postfix at core/libs/prx/libSceMouse/Export.cpp:31

Refs #6245 and #5595. v0.1.2 (a48c00660) was tagged at 08:56:52 UTC, before #5738 merged at 08:58:38, and its source still has both the stub and MouseIsOpen_nid_postfix(). That fits #6245 (Octopath Traveler, a VideoOut presentation failure naming YNw9Xk5iNWo) and the note on #5381. The YNw9Xk5iNWo in #5595 is the same helper import, not a title import, which fits the base Onimusha eboot not importing it. This PR does not change either issue's runtime; libraries built from current main no longer have the collision.

Named aliases are not checked. libc and libSceLibcInternal, and libSceAmpr and libc, share NIDs on purpose (libc___cxa_finalize, sceAmprLocaleconv), and duplicate-export still compares names only. #5849 (ELF exports that patch to the same name in one library) is complementary: it sees neither imports nor other libraries.

Tested

Windows 11 Pro (26300), Python 3.13, Git for Windows. No CMake build: the Python tests were run directly.

  • New tools/tests/test_check_conventions_unknown_nids.py (ctest conventions_unknown_nids): 10 tests pass in about 5 s. Against tools/check_conventions.py from main, the 6 that expect the error fail.
  • The rule applied to every line of the tree: on main db81992c5, 22 Unknown exports against 3,890 symbol NIDs, no collision. On a3aeaf884, one: YNw9Xk5iNWo above.
  • The other test_check_conventions_*.py, test_nid_names.py and test_import_audit.py pass. test_check_conventions_comments.py (ctest conventions_function_bodies, #5672) took 17.7 to 18.3 s with the change and 18.3 to 19.1 s without, three runs each.
  • python3 tools/check_conventions.py --base origin/main with this title and body, and git diff --check: clean.
  • Not run: tools/check_test_registration.py (it needs a configured build), Linux, macOS.

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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4870451290 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6268). Originally posted by [DavidFB-creator](https://github.com/DavidFB-creator) on 2026-10-15T08:31:12Z. --- ### What Adds an `unknown-nid` rule to `tools/check_conventions.py`. An added `APS5_EXPORT("<NID>", name)` whose name marks the NID as unknown (the test `tools/nid_names.py` uses: `unknown` in the name) is an error when a symbol in `core/libs/prx` (outside `tests/`) already gets that NID from `nid_patcher`: a `_nid_postfix` name (definition, declaration or call), an `APS5_VABI` function, or an `APS5_ASM_FUNCTION` / `APS5_SIGNAL_ASM_FUNCTION`. NIDs follow `ResolveOneName`: `_nid_postfix` and a trailing `_nid_disambig<N>` are stripped, and `_nid_no_patch`, `_nid_no_patch_cut` and `SDL_` names get none. The reverse is reported too: an added symbol whose NID is an existing Unknown export. #5608 exported `YNw9Xk5iNWo` from libSceVideoOut as a throwing stub, `sceVideoOutUnknown_YNw9Xk5iNWo`. That is the NID of `MouseIsOpen`: `MouseIsOpen_nid_postfix`, which libSceVideoOut imports from libSceMouse for mouse capture. Depending on load order, VideoOut's call reached its own stub and presentation failed with `YNw9Xk5iNWo not implemented`. #5738 reverted it, and #5936 renamed the helpers to `_nid_no_patch`. On #5608's merge `a3aeaf884`, against its first parent, the rule reports: ``` core/libs/prx/libSceVideoOut/Unimplemented.cpp:10: error: [unknown-nid] An Unknown export has the NID of a symbol in core/libs/prx, so the NID is not unknown: name the export after that symbol, or give an AnyPS5 helper the _nid_no_patch suffix: YNw9Xk5iNWo (sceVideoOutUnknown_YNw9Xk5iNWo) is MouseIsOpen_nid_postfix at core/libs/prx/libSceMouse/Export.cpp:31 ``` Refs #6245 and #5595. `v0.1.2` (`a48c00660`) was tagged at 08:56:52 UTC, before #5738 merged at 08:58:38, and its source still has both the stub and `MouseIsOpen_nid_postfix()`. That fits #6245 (Octopath Traveler, a VideoOut presentation failure naming `YNw9Xk5iNWo`) and the note on #5381. The `YNw9Xk5iNWo` in #5595 is the same helper import, not a title import, which fits the base Onimusha eboot not importing it. This PR does not change either issue's runtime; libraries built from current `main` no longer have the collision. Named aliases are not checked. libc and libSceLibcInternal, and libSceAmpr and libc, share NIDs on purpose (`libc___cxa_finalize`, `sceAmprLocaleconv`), and `duplicate-export` still compares names only. #5849 (ELF exports that patch to the same name in one library) is complementary: it sees neither imports nor other libraries. ### Tested Windows 11 Pro (26300), Python 3.13, Git for Windows. No CMake build: the Python tests were run directly. - New `tools/tests/test_check_conventions_unknown_nids.py` (ctest `conventions_unknown_nids`): 10 tests pass in about 5 s. Against `tools/check_conventions.py` from `main`, the 6 that expect the error fail. - The rule applied to every line of the tree: on `main` `db81992c5`, 22 Unknown exports against 3,890 symbol NIDs, no collision. On `a3aeaf884`, one: `YNw9Xk5iNWo` above. - The other `test_check_conventions_*.py`, `test_nid_names.py` and `test_import_audit.py` pass. `test_check_conventions_comments.py` (ctest `conventions_function_bodies`, #5672) took 17.7 to 18.3 s with the change and 18.3 to 19.1 s without, three runs each. - `python3 tools/check_conventions.py --base origin/main` with this title and body, and `git diff --check`: clean. - Not run: `tools/check_test_registration.py` (it needs a configured build), Linux, macOS. ### 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] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-15 12:17:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:17:47Z.


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
PR 6757 CMakeLists.txt L155

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 674 CMakeLists.txt
PR 1835 CMakeLists.txt
PR 3998 CMakeLists.txt
PR 5021 CMakeLists.txt
PR 6044 CMakeLists.txt
PR 6746 CMakeLists.txt
PR 6879 CMakeLists.txt
PR 6946 CMakeLists.txt
PR 6947 CMakeLists.txt
PR 7039 CMakeLists.txt
PR 7201 CMakeLists.txt
PR 7332 CMakeLists.txt
PR 7642 CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191852637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6268#issuecomment-6191852637). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:17:47Z. --- <!-- 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 | |---|---|---|---| | [PR 6757](https://www.github.com/boykopovar/AnyPS5/pull/6757) | `CMakeLists.txt` [L155](https://github.com/boykopovar/AnyPS5/blob/967f0b95c52322f4d81682c7d929d34741d8008d/CMakeLists.txt#L155) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 674](https://www.github.com/boykopovar/AnyPS5/pull/674) | `CMakeLists.txt` | | [PR 1835](https://www.github.com/boykopovar/AnyPS5/pull/1835) | `CMakeLists.txt` | | [PR 3998](https://www.github.com/boykopovar/AnyPS5/pull/3998) | `CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `CMakeLists.txt` | | [PR 6746](https://www.github.com/boykopovar/AnyPS5/pull/6746) | `CMakeLists.txt` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `CMakeLists.txt` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `CMakeLists.txt` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `CMakeLists.txt` | | [PR 7039](https://www.github.com/boykopovar/AnyPS5/pull/7039) | `CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `CMakeLists.txt` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `CMakeLists.txt` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `CMakeLists.txt` |
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!6268
No description provided.