fix(savedata): build libSceSaveData and libSceSaveDataDialog from the native sources #7780
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7780"
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 savvaniss on 2026-10-19T07:11:05Z.
What
PS4 titles import save data from
libSceSaveDataandlibSceSaveDataDialog, and a converted title loads exactly the modules its DT_NEEDED names. Those two libraries were separate, older implementations.libSceSaveDataexports 9 functions (sceSaveDataInitialize3,sceSaveDataTransferringMount, the memory-2 calls, …) andlibSceSaveDataDialogexports 8. The maintained implementations arelibSceSaveData.native(30 functions) andlibSceSaveDataDialog.native(10). They havesceSaveDataDelete,sceSaveDataDirNameSearch,sceSaveDataSetParam,sceSaveDataSaveIcon,sceSaveDataDialogUpdateStatusandsceSaveDataDialogGetStatus, which a PS4 title imports from the plain modules. Such a title failed at startup withunresolved ELF importfor each of them. Details for CUSA03312: #6977 comment.libSceSaveDataandlibSceSaveDataDialogare now built from the.nativesources, the waylibSceNgs2is built fromlibSceNgs2.native(SaveDataLibrary.cmake,SaveDataDialogLibrary.cmake). Their exports become a superset of the old ones: every function the old libraries exported is in the native ones.SaveDataCore.hpp,Export.cpp, 1,487 lines) and itssavedata_core_write_replacementtest variant are removed.SaveDataWriteReplacement.cppkeeps only its native path.SaveDataFile.hppstays where it is, since the native library andsavedata_replace_file_failureinclude it.libSceSaveData: the old implementation kept save-data memory in_sd/sce_sdmemory/<user>/memory.datand mount aliases in_sd/_aliases. The native one uses_sd_mem/u<user>/slot<n>.binand plain_sd/<dir>. Memory saved through the old library is not read after this change. oneandonlydean chose the native layout without a migration (comment), unless a PS5 title is known to keep real save-data memory through the plain module. I found none. No issue, pull request or discussion names a title that callssceSaveDataSetupSaveDataMemory2,sceSaveDataSetSaveDataMemory2orsceSaveDataSyncSaveDataMemory, and that includes the pull requests behind each save-memory fix.65a6531b6only declares pending exports that throw. The gap is recorded indocs/dev/debt/libSceSaveData.md..native.Tested
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release.
Merges of
main, 24 and 25 Oct:6cd36e6517, merge commit797e2b9733. The only conflict wascore/libs/CMakeLists.txt:mainadded twolibSceNpCppWebApitests next to thesavedata_core_write_replacementlines this branch removes. The merge keeps both tests, and that test stays removed.cceb6c3c41, merge commit7394d62549.main's canonical-header refactor (f38d29fd08) edited the old sources this branch removes, and they stay removed. Its newinclude/Api.hppheaders forlibSceSaveDataandlibSceSaveDataDialogstay. They declare those modules' exports, which the native sources implement.libkernel'sEventFlag.cpp,libSceNpCommon'sRuntime.cppandGuestKernelErrors.cppinclude the oldSaveDataCore.hpp. They use nothing from it and build without it, so the include is dropped.SaveDataWriteReplacement.cpptakesmain's header and keeps only the native path.All 13 save-data tests and
guest_kernel_errorpass 3 of 3 on the second merge.libkernelandlibSceNpCommonbuild. The save-data tests are:guest_savedata_cancel,_convert,_delete,_dialog,_mount_status,_ps4and_search;savedata_memory_growth,_growth_read_failure,_journaland_metadata;savedata_native_write_replacementandsavedata_replace_file_failure.The built
libSceSaveData.prxandlibSceSaveDataDialog.prxare again the same size as their.nativecounterparts: 271,546 and 81,593 bytes.patched_librarieswas not rerun on the merge, since it loads every built.prx.Earlier runs, on
main7f596df48with the branch rebased onto6b8228b2b:patched_libraries(which loads every built.prx), 3 runs each: 15 of 15 pass onmain, and 14 of 14 with this branch. The difference is the removedsavedata_core_write_replacement. With this branch, the-R "savedata|SaveData|patched_libraries"set includesguest_savedata_cancel,_convert,_delete,_dialog,_mount_status,_search, the foursavedata_memory_*tests,savedata_native_write_replacement,savedata_replace_file_failureandpatched_libraries.libSceSaveData.prxandlibSceSaveDataDialog.prxwere the same size as their.nativecounterparts (266,554 and 81,593 bytes), and their NID exports include Delete, DirNameSearch, SetParam, SaveIcon and DialogUpdateStatus.93eeee014, whose.nativelibrary also has the PS4sceSaveDataInitialize,sceSaveDataMountandsceSaveDataUmount. With onlylibSceSaveData.prxandlibSceSaveDataDialog.prxrebuilt, startup goes from 28 unresolved imports to 20. Exactly the 8 save-data imports resolve and no new import appears. The libraries this branch builds onmainexport 5 of those 8; the other 3 are the PS4 wrappers that #6977 adds to.native.python3 tools/check_conventions.py --base origin/mainon the merge: no errors. Onedebt-lengthwarning remains, for the 6,140-character pending-declarations entry from65a6531b6, which this branch moves tolibSceSaveData.native.mdunchanged.Risk and Monopoly Plus (CUSA03312), 20 Oct: this change resolves their save-data imports. With it in the stack of #7198 (on an RX 9070 XT), Risk plays a local match against the AI and Monopoly Plus reaches its loading screen.
Checklist
Based on current
main; no other open PR implements the same functionsOne 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 fileNo notes, investigation
.mdfiles 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.
tools/pr_overlap.py --branch(24 Oct) lists the following:sceSaveDataMount2) declares the same pending exports and changes the same save-data files. oneandonlydean plans it on top of this pull request.libSceSaveData.native/Export.cpp.core/libs/CMakeLists.txt.Those could not be compared, because they conflict with
main.Fixes: none
Unblocks: CUSA03312 #7198
GPUs tested: n/a
AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by DealPotato on 2026-10-19T15:24:45Z.
Tested with inFAMOUS Second Son (CUSA00004, my own dump) on Windows 11 Pro, WinLibs GCC 15.2.0 r7, NVIDIA RTX 4070.
Setup: this PR's commit
4e8bd1609cherry-picked onto #6977's head93eeee014, together with the jump-table fix now merged as #6595. The run directory'slibscame straight from the build output.On #6977 without this PR, Second Son's save-data imports (
sceSaveDataDelete,DirNameSearch,SaveIcon,SetParam,Umount,sceSaveDataDialogUpdateStatus) only resolved after I copied the.nativemodules over the plain names. With this PR, no copy is needed:The plain and
.nativemodules now export the same functions (90 for save data, 10 for the dialog).One more import Second Son needs that neither module has yet is
sceSaveDataMount2. In this test it came from a local addition inlibSceSaveData.nativethat takes the PS4SceSaveDataMount2asMount3without the system blocks and resource fields. I can send it as a follow-up on top of this PR if that suits you.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T15:34:27Z.
@DealPotato thanks for testing with Second Son. Yes, please send
sceSaveDataMount2as its own PR withDepends on: #7780. This one stays a draft until the maintainers decide how to migrate the old save-data memory location.Imported from boykopovar/AnyPS5. Originally posted by DealPotato on 2026-10-20T08:39:30Z.
@savvaniss done: #8285 adds
sceSaveDataMount2on top of this branch, withDepends on: #7780. It takes the PS4SceSaveDataMount2(Mount3's parameters without the system blocks and the resource field) and mounts throughsceSaveDataMount3, so the result and the error codes are Mount3's;guest_savedata_ps4covers it.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-21T10:09:27Z.
Merged
mainb6fe513b9to clear the conflict; the head is nowad5516e2d.65a6531b6("declare pending PS5 exports") added 66NotImplemented_nid_no_patchdeclarations tolibSceSaveData/Export.cpp, which this PR removes. Here is how the merge keeps both sides:libSceSaveData.native/Export.cpp, which both save data libraries are built from. None of them clashed with an existing native export, and the builtlibSceSaveData.prxexports them.docs/dev/debt/libSceSaveData.native.md, with its links pointing at that file. The conventions check requires that, since the entry now links the native library.All 13
savedatatests pass on Windows with the merge (guest_savedata_*andsavedata_*), andtools/check_conventions.py --base origin/mainreports no errors. Its one warning is the length of the moved entry, as onmain.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T01:26:45Z.
Review: COMMENTED
Linux run of head
7394d6254, merged with--no-commitontomaine2d457be3(clean merge, no conflicts; no file left includingSaveDataCore.hpp).Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release,
BUILD_TESTING=ON, incremental build oflibsplus the save-data,patched_librariesandguest_kernel_errortest targets (770 steps, no new warnings in the save-data sources).Tests
ctest -R "savedata|patched_libraries|^guest_kernel_errors$": 15/15 pass. That includespatched_libraries, which the description says was not rerun on the merge: it loads the rebuilt plainlibSceSaveData.prx/libSceSaveDataDialog.prxand passes.patched_libraries,--repeat until-fail:20 -j6: 14/14 pass every round.Exports (patched
.prx,nm -D --defined-only, NIDs only)mainlibSceSaveDatalibSceSaveData.nativelibSceSaveDataDialoglibSceSaveDataDialog.nativemain's plainlibSceSaveDataandlibSceSaveDataDialogexport is still exported (0 missing), so no title that imports the plain names loses a symbol at link time. The 132 are exactly the union ofmain's two save-data export sets (75 + 66, 9 shared)..nativemodules now export identical NID sets on Linux, matching the equal sizes you saw on Windows (here 191,952 and 16,112 bytes per pair).Not covered here: the memory-layout change (
_sd/sce_sdmemory->_sd_mem) has no migration test, as the description already says.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.