Skip to content

Self-host: stub surface burn-down — inventory of SelfHostBuiltinPolicy / ExternalMethod #2484

Closed

Description

@PurHur

Milestone

M5 stub retirement with M3/M5 diagnostic value — parent #1492 / #1520 / #1768

Problem

Self-host progress (M3→M5) requires shrinking the stub surface where PHP_COMPILER_SELFHOST_AOT=1 substitutes ExternalMethod / policy stubs for real lowering. Spine/inventory counts do not show which symbols still stub at runtime.

May 2026 harness: M3 strict emit ladder is green for trivial fixtures, but M5 driver compile fails:

./script/docker-exec.sh -- bash -lc '
  source script/php-env.sh
  BOOTSTRAP_M3_HELLOWORLD_STRICT=1 make bootstrap-selfhost-helloworld
  PHP_COMPILER_M3_COMPILE_MODE=compile PHP_COMPILER_M3_SOURCE=bin/compile.php \
  PHP_COMPILER_M3_OUT=/tmp/out ./build/selfhost-helloworld-emit
'
# parseAndCompile returned null — likely stubbed Runtime init / parse spine (#2633)

A generated stub inventory helps implementers pick the next symbols to real-lower without grep archaeology.

Scope (implementation = audit script + generated docs)

Path Role
script/bootstrap-selfhost-stub-inventory.php New — scan + --check
lib/JIT/SelfHostBuiltinPolicy.php Policy categories / isRequiredForBundle
lib/JIT.php shouldUseM3EmitTuRuntimeMethodStub(), ExternalMethod, selfhost skip patterns
lib/Func/Internal.php Internal builtin dispatch
docs/bootstrap-selfhost-stubs.md Generated markdown
docs/bootstrap-selfhost-stubs.json Generated JSON (optional CI snapshot)

Repro (today: manual)

# Partial stdlib JIT audit (not AOT-specific):
php script/audit-stdlib-jit.php

# M3 emit-TU runtime method stubs (high leverage for #2633):
grep -n 'shouldUseM3EmitTuRuntimeMethodStub\|M3EmitTuRuntimeMethodStub\|compileRuntimeInit' lib/JIT.php | head -40

# Self-host env sites:
grep -rn 'PHP_COMPILER_SELFHOST_AOT' lib/JIT.php lib/Func/ lib/JIT/SelfHostBuiltinPolicy.php | wc -l

# Tie stubs to M5 failure:
./script/docker-exec.sh -- bash -lc '
  source script/php-env.sh
  BOOTSTRAP_M3_HELLOWORLD_STRICT=1 make bootstrap-selfhost-helloworld
  PHP_COMPILER_M3_SOURCE=bin/compile.php PHP_COMPILER_M3_OUT=/tmp/out \
  PHP_COMPILER_M3_COMPILE_MODE=compile ./build/selfhost-helloworld-emit
'

Done when

Non-goals

Links

Epic #1492 · #2633 · #1520 · #1768

Activity

  1. PurHur commented on May 26, 2026

    @PurHur
    OwnerAuthor

    Backlog architect (May 2026): Parked until M3 emit-TU is green (#2512, #2513, #2540). Stub burn-down is valuable but does not unblock red bootstrap gates. Revisit after #2442 closes. Epic: #1492.

  2. PurHur commented on May 27, 2026

    @PurHur
    OwnerAuthor

    Status update from a fresh self-host run (2026-05-27, master, Docker): M2/M3/M4 slice gates are green, and the next hard blocker is M5 vendor prelink AOT (--compile).

    Repro:

    ./script/docker-exec.sh -- bash -lc 'make north-star5-verify'

    First failing symptoms are vendor-prelink compile failures (object_ok is currently 0/3):

    • Unknown type declaration found: */ at vendor/ircmaxell/php-types/lib/PHPTypes/Type.php:443
    • PhpParser\Error: unexpected T_USE during ircmaxell/php-llvm bundle compile

    New focused blockers filed:

    This makes the stub-inventory idea even higher leverage: once vendor prelink starts compiling, we’ll need a fast way to see which remaining PHP_COMPILER_SELFHOST_AOT stubs are still masking real lowering gaps on the M5 cold-boot path.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions