Skip to content

feat(libkernel): export environ as an empty environment - #2090

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
LeandroLP23:feat/libkernel-environ
Oct 10, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
LeandroLP23:feat/libkernel-environ

Conversation

@LeandroLP23

Copy link
Copy Markdown
Contributor

What

PICO-8 for PS5 (PPSA99808 v0.1.2, RafaelNGP/pico8-ps5, GPL-3.0) stops at start-up on environ once __inet_aton (#1848) resolves:

FAIL: unresolved ELF import +2thxYZ4syk from libkernel.prx

+2thxYZ4syk is environ. FreeBSD's libc getenv reads it and setenv/putenv replace it, so the export is a writable char**.

It points to an empty, null-terminated array. A PS5 app starts with no environment variables: the payload SDK's elfldr (elfldr_set_environ in ps5-payload-dev/websrv) writes environ only when it has variables to pass, and shadPS4 exports the same NID as a pointer to an empty array (src/core/libraries/kernel/kernel.cpp).

Tested

Windows 11, MinGW-w64 GCC 15.2.0, Release, main f145139:

Linux and Windows: fork CI https://github.com/LeandroLP23/AnyPS5/actions/runs/37899939325, all jobs pass.

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 (Claude Code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
@LeandroLP23
LeandroLP23 force-pushed the feat/libkernel-environ branch from a6a083f to a3f0120 Compare October 9, 2026 21:36
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 10, 2026
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 10, 2026
@Amirtheshwaran

Copy link
Copy Markdown
Contributor

Tested on Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7, same as CI), Release:

  • Merges cleanly onto current main.
  • guest_system_configuration builds and passes.
  • Patched libkernel.prx exports +2thxYZ4syk.

One question: libc's Environment.cpp seeds the guest environment from the host, so getenv("PATH") returns a value while environ stays empty, and setenv changes never show up in it. Is that intended for now? If so, it might be worth a line in TechnicalDebt.md under "Unknown function info", like __progname has.

@oneandonlydean
oneandonlydean merged commit ad0b5ba into boykopovar:main Oct 10, 2026
8 checks passed
@LeandroLP23

Copy link
Copy Markdown
Contributor Author

Thanks for testing it. Yes, that's how it is for now: environ is a fixed empty environment so titles that import it can load. It isn't linked to libc's environment, so it doesn't show the variables getenv sees, and setenv/putenv changes don't appear in it. You're right that it belongs in TechnicalDebt next to __progname; I missed that in this PR. I'll add the line in a follow-up as soon as I can open PRs again (the intake check closes new ones from my account for now); anyone who can open one is welcome to take it first.

SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…viron

feat(libkernel): export environ as an empty environment
@LeandroLP23
LeandroLP23 deleted the feat/libkernel-environ branch October 10, 2026 09:18
@Amirtheshwaran Amirtheshwaran mentioned this pull request Oct 10, 2026
6 tasks done
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.

3 participants