Skip to content

php-in-php: drop last AOT C TU (phpc_progress.c) by emitting SIGSEGV handler in LLVM #17148

Description

@PurHur

Goal

Remove the last hand-written C runtime translation unit from the AOT link by emitting the async-signal-safe SIGSEGV handler directly in LLVM IR from PHP lowering (PHP-in-PHP, #1492).

Current behavior

AOT links a bundled C TU that installs a SIGSEGV handler which prints the last progress breadcrumb ("phpc_last_progress") and exits 139.

Change

  • Emit phpc_segv_handler in LLVM IR (write(2)+_exit only)
  • Install handler during __init__ emission (no __attribute__((constructor)))
  • Keep progress breadcrumb globals in LLVM (existing ProgressNoteRuntime)
  • Make lib/AOT/Linker.php ship no bundled C runtime sources

Why this is safe

The handler stays async-signal-safe (no malloc/stdio); only write + _exit.

Verification

  • ./script/docker-exec.sh ./script/check-aot-build-smoke.sh
  • ./script/docker-exec.sh php vendor/bin/phpunit --filter 'AotRuntimeInventoryTest|RuntimeShrinkCloseoutTest|ProgressNoteRuntimeStandaloneTest|ExecJitRuntimeShrinkTest|GettextJitRuntimeShrinkTest|ProgressNoteRuntimeShrinkTest'

Notes

If we need portability beyond Linux, a follow-up could avoid hardcoding SIGSEGV=11 in IR.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions