Skip to content

php-in-php: AOT LastErrorRuntimeLlvm — route standalone error_get_last through ErrorLastJitHelper PHP not LLVM globals (#1492) #9607

Closed

Description

@PurHur

Category

php-in-php · runtime

Problem

#9454 migrated JIT error_get_last() / error_clear_last() to compiled PHP via ext/standard/ErrorLastJitHelper.php, but AOT standalone still falls back to lib/JIT/Builtin/LastErrorRuntimeLlvm.php (~LLVM globals + hashtable builder) when Builtin::LOAD_TYPE_STANDALONE is set (LastErrorRuntime::implement() line 77–78).

VM and JIT hot paths use PHP helpers; standalone native binaries retain a parallel LLVM last-error stack (~duplicate semantics, malloc-backed message storage).

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
# Build AOT binary from a script that reads last error after warning
cat >/tmp/last_err.php <<PHP
<?php
trigger_error("probe", E_USER_WARNING);
var_export(error_get_last());
PHP
php bin/compile.php /tmp/last_err.php -o /tmp/last_err
/tmp/last_err 2>/dev/null
# Inspect link: LastErrorRuntimeLlvm symbols still present in standalone module
rg -l LastErrorRuntimeLlvm lib/JIT/Builtin/LastErrorRuntime.php
'

Today LastErrorRuntime.php explicitly documents: "AOT standalone keeps LastErrorRuntimeLlvm until compiled PHP static storage is reliable in native link".

Scope

Layer Files
JIT/AOT lib/JIT/Builtin/LastErrorRuntime.php — always link ErrorLastJitHelper compiled PHP on standalone
Delete/shrink lib/JIT/Builtin/LastErrorRuntimeLlvm.php bodies (or thin forwarders)
AOT link lib/AOT/ emit path — static storage for helper strings like ProgressNoteRuntime migration
Tests test/compliance/cases/stdlib/error_get_last_aot.phpt

PHP-in-PHP first: last-error record in PHP statics; LLVM only for ABI trampoline if required.

Done when

  • AOT standalone error_get_last() matches VM/JIT associative shape after trigger_error()
  • LastErrorRuntimeLlvm deleted or reduced to forward-only stubs with line count noted in PR
  • ./script/ci-fast.sh --filter error_get_last green (VM + AOT fixture)

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 18, 2026
  2. PurHur commented on Jun 18, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — starting this run.

  3. PurHur commented on Jun 22, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — starting this run (route AOT standalone error_get_last through ErrorLastJitHelper, delete LastErrorRuntimeLlvm).

  4. PurHur commented on Jun 22, 2026

    @PurHur
    OwnerAuthor

    Merged via #10614.

    Shrink: deleted lib/JIT/Builtin/LastErrorRuntimeLlvm.php (427 lines). AOT standalone LastErrorRuntime::implement() now uses the same ErrorLastJitHelper PHP bridges as JIT (via NestedJitCompileScope).

    Verification (green):

    • LastErrorRuntimeStandaloneTest — ABI symbols + ErrorLastJitHelper::isActive compiled, no phpc_last_error_active global
    • LastErrorRuntimeShrinkTest — no LastErrorRuntimeLlvm reference
    • php script/bootstrap-inventory.php --check — OK 2873/2873

    Follow-up: full AOT error_get_last fixture compile still fails on master (pre-existing CliArgvJitHelper::createTable LLVM type mismatch during standalone link — separate from this migration).

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

    area:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions