Skip to content

M2 spine: bundle src/cli.php entry shim (#1432 follow-up) #1467

Description

@PurHur

Summary

Follow-up from #1432 / PR #1465. Four compat shims landed in compiler_lib_spine_smoke; src/cli.php remains deferred from the M2 spine bundle until M4 entry wiring.

Parent epic: #1492 (North Star 2 self-host). M4 loop: #1498 ✅ scaffold · native gen-2 #2075.

Problem

src/cli.php is the Zend-side entry for phpc-style argv dispatch during bootstrap. Today it:

  • requires vendor/autoload.php at top level
  • Parses $argv and may exit at include time

That breaks bundled AOT lint (php bin/compile.php -l test/selfhost/...) and spine smoke targets that expect side-effect-free compilation units.

Goal

src/cli.php compiles under compiler_lib_spine_smoke (or a thin src/cli_stub.php) and can be invoked from a native gen-2 driver (#2075) without Zend vendor/ on disk.

Implementation hints

Piece Path Notes
Entry split src/cli.phpsrc/cli_main.php Top-level only defines functions; main($argv) callable from native bootstrap
Autoload guard PHP_COMPILER_SELFHOST_AOT Skip vendor/autoload.php when bundled stubs provide classes (#1520)
Allowlist docs/m3-allowlist-snapshot.txt, docs/m4-allowlist-*.txt Add src/cli.php when emit path stable (#1937)
Spine smoke test/selfhost/compiler_lib_spine_smoke/main.php Include or compile src/cli.php after shims
M4 driver #1467 / #2075 Native main() calls compiled CLI dispatcher
Inventory php script/bootstrap-inventory.php --check Count moves 606→611 with #2066

Suggested steps (ordered)

  1. Refactor src/cli.php so include does not execute argv handling
  2. Add spine smoke reference from compiler_lib_spine_smoke (lint-only first)
  3. Wire Self-host M3: Native emit for compiler compile-smoke fixture (post-#1493) #1937 strict emit for the refactored file
  4. Connect Self-host M4: Native gen-2 AOT emit without Zend fallback (post-#1498) #2075 gen-2 native driver to call compiled entry

Blocker (current)

src/cli.php requires vendor/autoload.php and executes argv at include time — incompatible with bundled AOT lint / self-host spine until refactor above lands.

Acceptance criteria

script/apply-patches.sh
php bin/compile.php -l test/selfhost/compiler_lib_spine_smoke/main.php
# After refactor:
php bin/compile.php -l src/cli.php
BOOTSTRAP_LIB_SPINE_SMOKE=1 make bootstrap-selfhost-lib-spine-smoke
make bootstrap-aot-link
vendor/bin/phpunit test/unit/BootstrapSelfhostBundleTest.php

Docker:

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  make bootstrap-selfhost-lib-spine-smoke

Dependencies

Gates (when ready)

script/apply-patches.sh
php bin/compile.php -l test/selfhost/compiler_lib_spine_smoke/main.php
BOOTSTRAP_LIB_SPINE_SMOKE=1 make bootstrap-selfhost-lib-spine-smoke
make bootstrap-aot-link
vendor/bin/phpunit test/unit/BootstrapSelfhostBundleTest.php
BOOTSTRAP_M4_LOOP_PROBE_GATE=1 ./script/bootstrap-loop-probe.sh --dry-run

Links

Verification

Local/Docker only; do not require GitHub Actions (#394 ✅).

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions