Skip to content

php-in-php: drop always-on LibcExtern mkstemp/memchr after JitTempnamKernel module-local (#31637 shape) #31655

Description

@PurHur

Category

php-in-php · runtime-shrink (#1492, peer #31637 / #31606 / #31458)

Problem

Always-on LibcExtern still registers libc mkstemp(3) and memchr(3) even though the sole NestedJIT lookupFunction consumer (JitTempnamKernel::ensureLibc) already declares both module-locally. User-script tempnam() routes through PHP (TempnamJitHelper / StringTempnam / VmFsTempnam*) — not these always-on rows.

Symbol Sole lookupFunction consumers Already module-local
mkstemp JitTempnamKernel yes (ensureLibc)
memchr JitTempnamKernel yes (ensureLibc)
Path Today Target
User-script tempnam() PHP helpers (already) unchanged
LibcExtern always-on mkstemp memchr drop both rows
JitTempnamKernel ensureLibc already declares unchanged (cite this issue)
MCJIT host pin list McjitEmbedRuntime may keep memchr for reloc unchanged (not LibcExtern)

php-src reference

PHP implementation target

  • lib/JIT/LibcExtern.php — drop 'mkstemp' and 'memchr' rows; cite this issue
  • ext/standard/JitTempnamKernel.php — cite this issue on the existing ensureLibc decls
  • test/unit/LibcExternDeadDeclsRuntimeShrinkTest.php — flip keep→drop for mkstemp; add memchr to deletedDecls
  • test/unit/TempnamRuntimeShrinkTest.php — assert kernel still looks up mkstemp after ensure

Repro / verify

./script/phpunit.sh --filter 'LibcExternDeadDeclsRuntimeShrinkTest|TempnamRuntimeShrinkTest|VmFsTouchTempnamRuntimeShrinkTest|StrrchrRuntimeShrinkTest'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r '\''$p=tempnam(sys_get_temp_dir(),"phpc"); echo is_string($p)?1:0; @unlink($p);'\'''

Done when

  • LibcExtern has no 'mkstemp' => or 'memchr' => row
  • JitTempnamKernel::ensureLibc still declares both before lookupFunction
  • User-script tempnam() still works on VM
  • LibcExternDeadDeclsRuntimeShrinkTest + TempnamRuntimeShrinkTest green
  • php-src-strict; no php-compiler-strict shortcut

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