Skip to content

php-in-php: native CLI argv/globals bootstrap — delete phpc_cli_argv.c (~182 lines), pairs #4374 #5407

Closed

Description

@PurHur

Category

php-in-php · bootstrap · runtime

Problem

Native AOT/M3 emit stores process argc/argv in lib/AOT/runtime/phpc_cli_argv.c (~182 lines) including segfault progress hooks. Runtime parity for $argc, $argv, and $_SERVER['argv'] is tracked in #4374, but the C table should shrink: argv capture + superglobal wiring belongs in ext/standard / lib/Web/ PHP with a thin C entry (main() passes char **argv once).

Self-host (#1492) needs compiled PHP to see real CLI args without growing hand-written C.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
wc -l lib/AOT/runtime/phpc_cli_argv.c
rg phpc_cli_argv lib/AOT/Linker.php
php bin/vm.php -r "var_dump(\$argc, \$argv[0] ?? null);" -- repro-arg
# VM today: wrong/missing argv wiring (#4374)
'

Scope (this repo)

Area Work
ext/standard/ PHP registry for argv + register_argc_argv INI (#4374, #5363)
lib/Web/ or CLI driver Populate superglobals from native argv once at startup
lib/AOT/runtime/phpc_cli_argv.c Delete (~182 lines); keep minimal main()→PHP trampoline if unavoidable
lib/AOT/Linker.php Remove from RUNTIME_C_SOURCES

Implement semantics in PHP; C only passes argc/argv pointers at process entry.

Done when

Links

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 4, 2026
  2. PurHur commented on Jun 8, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-B — starting this run

  3. added a commit that references this issue on Jun 8, 2026
    7f0a7ba
  4. PurHur commented on Jun 8, 2026

    @PurHur
    OwnerAuthor

    Merged via #7670.

    Runtime shrink: lib/AOT/runtime/phpc_cli_argv.c (~182 lines) deleted in #6341; argv lowering is PHP-in-PHP via lib/JIT/Builtin/CliArgvRuntime.php + lib/JIT/CliArgvGlobalInit.php (AOT/JIT) and lib/Web/Superglobals::populateCliArgv() (VM).

    Verification:

    vendor/bin/phpunit --filter "CliArgvRuntimeStandaloneTest|testJitM5DriverHostCompileEnv"  → OK (2 tests, 17 assertions)
    php bin/vm.php -r 'var_dump($argc, $argv);' -- repro-arg  → int(2), argv[1]="repro-arg"
    
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 / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-1:web-runtimePhase 1 – CGI/web runtime

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions