Skip to content

fix(libkernel): export sysarch so modules that import it load - #6028

Merged
1 commit merged into
boykopovar:mainfrom
milescoviello:fix/kernel-sysarch-export
Oct 17, 2026
Merged

1 commit merged into
boykopovar:mainfrom
milescoviello:fix/kernel-sysarch-export

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What

The Wine port (PPSA99995, prospero-win) does not start on main:

./app.elf: symbol lookup error: .../app0/win/wine/lib/wine/x86_64-unix/ntdll.prx.guest.prx: undefined symbol: b7uXQmnfB2s

Update (10-15): since #5559 (merged 11:38), Linux and macOS defer a runtime-only module such as ntdll until a module that needs it is used. On main 940eba9 the title starts on Linux without this PR: its launcher, with an empty game library, does not load ntdll in a 40 s run (LD_DEBUG=files), so the error above no longer appears there. #5559 keeps eager loading on Windows, so there the load should still stop at this import (not checked here). On Linux, the import would only be resolved once ntdll is loaded, which my runs don't reach.

b7uXQmnfB2s is sysarch (tools/nid_names.py --nid b7uXQmnfB2s), the FreeBSD call that gets and sets the FS and GS bases. Its ntdll module imports it, and libkernel does not export it, so loading stops before the title runs.

libkernel now exports sysarch as a stub that reports that it is not implemented, next to the other unimplemented exports in Unimplemented.cpp. With it the title loads and runs its launcher, and it does not call sysarch in a 125 s run. An implementation would have to set the GS base through arch_prctl on Linux and could not on Windows or macOS, where the host owns that register, so that waits for a title that calls it.

guest_sysarch checks that the call reports sysarch not implemented. Without the export it does not link.

Tested

Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on main 9f03c4f, then rebased onto main 358e218:

  • All 376 guest_* tests pass, guest_sysarch included.
  • PPSA99995 (catalog release), relinked with --to-intel and run on Linux for 40 s; the builds differ only in libkernel.prx:
    • main: exits with 127 at 0 s on the error above.
    • This PR: runs the 40 s. Its own session log (/data/prospero-win/logs/session-0.log) records the keyboard and mouse modules opening, the data mount, an empty game library and the launcher's state (launcher video=state pad=ok hid=ok frame=1 apps=0).
  • tools/check_conventions.py --base upstream/main passes, and tools/pr_overlap.py --branch finds no overlap.

@screamm checked it on Windows (RTX 4070, WinLibs GCC 15.2.0), alone and stacked with #6102 and #6135 on main 5d9dcc4. Windows still binds ntdll's imports at load. With #6102 and #6135 but without this PR, Prospero Win (PPSA99995) exits within 1 to 3 s on FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx, 2 of 2. With all three, 2 of 2 runs reach the 125 s limit at its launcher's library screen, with no stop line. guest_sysarch passes 3 of 3 and fails both negative controls. Of 1,093 relinked import registries from 51 titles, only PPSA99995 imports sysarch.

Not checked on a console.

Follow-up (10-17): #7095 builds on this PR and implements the GS base operations (AMD64_SET_GSBASE, AMD64_GET_GSBASE, AMD64_GET_FSBASE), because Forever Launcher's Wine (PPSA99030) now calls sysarch(AMD64_SET_GSBASE, ...) for its TEB. This PR stays the declaration that lets the modules load.

Checklist

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Progress report (90fcd20 → 162f4af)

📉 System libraries: 89.62% (-0.03%, +1 declared functions)

🆕 1 declared as stubs
Library Name
libkernel sysarch

@milescoviello
milescoviello force-pushed the fix/kernel-sysarch-export branch from fe884e6 to d178d0a Compare October 15, 2026 02:57
This was referenced Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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 6915 core/libs/prx/libkernel/Unimplemented.cpp L12

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 4972 core/libs/prx/libkernel/CMakeLists.txt
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6222 core/libs/prx/libkernel/CMakeLists.txt
PR 6287 core/libs/prx/libkernel/CMakeLists.txt
PR 6414 core/libs/prx/libkernel/Unimplemented.cpp
PR 6908 core/libs/prx/libkernel/CMakeLists.txt
PR 6942 core/libs/prx/libkernel/CMakeLists.txt
PR 7129 core/libs/prx/libkernel/CMakeLists.txt
PR 7201 core/libs/prx/libkernel/CMakeLists.txt

@screamm

screamm commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Cross-validation on Windows of head fb0f83ddf, alone and stacked with #6102 (f1735f59f) and #6135 (10bc2f05a), on main 5d9dcc42d. My earlier run of this PR was at 183782ddc (posted in #6135); fb0f83ddf is the same commit rebased (git range-diff shows patch and message unchanged).

Windows 11 Pro 26220, Ryzen 7 5700X, NVIDIA RTX 4070 (596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release.

Prospero Win (PPSA99995), --trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix, display on, 125 s limit. This answers the "not checked on Windows" point: Windows still binds ntdll's imports at load.

Suggestion: "Unblocks: none" could become "PPSA99995 on Windows, with #6102 and #6135", since that is where the stop line moves.

Not checked: Linux, a console, any program run inside Prospero Win.

Written with Claude Code assistance (validation by a subagent, reviewed in this session).

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @screamm, that answers the Windows question properly. Your results are in the description, and "Unblocks" now names Prospero Win on Windows with #6102 and #6135.

AI-assisted: yes

The Wine port (PPSA99995) ships an ntdll module that imports sysarch
(b7uXQmnfB2s). libkernel did not export it, so loading stopped with
"undefined symbol: b7uXQmnfB2s" before the title ran.

Export sysarch as a stub that reports that it is not implemented: the
title loads and runs its launcher without calling it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milescoviello
milescoviello force-pushed the fix/kernel-sysarch-export branch from fb0f83d to 162f4af Compare October 17, 2026 20:54
@oneandonlydean oneandonlydean closed this pull request by merging all changes into boykopovar:main in fbb76ae Oct 17, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@adriadam10 FYI: this landed through #7095, which carried this PR's commit fb0f83d, so GitHub now shows it as merged. I've added myself as co-assignee for the follow-up; you're still on it as before.

@oneandonlydean oneandonlydean self-assigned this Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants