Skip to content

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

Description

@PurHur

Milestone

M3 — HelloWorld / compile-smoke native emit execute (downstream of parse spine; parent #1492)

Problem

May 2026 update: emit-helper link is green on master for runtime, compile-smoke, and HelloWorld TUs. The first failure is now parseAndCompile returned null at execute (#2566, #2568, #2559–#2567).

This issue tracks the next failure class once parse spine returns a non-null Block: LLVM 9 global ctor / type reconstructor crash during emit-helper execute (historically also seen at link time).

Probe prints NEXT_LOWER: M3 emit TU runtime init (global ctor / type reconstructor; #1937) on partial runs.

Scope

Area Path Notes
Emit TU compile lib/JIT.php — compileM3EmitTuMainNative() Global init / ctor emission for bundled vendor types
Runtime init lib/JIT/RuntimeInitVmContext.php May share ctor ordering with emit TU
PHPTypes vendor/ircmaxell/php-types/lib/PHPTypes/TypeReconstructor.php Dynamic property warnings during compile
php-cfg vendor/ircmaxell/php-cfg/... Switch_::$cond dynamic property during spine compile
Deny list lib/JIT.php — m3CompileDriverSpineDenyNames() Ensure ctor helpers not stubbed when real lowering on

Repro (after #2566 green — may segfault at execute)

./script/docker-exec.sh -- bash -lc '
  source script/php-env.sh
  BOOTSTRAP_M3_LINK_COMPILE_DRIVER=1 \
  BOOTSTRAP_M3_COMPILE_DRIVER_REAL_LOWERING=1 \
  BOOTSTRAP_M3_RUNTIME_COMPILE=1 \
  ./script/bootstrap-m3-emit-tu-execute.sh
'

Prerequisite bisect (fails today at parseAndCompile):

BOOTSTRAP_M3_RUNTIME_COMPILE=1 \
BOOTSTRAP_M3_LINK_COMPILE_DRIVER=1 \
make bootstrap-selfhost-runtime-compile-smoke

Done when

Labels

suggested: self-host, bootstrap, IMPORTANT

Epic #1492 · Prerequisite #2566 · #2568 · Execute gate #2552

Activity

  1. PurHur commented on May 26, 2026

    @PurHur
    OwnerAuthor

    Link-time emit-helper Runtime alloc fixed in #2547 (allocateEmitTuShell). Remaining: initVmContext runtime segfault + initParsePipeline PHP CFG link segfault before emit_path=native.

  2. PurHur commented on May 26, 2026

    @PurHur
    OwnerAuthor

    Reopened (backlog-architect May 2026): harness still hits LLVM emit-TU global ctor segfault on M3 strict HelloWorld execute — emit helper link OK, run segfaults. See repro on #1492.

  3. reopened this on May 26, 2026
  4. PurHur commented on May 26, 2026

    @PurHur
    OwnerAuthor

    Priority: P0 after #2559 + #2561 green (HelloWorld execute segfault; link already OK on master). Epic #1492.

  5. PurHur commented on May 27, 2026

    @PurHur
    OwnerAuthor

    Backlog architect update (2026-05-27 harness):

    M3 strict emit ladder is green on master:

    • BOOTSTRAP_M3_COMPILE_SMOKE_STRICT=1 ./script/bootstrap-selfhost-compile-smoke-probe.sh → emit_path=native
    • BOOTSTRAP_M3_RUNTIME_COMPILE_SMOKE_STRICT=1 ./script/bootstrap-selfhost-runtime-compile-smoke.sh → emit_path=native
    • make bootstrap-selfhost-helloworld (Makefile strict defaults) → emit_path=native

    #2568 ✅ closed.

    This issue (global ctor / PHPTypes segfault) is deferred until #2633 (bin/compile.php native emit / parseAndCompile null) is green — that is the current M5 first compile-path failure. Reprioritize execute-time ctor work after parse spine succeeds on the production driver.

  6. PurHur commented on May 27, 2026

    @PurHur
    OwnerAuthor

    Harness verification (2026-05-27) — candidate close

    Emit-helper execute is green on master:

    ./script/docker-exec.sh -- bash -lc '
      source script/php-env.sh
      BOOTSTRAP_M3_LINK_COMPILE_DRIVER=1 \
      BOOTSTRAP_M3_COMPILE_DRIVER_REAL_LOWERING=1 \
      BOOTSTRAP_M3_RUNTIME_COMPILE=1 \
      ./script/bootstrap-m3-emit-tu-execute.sh
    '
    # exit 0 — m3-emit-tu-aot stdout: 1
    
    make bootstrap-selfhost-helloworld
    # emit_path=native
    
    make bootstrap-selfhost-compiler-unit-probe-strict
    # emit_path=native

    Prerequisites #2559 / #2566 appear satisfied on current master. If no remaining segfault repro, close this issue and track any new ctor/init failures under fresh tickets with a failing build/.last-jit-func-* path.

    #1492 backlog run: recommend close unless a maintainer has a red repro on latest master.

  7. PurHur commented on May 27, 2026

    @PurHur
    OwnerAuthor

    Closing: emit-TU execute + M3 strict native emit green on harness 2026-05-27 (see last comment). Reopen with fresh repro if global ctor segfault returns.

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