Skip to content

php-in-php: delete JitEnv emitLibcPutenvMirror — PutenvJitHelper + kernel (#23414) - #23441

Merged
PurHur merged 1 commit into
masterfrom
agent/runtime-php-putenv-23414
Jul 26, 2026
Merged

php-in-php: delete JitEnv emitLibcPutenvMirror — PutenvJitHelper + kernel (#23414)#23441
PurHur merged 1 commit into
masterfrom
agent/runtime-php-putenv-23414

Conversation

@PurHur

@PurHur PurHur commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Delete emitLibcPutenvMirror / inline malloc+setenv LLVM from JitEnv.php (~108 LOC removed; 262→154 lines).
  • Route putenv through slim PutenvJitHelper NestedJIT leaf + phpc_putenv_kernel / JitPutenvKernel (peer getenv/rename), avoiding co-emission of GetenvJitHelper::apacheSetenv that segfaulted user-script AOT putenv on master.
  • Flip PutenvRuntimeShrinkTest to guard absence of caller-side LibcExtern; inventory/spine include new files (6574/6574).

Closes #23414

php-src reference

  • ext/standard/basic_functions.czif_putenv

PHP implementation

  • ext/standard/PutenvJitHelper.php — overlay + kernel call
  • ext/standard/JitPutenvKernel.php / phpc_putenv_kernel.php — thin setenv mirror
  • ext/standard/JitEnv.php — helper-only putenv paths

C runtime

  • No new runtime/*.c. Net shrink: caller-side LLVM deleted from JitEnv.php (−108 lines).

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_HELPER_RUNTIME_O=0
vendor/bin/phpunit test/unit/PutenvRuntimeShrinkTest.php
# OK (5 tests, 29 assertions)
tmpdir=$(mktemp -d)
cat > "$tmpdir/t.php" << "PHP"
<?php
putenv("PHPC_PE=1");
echo getenv("PHPC_PE");
PHP
PHP_COMPILER_AOT_USER_SCRIPT=1 php bin/compile.php -o "$tmpdir/pe" "$tmpdir/t.php"
"$tmpdir/pe"   # prints: 1
php script/bootstrap-inventory.php --check   # OK 6574/6574
BOOTSTRAP_ALLOW_STALE_COMPILED_DRIVER=1 make bootstrap-selfhost-vm-driver-execute-probe
# OK /compiler/build/selfhost-lib-spine-smoke
'

Made with Cursor

…pc_putenv_kernel (#23414)

Move process-environ setenv mirroring out of caller-side JitEnv LLVM into a
slim PutenvJitHelper NestedJIT leaf (peer GetenvLookupJitHelper/rename), so
user-script AOT no longer co-emits GetenvJitHelper::apacheSetenv. JitEnv drops
~108 LOC of malloc/strchr/setenv; kernel keeps the proven assignment-string
mirror for libc getenv readers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit cc986a9 into master Jul 26, 2026
1 check failed
@PurHur
PurHur deleted the agent/runtime-php-putenv-23414 branch July 26, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

php-in-php: delete JitEnv emitLibcPutenvMirror — route libc environ sync through GetenvJitHelper PHP (#1492)

1 participant