mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 16:43:05 -05:00
Every library under core/libs/prx links the libc and libkernel import libraries, and every NID patch step depended on the unpatched libc.prx. GNU ld 2.46 rewrites the import library on every link with new archive timestamps (the member headers and the symbol map header), so the restat on the link edge never pruned anything: one libc or libkernel .cpp edit relinked all 124 libraries and re-patched all of them. On MinGW the shared library link now writes the import library to <implib>.new with SOURCE_DATE_EPOCH=0 (ld then writes zero member timestamps), makes the symbol map deterministic with ranlib -D and copies the result over the import library only when its bytes differ (cmake -E copy_if_different). The link edge keeps restat, so a link that keeps the exports leaves the import library untouched and prunes every dependent link. The SOURCE_DATE_EPOCH also zeroes the export directory TimeDateStamp of the DLL; the COFF header TimeDateStamp that the unwinder keys on is unchanged. The NID patch steps only use the names libc exports. nid_patcher --write-export-list writes those names, normalized and sorted, to libc.exports and leaves the file untouched when they did not change; the patch steps read it with --preserve-export-list and depend on it instead of libc.prx, on every platform. A patched library is byte-identical to one patched against libc.prx. Measured on Windows (GCC 15.2, -j 4, loaded machine) after touching libc/src/Strings.cpp: with CMAKE_LINK_DEPENDS_NO_SHARED off, 124 links and 124 patches in 74.9 s before, 1 compile, 1 link, the export list and the libc patch in 4.3 s after; with it on, 124 patches in 7.8 s before and the same four steps in 5.3 s after. Touching libkernel/Time/Time.cpp runs 123 links and 123 patches (89.1 s) before and one compile, link and patch (3.4 s) after. Removing a libc export still relinks and re-patches all 124 libraries. nid_patcher_macho covers --write-export-list (sorted normalized names, no rewrite when unchanged, rewrite when changed) and --preserve-export-list (the same exports kept as with --preserve-exports; malformed lists and two references refused). It fails on main, where the option is unknown. Sources: SOURCE_DATE_EPOCH, https://reproducible-builds.org/specs/source-date-epoch/; ranlib -D and ld --out-implib, GNU binutils documentation; ninja restat, https://ninja-build.org/manual.html#ref_rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>