fix(tools): count assembly exports in the duplicate-export check #8777
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8777"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-21T00:19:19Z.
What
The
duplicate-exportcheck only sawAPS5_VABI name(definitions, so exports written in assembly throughAPS5_ASM_FUNCTION("name")orAPS5_SIGNAL_ASM_FUNCTION("name")were invisible in both directions. #8747 adds throwingsetjmp_nid_postfixandlongjmp_nid_postfixstubs inlibSceLibcInternal, which shadow the assembly ones inlibc/src/JumpBuffer.cpp;guest_user_contextthen aborts withsetjmp_nid_postfix not implementedwhile the check passes. The check now counts assembly exports both as exports a change adds and as existing exports elsewhere. It reads them from the whole file, so a call next to a raw string counts and one inside a block comment does not, and takes only identifier names. A failinggit grepstops the check instead of passing it. The assembly pattern goes through the samegit grep -f -stdin pattern as #8461, so a large change stays under the Windows command-line limit; a test from @MarcZX10 covers 1,100 export names (more than 32,767 characters).Tested
Linux and Windows. Three new tests in
test_check_conventions_comments.py(a C export shadowing a libc assembly export, anAPS5_SIGNAL_ASM_FUNCTIONexport repeated in another library, an export after a raw string) fail onmainand pass here; two more keep an export in a block comment and a name that is not an identifier from changing the result. All 12 shards and the other conventions tests pass (77 tests on Linux, rebased onto47fa6eecf8). On Windows (WinLibs GCC 15.2 VM, Python 3.13)test_check_conventions_comments.pyand the conventions check pass. On #8747's head the check now reports nine duplicates instead of four: the fourfe*functions plussetjmp,longjmp,getcontext,sigsetjmpandsiglongjmp. The check passes on its own change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T00:21:46Z.
Review: APPROVED
I ran the exact PR-head
test_check_conventions_comments.pylocally on Linux with the checker and its helper modules: all 76 tests pass. This includes detection of a C export shadowing an assembly export, assembly duplicate exports, raw strings, block comments, and non-identifier names. The hosted conventions, eligibility, intake, and labels checks pass; the relinker matrix is still pending and is outside this Python-only change. #8461 is still open and edits the same duplicate-check method; please preserve the noted merge/rebase coordination if that PR lands first.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:19:16Z.
I checked the reported #8848 failure against this PR. The current
duplicates()still passes the export alternation as one argv element; #8848 measured 4,445 names and a 147,788-character pattern, which exceeds WindowsCreateProcesseven though this PR deduplicates the list. The issue author verifiedgit grep -fagainst a BOM-free UTF-8 pattern file and got the expected 7,835 matches on Windows. Could this PR include that file-backed search and a regression test for large export sets? That would address the independent Windows failure alongside the assembly-export detection, without a competing PR on the same method. I can’t currently run or stage a patch because this filesystem has 0 bytes available.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:30:00Z.
Update on #8848: PR #8461 has now merged, and current
mainsolves the 32K Windows command-line failure by passinggit grep -F -f -patterns through stdin. Its PR reports the 400-export WinError 206 regression failing on unchanged main and passing with the fix, including the Windows relinker CI. #8777 still uses the older combined regex as one argv item and predates that merge. Please rebase and preserve the streamed-pattern approach when adding the assembly-export search; otherwise this PR will reintroduce #8848. I prepared a regression locally, but a separate PR would duplicate the fix already merged by #8461.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T04:18:35Z.
Code review location:
tools/check_conventions.py; line 211This change puts the alternation of every exported name back into one
git grepargv element. That recreates the Windows failure reported in #8848: the measured expression there was 147,788 characters, beyondCreateProcess’s command-line limit. The fix for that exact issue is already onmainvia #8461, which streams patterns togit grep -F -f -. Could this keep the pattern off argv (for example write the regex to a UTF-8 temp file and use-f, while preserving the regex semantics needed for assembly exports)? Otherwise this PR appears to reintroduce the Windows failure.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T04:20:47Z.
Code review location:
tools/check_conventions.py; line 211I prepared the fix and regression on my fork at
MarcZX100:codex/pr-8777-stream-pattern(commitf61f189c99). It writes the expanded regex as UTF-8 without a BOM to a temporary file and usesgit grep -f, keeping the regex semantics while avoiding the Windows argv limit. The new test builds a 36K+ pattern and still detects the duplicate export. Validation: all 77test_check_conventions_comments.pytests pass,python tools/check_conventions.py --base upstream/mainpasses, andgit diff --checkpasses. Direct push to your branch was denied, so you can cherry-pick this commit if it fits your update.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T04:39:34Z.
Code review location:
tools/check_conventions.py; line 211This still passes the full alternation as one command-line argument. That reintroduces #8848: current main fixes the Windows 32K limit in #8461 by streaming patterns to
git grep -F -f -. Could this expanded scan use the same stdin path (while preserving the assembly-export matching) and add a large-pattern regression test? Deduplicating the names still leaves the measured pattern at 147,788 characters, so the current-Einvocation will fail on Windows before grep starts.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:16:28Z.
I have a one-commit follow-up for the Windows command-line limit in the new ERE matcher:
f61f189c994de8893ca345a593812d201a60133bonMarcZX100/AnyPS5:codex/pr-8777-stream-pattern(parent is the current PR heada18480ce). It moves the regex to a temporarygit grep -fpattern file and adds a 1,100-export regression (>32,767 characters). On Linux,python3 tools/tests/test_check_conventions_comments.pypasses 77/77,check_conventions.py --base upstream/pr-8777-reviewpasses, andgit diff --checkpasses. The overlap check reported #8892 only because it also changestools/check_conventions.py; manual diff shows #8892 editsenv_reference()/the target-ref handling, not thisduplicates()logic. I cannot push to your fork, but the branch is available if you want to cherry-pick this commit onto the PR.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T09:45:39Z.
Linux data point for
a18480ce30: WSL2 Ubuntu 24.04 (a virtualised kernel, not bare-metal Linux), Python 3.12, PR head alone (not merged ontomain),python3 -I -m unittest discover -s tools/tests -p test_check_conventions_comments.py.tools/check_conventions.pyrestored to the merge-base (the PR's tests kept): 3 failures (test_assembly_export_after_a_raw_string_is_a_duplicate, test_assembly_export_in_another_library_is_a_duplicate, test_export_shadowing_an_assembly_export_is_a_duplicate).Not tested: macOS, Windows, a merge onto current
main.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-21T13:15:36Z.
Thanks @MarcZX10. Rebased onto current
main, which already has #8461's stdin patterns, so the assembly pattern now goes throughgit grep -f -the same way and your temp file wasn't needed. I kept your 1,100-name test as cbfc92ecac with you as author.On the new head, 77 tests pass on Linux, and on Windows (WinLibs GCC 15.2, Python 3.13)
test_check_conventions_comments.pyand the conventions check pass too.The red
relinker (macos-latest, clang++, x86_64)job never got past fetching the PR:git fetchfailed withRPC failed; curl 56 Recv failure: Connection reset by peerandbad pack headerin the merge step, before anything was built. The other relinker jobs, including the arm64 macOS one, pass on the same head. Could a maintainer rerun it?Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-21T19:09:53Z.
Checked at cbfc92ecac8712c3798117ebb7d486e4ce99fad1 on Windows (Python 3.11.9). The 77 existing tests pass both on the exact head and cherry-picked onto local main; conventions and diff whitespace checks also pass.
I found one P2 gap at
tools/check_conventions.py:211: the new grep prefilter excludes valid spaced or multiline assembly macro invocations before the whole-file parser can inspect them. ReusingTestFixtureExportTests.check(), seedlibc/src/JumpBuffer.cppwithAPS5_ASM_FUNCTION ("setjmp_nid_postfix"), then add the throwing C definition fromtest_export_shadowing_an_assembly_export_is_a_duplicateinlibSceLibcInternal/Export.cpp. The checker exits 0 withAll conventions checks passed.Removing just the space before(restores the duplicate diagnostic and exit 1. SplittingAPS5_ASM_FUNCTION(and its string argument across lines also incorrectly passes, as does the spaced signal macro.asm_exports()recognizes these exports, and GCC 15.2 preprocessing with the production macro header confirms the ordinary, spaced and multiline forms expand identically.Please make candidate discovery conservative enough to retain these files and inspect their parsed exports without requiring the macro and name on the same grep line. Regression tests for an existing spaced/multiline assembly definition shadowed by a C export would cover this. Please retain
git grep -f -so the Windows command-line fix stays intact.AI-assisted: yes (Codex); tests and reproductions were executed locally.
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-21T22:54:33Z.
Thanks @THEMANnt, good catch. I rebased onto current
main, where68aeef249areplaced the grep prefilter with a scan of every committed prx source, so the assembly side now goes throughasm_exports()on the whole file and the macro and name no longer need to share a line. Thegit grep -f -path is gone with it, so the Windows command-line limit cannot come back through this check.e5dc85e483adds your case: a C export shadowing an existingAPS5_ASM_FUNCTION ("…"), a splitAPS5_ASM_FUNCTION(/ name, and a spaced splitAPS5_SIGNAL_ASM_FUNCTION. All three pass the checker at cbfc92ecac and are reported now. 79 tests pass on Linux, and on Windows the build, ctest, tools tests and conventions check show no failure thatmainlacks.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-22T08:23:29Z.
Review: APPROVED
Rechecked at
e5dc85e483on Windows with Python 3.11.9. My earlier spacing/multiline finding is resolved; no blocking findings remain.test_check_conventions_comments.pytests pass, including the new spaced/split regression and the 1,100-export case.git diff --checkpass.The whole-file assembly parsing now reaches all committed PRX sources selected by the scanner, and duplicate discovery no longer constructs an export-name grep pattern or passes it on the Windows command line. This addresses both the original filtering gap and the command-line-length concern.
Nonblocking description nit: the What/Tested text still describes the removed
git grep -f -path and the earlier 77-test result; please update it to match the current implementation.Scope: Python checker and relevant fixtures; I did not rerun native builds, CTest, Linux or macOS validation for this review.
AI-assisted: yes (Codex); the tests and reproductions above were executed locally.