Skip to content

php-in-php: drop always-on LibcExtern printf after NestedJIT module-local (#31606/#31682 shape) #31706

Description

@PurHur

Category

php-in-php · runtime-shrink (#1492, peer #31606 / #31682 / #31655)

Problem

Always-on LibcExtern still registers libc printf(3) even though:

  1. User-script printf() already routes through PHP (JitPrintf / __compiler_printf / printf_Stdlib: printf() — formatted output to stdout (ext/standard/formatted_print.c parity) #3681).
  2. The only NestedJIT lookupFunction('printf') consumers are four internal emitters that can declare printf module-locally.
Symbol NestedJIT lookupFunction consumers Target
printf JitHeader, JitSetcookie, JitSessionStorageKernel (Set-Cookie), ScriptExit::echoString module-local ensureLibcPrintf
Path Today Target
User-script printf() JitPrintf / __compiler_printf unchanged
LibcExtern always-on printf drop row
NestedJIT header/cookie/echo rely on always-on ensureLibcPrintf then lookup

php-src reference

PHP implementation target

  • ext/standard/JitHeader.php, JitSetcookie.php, JitSessionStorageKernel.php — module-local ensure
  • lib/JIT/Builtin/ScriptExit.php — module-local ensure
  • lib/JIT/LibcExtern.php — drop always-on 'printf' row
  • test/unit/LibcExternDeadDeclsRuntimeShrinkTest.php (+ targeted shrink guards)

Repro / verify

./script/phpunit.sh --filter 'LibcExternDeadDeclsRuntimeShrinkTest|LibcNameCollisionRuntimeShrinkTest'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r "printf(\"%s\\n\", \"ok\");"'
./script/docker-exec.sh -- bash -lc 'php bin/jit.php -r "printf(\"%s\\n\", \"ok\");"'

Done when

  • LibcExtern has no 'printf' => row
  • NestedJIT consumers declare printf module-locally before lookup
  • User-script printf() still matches Zend via VM/JIT
  • No new lib/AOT/runtime/*.c
  • php-src-strict; no php-compiler-strict shortcut

Note

#10533 comments are locked (2500+); candidate recorded here instead of a tracker comment.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevEx

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions