Repository navigation
php-in-php: native CLI argv/globals bootstrap — delete phpc_cli_argv.c (~182 lines), pairs #4374 #5407
Copy link
Copy link
Closed
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExPhase 0 – foundation & DevExphase-1:web-runtimePhase 1 – CGI/web runtimePhase 1 – CGI/web runtime
Description
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
- php/php-src
sapi/cli/php_cli.c— argv vector - php/php-src
main/php_variables.c—$argc/$argvregistration - Current C:
lib/AOT/runtime/phpc_cli_argv.c(Self-host M3: Native emit for compiler compile-smoke fixture (post-#1493) #1937, Self-host M5: bin/compile.php AOT sidecar segfault — missing .m3_bin_compile_aot_blob at emit-helper link #2697, Self-host M5: native $argv bridge — BOOTSTRAP_M5_DRIVER_HOST_FULL_CLI segfault 139 #2794)
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
-
phpc_cli_argv.cdeleted; PR body lists ~182 lines removed fromruntime/ - Runtime: CLI / + ['argv'] (register_argc_argv) parity #4374 repro passes:
$argv[0]and multi-arg scripts match Zend -
make bootstrap-selfhost-helloworldstill green -
./script/ci-fast.sh --filter CliArgvgreen
Links
- Runtime: CLI / + ['argv'] (register_argc_argv) parity #4374, php-in-php: ini_set()/ini_get()/error_reporting() — delete phpc_ini_set.c (~230 lines), INI table in ext/standard #5363, php-in-php: CGI superglobal refresh — delete superglobals_refresh.c (~2623 lines), populate in lib/Web/ #5330, Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492
Metadata
Metadata
Assignees
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExPhase 0 – foundation & DevExphase-1:web-runtimePhase 1 – CGI/web runtimePhase 1 – CGI/web runtime
Activity
PurHur commentedon Jun 8, 2026
claim: worker-lane-B — starting this run
Close #5407: confirm phpc_cli_argv.c shrink, fix M5 argv inventory pr…
PurHur commentedon Jun 8, 2026
Merged via #7670.
Runtime shrink:
lib/AOT/runtime/phpc_cli_argv.c(~182 lines) deleted in #6341; argv lowering is PHP-in-PHP vialib/JIT/Builtin/CliArgvRuntime.php+lib/JIT/CliArgvGlobalInit.php(AOT/JIT) andlib/Web/Superglobals::populateCliArgv()(VM).Verification: