Skip to content

Self-host M3: emit-TU link via LLVM stubs (no PHP CFG segfault) - #2548

Merged
PurHur merged 1 commit into
masterfrom
agent/selfhost-m3-emit-tu-runtime-stubs
May 26, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/selfhost-m3-emit-tu-runtime-stubs

Conversation

@PurHur

@PurHur PurHur commented May 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • During M3 emit-TU link (PHP_COMPILER_EMIT_HELPER_LINK + PHP_COMPILER_M3_EMIT_TU), route Runtime/Compiler spine symbols and the rest of the bundled lib/ tree to LLVM stubs instead of PHP CFG lowering, which was segfaulting LLVM 9 during global ctor / PHPTypes init.
  • Register native stubs for Runtime::compile, parseAndCompile, and related spine methods used by the emit bridge.
  • Compile emit entry {main} with thin PHP CFG; keep the native emit path on BootstrapAot\*_m3_emit with a null Runtime handle (no object->allocate IR during link).

Test plan

  • make bootstrap-selfhost-link
  • BOOTSTRAP_LIB_SPINE_SMOKE=1 make bootstrap-selfhost-lib-spine-smoke
  • BOOTSTRAP_M3_LINK_COMPILE_DRIVER=1 BOOTSTRAP_M3_COMPILE_DRIVER_REAL_LOWERING=1 ./script/bootstrap-selfhost-runtime-compile-smoke.sh — emit helper link OK (8/8 repro)
  • Same flags on ./script/bootstrap-selfhost-helloworld-probe.sh — emit helper link OK (native execute still partial until Batch A real lowering)

Closes #2540

Made with Cursor

Route Runtime/Compiler spine and bundled lib/ to native LLVM stubs during
M3 emit-TU link instead of PHP CFG lowering (LLVM 9 global ctor segfault).
Simplify {main} to PHP CFG and avoid object allocate in the emit bridge.

Closes #2540

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/selfhost-m3-emit-tu-runtime-stubs branch from 01fda97 to 89c794f Compare May 26, 2026 19:55
@PurHur
PurHur merged commit d094e59 into master May 26, 2026
@PurHur
PurHur deleted the agent/selfhost-m3-emit-tu-runtime-stubs 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Self-host M3: PHPTypes/CFG static init in emit-TU LLVM global ctor (link segfault)

1 participant