Skip to content

Self-host M5: bin/compile.php AOT sidecar segfault — missing .m3_bin_compile_aot_blob at emit-helper link #2697

@PurHur

Description

@PurHur

Milestone

M5 — production bootstrap driver native emit (parent #1492 / #2600 / #1521)

Problem

M3 strict ladder and M4 loop slice are green on harness 2026-05-27, but gen-1 cannot native-emit bin/compile.php via ./build/selfhost-helloworld-compile:

helloworld_compile_smoke: parseAndCompile returned null (parser/CFG spine)
helloworld_compile_smoke: native emit failed at phase=parseAndCompile

Root cause (link-time): emit-helper link registers M3 sidecars in lib/JIT.php::registerM3EmitTuSidecarFromPath(). lib/Compiler.php sidecar is present; bin/compile.php sidecar is missing:

./script/docker-exec.sh -- bash -lc '
  ./script/bootstrap-selfhost-helloworld-compile-bin.sh >/dev/null
  ls -la build/.m3_compiler_php_aot_blob build/.m3_bin_compile_aot_blob
'
# .m3_compiler_php_aot_blob: ~176 KiB
# .m3_bin_compile_aot_blob: MISSING

Sidecar host-compile subprocess segfaults:

./script/docker-exec.sh -- bash -lc '
  source script/php-env.sh
  export PHP_COMPILER_SELFHOST_AOT=1
  unset PHP_COMPILER_EMIT_HELPER_LINK PHP_COMPILER_M3_EMIT_TU
  php bin/compile.php -o /tmp/bin-compile-sidecar bin/compile.php
  echo exit:$?
'
# exit:139 (Segmentation fault) — no output binary

Without the sidecar, native BootstrapCompileSmokeM3Emit falls through to real compileEmitSmoke and returns null for driver-scale CFG.

Scope

Path Work
lib/JIT.php registerM3EmitTuSidecarFromPath() — surface sidecar failure (stderr) instead of silent skip
lib/JIT/M3EmitTuTrivialEchoAot.php BIN_COMPILE_SIDECAR_REL registration
bin/compile.php First LLVM/JIT crash site under PHP_COMPILER_SELFHOST_AOT=1 full AOT link
lib/JIT/BootstrapCompileSmokeM3Emit.php Native bridge when sidecar absent (real lowering vs honest error)
lib/Web/LiteralIncludeDiscovery.php, lib/Web/SourceBundler.php Likely hot path in bin/compile.php vs lib/Compiler.php

Repro

# M5 driver emit (fails today):
./script/docker-exec.sh -- bash -lc '
  export PHP_COMPILER_M3_SOURCE=/compiler/bin/compile.php
  export PHP_COMPILER_M3_OUT=/compiler/build/compile-php-aot
  ./script/bootstrap-selfhost-helloworld-compile-bin.sh
'

# Sidecar segfault (link-time blocker):
./script/docker-exec.sh -- bash -lc '
  source script/php-env.sh
  export PHP_COMPILER_SELFHOST_AOT=1
  php bin/compile.php -o /tmp/out bin/compile.php; echo exit:$?
'

Contrast (green): PHP_COMPILER_M3_SOURCE=lib/Compiler.php via same script → compile OK.

Done when

Labels

self-host, bootstrap, IMPORTANT

Links

#2600 · #1521 · #2540 · #2633 (closed — symptom moved to sidecar root cause) · #1492

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions