Skip to content

M3 emit TU: runtime spine skip-list + emit phase diagnostics (#2442) - #2506

Merged
PurHur merged 2 commits into
masterfrom
agent/issue-2442-emit-tu-runtime
May 26, 2026
Merged

M3 emit TU: runtime spine skip-list + emit phase diagnostics (#2442)#2506
PurHur merged 2 commits into
masterfrom
agent/issue-2442-emit-tu-runtime

Conversation

@PurHur

@PurHur PurHur commented May 26, 2026

Copy link
Copy Markdown
Owner

Problem

M3 emit-TU helper translation units can link but do not reliably execute natively yet: running the resulting binary still hits parse returned null and the probe falls back to emit_path=zend partial (tracked as the primary gate in #2442).

This issue documents the concrete emitter skip-list + diagnostics work needed on the emit-TU path, with clear file paths and repro commands.

Gates / repro

Minimal repro (harness-safe Docker):

./script/docker-exec.sh -- bash -lc '
  source script/php-env.sh
  script/apply-patches.sh
  BOOTSTRAP_M3_LINK_COMPILE_DRIVER=1   BOOTSTRAP_M3_COMPILE_DRIVER_REAL_LOWERING=1   BOOTSTRAP_M3_RUNTIME_COMPILE=1   ./script/bootstrap-selfhost-helloworld-probe.sh
'

Expected: emit_path=native.

Actual (today): emit_path=zend partial and/or parse returned null unless the runtime spine is bound to real-lowered symbols.

Scope (files / symbols)

  • lib/JIT.php
  • Emit TU entrypoints (smallest → largest):
    • test/bootstrap-aot/runtime_m3_emit_native_entry.php
    • test/bootstrap-aot/compile_smoke_m3_emit_native_entry.php
    • test/bootstrap-aot/helloworld_m3_emit_native_entry.php
  • Probes / drivers:
    • ./script/bootstrap-selfhost-helloworld-probe.sh
    • make bootstrap-selfhost-runtime-compile-smoke
    • bin/compile.php (M3 env dispatch)

Done when

Dependencies

Made with Cursor

- Add isM3EmitTuRuntimeSpineLoweringName so emit-TU link does not stub
  Runtime::parse/compile/compileEmitSmoke via self-host skip lists.
- Split BootstrapCompileSmokeM3Emit failures into parse vs compileEmitSmoke
  phases; refuse hollow runtimeSpine forward declarations at link time.
- Fall back to patch-php-cfg-match.py when php-cfg-match.patch is corrupt.
- Accept helloworld_compile_smoke log prefix in helloworld probe success grep.

Native emit still returns null from Runtime::parse at runtime (forward-decl
ordering vs compileM3EmitTuMainNative); probe remains zend partial until
parse is real-lowered before bridge IR is emitted.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented May 26, 2026

Copy link
Copy Markdown
Owner Author

Harness repro confirms remaining blocker after link:

BOOTSTRAP_M3_LINK_COMPILE_DRIVER=1 BOOTSTRAP_M3_COMPILE_DRIVER_REAL_LOWERING=1 \
  PHP_COMPILER_EMIT_HELPER_LINK=1 ./script/bootstrap-m3-emit-tu-execute.sh
# runtime_compile_smoke_m3_emit: parseAndCompile returned null

Parent: #2442. Closed duplicate #2508 (same repro).

@PurHur

PurHur commented May 26, 2026

Copy link
Copy Markdown
Owner Author

Partial overlap with merged #2526 (bridge ordering) and #2523 (emit-helper Runtime spine + operand-chain helpers). Remaining unique value here looks like isM3EmitTuRuntimeSpineLoweringName + BootstrapCompileSmokeM3Emit phase diagnostics — please rebase onto current master and re-run make bootstrap-selfhost-compile-smoke / helloworld probe before merge.

Replace eager PHP CFG pre-lowering in compileM3EmitTuRuntimeSpineDecls with
native LLVM stubs for Runtime parse/compileEmitSmoke/standalone/construct so
emit-helper link avoids LLVM 9 segfaults on initParsePipeline and
markObjectConstructed. Split parse+compileEmitSmoke in the emit bridge with
phase diagnostics (continues #2506).

Blocker: BootstrapCompileSmokeM3Emit::emitMainEntry still segfaults during
IR build after spine registration — emit_path=native not green yet.
Next: Batch A real lowering (#2516) for parse/standalone/init*.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented May 26, 2026

Copy link
Copy Markdown
Owner Author

Harness verification (May 26)

Progress: Identified LLVM 9 link crash root cause — eager compileM3EmitTuRuntimeSpineDecls PHP CFG pre-lower of initParsePipeline / Compiler::compile / markObjectConstructed during emit-helper link. Latest commit replaces that with native LLVM spine stubs and drops compiler-spine PHP lowering from emit TU compile path.

Still red:

./script/docker-exec.sh -- bash -lc '
  source script/php-env.sh && script/apply-patches.sh
  BOOTSTRAP_M3_LINK_COMPILE_DRIVER=1 \
  BOOTSTRAP_M3_COMPILE_DRIVER_REAL_LOWERING=1 \
  BOOTSTRAP_M3_RUNTIME_COMPILE=1 \
  ./script/bootstrap-selfhost-helloworld-probe.sh
'
# emit helper link failed (segfault) — emit_path=zend partial

Narrow repro:

PHP_COMPILER_SELFHOST_AOT=1 PHP_COMPILER_M3_COMPILE_DRIVER=1 PHP_COMPILER_EMIT_HELPER_LINK=1 \
  php bin/compile.php -o build/emit test/bootstrap-aot/runtime_m3_emit_native_entry.php
# exit 139 during JIT compile (after spine stubs register; crash in emitMainEntry IR)

Next: #2516 Batch A — real Runtime::parse / init* / standalone lowering; then re-enable bridge execute path for emit_path=native.

@PurHur
PurHur merged commit 78adc17 into master May 26, 2026
@PurHur
PurHur deleted the agent/issue-2442-emit-tu-runtime branch June 3, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:compiler Compiler / CFG / JIT enhancement New feature or request phase-0:Foundation Phase 0 – foundation & DevEx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant