Skip to content

feat(libkernel): implement system - #1859

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
overlordxrz-source:feat/libkernel-system
Oct 9, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
overlordxrz-source:feat/libkernel-system

Conversation

@overlordxrz-source

@overlordxrz-source overlordxrz-source commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

libkernel does not export system (Jc6E7N+dHz0). Yamagi Quake II (PPSA99007) stops on it at load on main, and ccleste (PPSA59322) imports it too.

In both titles the only caller is the bundled Mesa. A small function runs system("clrxdisasm --version > /dev/null 2>&1") and returns whether the result is 0, which tells Mesa whether the CLRX disassembler is installed. It sits on the shader-disassembly dump path, at 0x4608d0 in the PPSA99007 executable and 0x826270 in PPSA59322 (the single call [system] site in each).

system now follows FreeBSD 11's lib/libc/stdlib/system.c (source) for a process with no /bin/sh:

  • A null command returns 1. That version returns 1 without checking for the shell (if (!command) return(1);).
  • Any other command runs nothing and returns 0x7f00. In FreeBSD, the child that cannot execl(_PATH_BSHELL, ...) calls _exit(127), and system returns its wait status. So WIFEXITED is true and WEXITSTATUS is 127, and Mesa's probe sees that CLRX is not available.
  • The guest errno is not touched.

No host command is ever run. A new line in docs/dev/TechnicalDebt.md says what is assumed: that the console's application sandbox has no shell, and that vfork succeeds there (FreeBSD returns -1 when it fails).

Log

I don't have a console, and I couldn't run the titles here: the host is aarch64 and the project needs x86-64. The stop is from @SleglJan's run of the homebrew catalog on main 4b6ab6b in #1578 (comment). Each title was relinked with --registry and run for 8 s on Linux. In the table of first stops, system is the stop for PPSA99007 Yamagi Quake II, with no open PR. That run reports the stop as app.elf: symbol lookup error: app.elf: undefined symbol: Jc6E7N+dHz0. Closed #3 also reported a Quake II build stopping at Jc6E7N+dHz0 (system) before guest entry.

The call sites come from the unwrapped eboot.bin of each release: the relocation for Jc6E7N+dHz0, then the only call qword ptr [rip+…] through that slot.

With this PR applied, @CouchRiv ran PPSA99007 on Linux (NVIDIA, main f145139 plus this PR, 90 s timeout) (comment). On main it stops at load with undefined symbol: Jc6E7N+dHz0, exit 127. With the PR, system resolves and the next stop is mkstemp (uEtgPWgPxOk, claimed by #1613):

/work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: uEtgPWgPxOk

The LD_BIND_NOW trace goes from 21 to 20 unresolved imports, with nothing new.

Tested

aarch64 Debian 13 host. The full project cannot be built here because it needs x86-64.

  • New core/libs/tests/GuestSystemCommand.cpp (guest_system_command) checks:
    • a null command returns 1
    • Mesa's probe string, exit 0 and an empty command each return a status with WIFEXITED true and exit status 127
    • errno is unchanged
  • It passes natively on aarch64 (Zig 0.17 clang, glibc 2.36), and on x86_64-linux-musl under qemu-user. Both builds link the export's body with a guest errno stand-in.
  • Negative check: without the change the test does not link. A mutant that returns 0 for a command aborts, and so does one that returns 0 for a null command.
  • Process.cpp and the test compile for x86_64-linux-gnu and x86_64-windows-gnu with -Wall -Wextra. The only warnings are the existing -Wreturn-type-c-linkage ones from General.hpp and Shutdown.hpp.
  • python3 tools/check_conventions.py --base origin/main passes. tools/progress.py: libkernel goes from 426 to 427 implemented.
  • Title run by @CouchRiv: PPSA99007 on Linux/NVIDIA gets past system and stops next at mkstemp (feat(posix): implement mkstemp and isatty #1613). See Log.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One 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 in TechnicalDebt
  • No notes, investigation .md files 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
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Progress report (ae91d97 → 8f09ec3)

➖ System libraries: 84.76% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel system_nid_postfix

@CouchRiv

CouchRiv commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Ran Yamagi Quake II 0.2.0-alpha.1 (PPSA99007, homebrew catalog release) on Linux with this PR merged onto main f145139, in a sandbox, NVIDIA, 90 s timeout.

On main it stops at load, exit 127:

/work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: Jc6E7N+dHz0

With this PR system resolves and the next stop is mkstemp (claimed by #1613), exit 127:

/work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: uEtgPWgPxOk

The LD_BIND_NOW load trace goes from 21 to 20 unresolved imports, with nothing new.

@overlordxrz-source

Copy link
Copy Markdown
Contributor Author

@CouchRiv thanks, that's the run this PR was missing. I've added it to Log and Tested. The next stop, mkstemp, belongs to #1613, so I'm leaving it out of this one.

@popcoder565

Copy link
Copy Markdown
Contributor

First Windows run, since the description says it wasn't tested on Windows.

Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto main b7218b3 together with nine other small libc/libkernel PRs: #1975, #1976, #1977, #1685, #1676, #1675, #1641, #1656, #1807.

  • guest_system_command passes.
  • Full ctest: 510/510 (one GPU test skipped for a device limit).

🤖 Addressed by Claude Code

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the system semantics against FreeBSD 11 lib/libc/stdlib/system.c (null → 1, otherwise the wait status of a child that couldn't exec the shell, 127 << 8), the guest errno being left alone, the test registration in ctest and the TechnicalDebt entry. guest_system_command passes locally on Linux and fails to link without the change; Linux and Windows CI are green. Also confirmed by @CouchRiv (PPSA99007 on Linux/NVIDIA gets past system) and @popcoder565 (Windows, MinGW); merging.

@adriadam10
adriadam10 merged commit db06355 into boykopovar:main Oct 9, 2026
7 checks passed
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