Skip to content

Self-host M3/M5: native emit bin/compile.php via inventory compile driver (not emit-helper TU only) #2843

Description

@PurHur

Milestone

M3 (emit) / M5 (full Compiler CFG) — parent #1492

Problem

M3 strict probes pass via dedicated emit-helper TUs (helloworld_m3_emit_native_entry.php, compile_smoke_m3_emit_native_entry.php). PHP_COMPILER_M3_SOURCE=bin/compile.php via bootstrap-selfhost-helloworld-compile-bin.sh is green on harness 2026-05-27, but production bootstrap still cannot treat bin/compile.php parsed as the inventory compile driver (full Runtime::parseAndCompile on the driver file itself) as the default emit path for arbitrary spine sources.

Gap: closing #2827 proved helper-TU emit; remaining work is honest inventory-scale CFG through the same entrypoints scripts use for real compiles (no parallel emit TU), matching docs/bootstrap-selfhost.md “inventory-scale bin/compile.php emit-TU” notes.

Scope

Path Work
lib/Runtime.php __construct / loadJit on emit-TU when source is bin/compile.php or full spine main.php
lib/JIT.php registerM3EmitTuSidecarFromPath, isM3CompileDriverRealLoweringName allowlist
lib/Web/LiteralIncludeDiscovery.php, lib/Web/SourceBundler.php Hot paths when compiling driver + spine
test/selfhost/compiler_helloworld_smoke/compile_driver.php Dispatch inventory PHP_COMPILER_M3_SOURCE without helper TU
script/bootstrap-selfhost-helloworld-probe.sh Optional strict mode: emit_path=native without helloworld_m3_emit_native_entry.php

Repro

# Green (helper / sidecar path):
./script/docker-exec.sh -- bash -lc 'make bootstrap-selfhost-helloworld'
./script/docker-exec.sh -- bash -lc '
  export PHP_COMPILER_M3_SOURCE=bin/compile.php
  ./script/bootstrap-selfhost-helloworld-compile-bin.sh
'

# Target (implementer defines exact env — no helper TU):
./script/docker-exec.sh -- bash -lc '
  source script/php-env.sh
  export BOOTSTRAP_M3_LINK_COMPILE_DRIVER=1
  export BOOTSTRAP_M3_COMPILE_DRIVER_REAL_LOWERING=1
  export BOOTSTRAP_M3_RUNTIME_COMPILE=1
  export BOOTSTRAP_M3_HELLOWORLD_STRICT=1
  export PHP_COMPILER_M3_SOURCE=bin/compile.php
  export PHP_COMPILER_M3_COMPILE_MODE=compile
  # run compile_driver.php from selfhost spine binary — emit_path=native, no *_m3_emit_native_entry.php
'

Done when

  • Strict HelloWorld / compile-smoke probes can pass with BOOTSTRAP_M3_USE_INVENTORY_EMIT_DRIVER=1 (name TBD) — no *_m3_emit_native_entry.php in the link line
  • bin/compile.php native compile of test/selfhost/compiler_lib_spine_smoke/main.php via compiled driver logs emit_path=native
  • docs/bootstrap-selfhost.md M3 HelloWorld row no longer describes emit-helper as the only native path

Labels

self-host, bootstrap, IMPORTANT

Links

#1492 · #2827 ✅ (helper TU) · #1768 (allowlist batches) · #1402

Activity

  1. added a commit that references this issue on May 27, 2026
  2. PurHur commented on May 27, 2026

    @PurHur
    OwnerAuthor

    Merged #2850 — inventory emit link path:

    • BOOTSTRAP_M3_USE_INVENTORY_EMIT_DRIVER=1 links compile_driver.php only (no *_m3_emit_native_entry.php)
    • make bootstrap-selfhost-helloworld default (emit-helper TU) unchanged and green

    Remaining for full close: inventory binary segfaults at HelloWorld execute (exit 139, LLVM 9 global init — same class as #1514). Strict emit_path=native run still requires emit-helper TU until runtime init for full compile_driver bundle is fixed.

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

    MOST IMPORTANTThis are the most important targetsphase-0:FoundationPhase 0 – foundation & DevEx

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions