fix(agc): keep std template instantiations out of the libSceAgcDriver export table with MinGW GCC #15398
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15398"
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 dantdmdarealguy on 2026-11-03T05:01:22Z.
What
A Windows Debug build of
mainstops at the link of the AGC driver:Nothing that depends on the AGC driver builds after that: VideoOut, the patched
libstarget and every AGC test. In the Debugctestrun that's 1295 failed or not-run tests out of 3851.No symbol in
libSceAgcDriveris markeddllexport, so MinGW ld exports every global symbol in the link. A PE export table holds at most 65535 entries. At-O0, everystdtemplate instantiation the driver, the shader recompiler and glslang use is a global COMDAT symbol, and those make up 56226 of the 68149 exports (--output-defof the failing link). The Release module has 9609 exports, because the optimizer inlines most of those instantiations. Windows CI builds only Release, so the overflow wasn't caught there.No module imports these symbols from the driver. Each module that uses an instantiation emits its own copy, and the linker takes the definition from the module's own objects ahead of an import library. The library defines nothing in namespace
stditself.GNU ld also leaves symbols that a version script marks
localout of the automatic export (bfd_hide_sym_by_versioninpe-dll.c). For MinGW GCC,core/libs/prx/libSceAgcDriver/CMakeLists.txtnow writes a version script into the build tree and passes it to the link. The script makes symbols whose mangled names are in namespacestdlocal:_ZSt*,_ZNSt*,_ZNSa*and their const and ref-qualified forms. It matches mangled prefixes rather than anextern "C++" { std::*; }pattern, because the demangled form also matches project templates that return astdtype. In a test link that pattern removed 2AgcDriverand 32ShaderRecompilerexports.libSceAgcDriver.prxexportsmainstdsymbols removed, none added)In both builds the
AgcDriver(Debug 4085, Release 2845),ShaderRecompiler(2662, 1773),SDL_(2101) and NID (_nid_no_patch_cut,_nid_postfix) export counts are unchanged.Tested
Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0 (binutils 2.46), Ninja,
-DBUILD_TESTING=ON,main7feb37ee3e:main,cmake --buildfails with the error above, every time. With this change, the build succeeds andlibSceAgcDriver.prxexports 12257 symbols. A full Debugctest --parallel 2 --timeout 300then runs all 3851 tests. The AGC failures left in Debug all have another cause: two Debug-only assertions that also fire before this change could be built (agc_driver_native_depth_clears,agc_driver_recorded_kept_bytes), and three that fail on this RTX 5080 in Release onmainas well.libstarget succeed, with the same warning set asmain. Fullctest --parallel 2 --timeout 300gives the same failures as onmain, all unrelated to this change.patched_librariesreports405 patched libraries loaded, 0 failed.mainand on this change:ctest -R "^agc_driver_(graphics|stream_copy|indexed_copy|pixel_barycentric_emulation|wait_shutdown)$" -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The layer is the KhronosVK_LAYER_KHRONOS_validation1.4.363, loaded throughVK_ADD_LAYER_PATHfrom a non-elevated process. WithVK_LOADER_DEBUG=layer, both logs showInsert instance layer "VK_LAYER_KHRONOS_validation"and nowas not found but was requested by env var VK_INSTANCE_LAYERS. Both logs: 5/5 passed, 0VUID-messages.tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass (1877 test executables, none new).MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU".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-11-03T05:07:24Z.
Review: COMMENTED
Reviewed — no blocking findings
The CMake change is limited to GNU MinGW exports and the exact-head checks found no source blocker; Windows CI is still pending, so this is a comment rather than an approval.
What I ran
Reviewed the only changed file at head
7c76144d55ea2feb03097291f83c7713210cece9against basef6232fcfda70644495273f6b8dd88cf0603463d6; the exact-head merge preview is clean. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not configure or build AnyPS5.Results
main.Commands and unedited output
The precheck's conventions and mergeability checks passed. Its overall result was
checks failedbecausetools/pr_test_quality.pyis absent from the isolated checkout; that optional helper did not run. The PR does not change ABI declarations or C/C++ tests.Negative control
The assertion is that MinGW Debug linking on
mainexceeds the PE export ordinal limit, while this change reduces the exported symbol count. The PR author reports this base failure and successful Debug/Release builds with this change; I did not run either build or independently reproduce the export counts.Findings
Blocking
None found in the changed CMake logic.
Non-blocking
The PR reports matched
mainand change runs for focused AGC tests with validation enabled, but I did not independently inspect those logs or reproduce the results.Sources
Not verified
No local CMake configure, build, CTest, Windows execution or Vulkan validation run was performed. The PR author's Debug/Release and RTX 5080 results are reported in the description, not reproduced here. The Windows hosted job remains pending; Linux and specialized hosted jobs were skipped.
To get this to a good state
No code change is requested from this source review. I will refresh the Windows result on this head; if the head changes, I will rerun the precheck and review the changed CMake logic again.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T05:43:26Z.
Review: APPROVED
Re-checked — checks passed, approved
The exact source review remains clear at head
7c76144d55ea2feb03097291f83c7713210cece9, and the previously pending hosted Windows job has now passed.What I ran
Rechecked the PR state and hosted checks for head
7c76144d55ea2feb03097291f83c7713210cece9against basef6232fcfda70644495273f6b8dd88cf0603463d6. The earlier exact-head merge preview was clean. This follow-up ran on Debian Linux x86_64; no local build was run.Results
Unedited hosted check output
Negative control
No negative control was run in this follow-up. The earlier source review did not reproduce the author's reported export-limit failure or Debug/Release results.
Findings
Blocking
None found in the reviewed CMake change.
Non-blocking
The author's focused Vulkan and hardware results remain author-reported; this PR's hosted checks do not establish those measurements.
Sources
Not verified
No local configure, build, CTest, Windows execution, Vulkan validation or GPU run was performed. Linux and specialized hosted jobs were skipped.
To get this to a good state
No code change is requested. The reviewed head is approved; if the head changes, I will inspect the new diff and rerun relevant checks.