Category
language
Problem
__halt_compiler() lowering landed (#3479), but the companion magic constant __COMPILER_HALT_OFFSET__ is still undefined at runtime. PHAR stubs and codegen tools rely on the byte offset of the first halt instruction.
Verified 2026-06-04: halt stops execution, but reading the constant fatals.
php-src reference
Repro
<?php
echo __COMPILER_HALT_OFFSET__, "\n";
__halt_compiler();
TRAILING
./script/docker-exec.sh bash -lc 'php repro.php' # prints int offset (e.g. 89)
./script/docker-exec.sh bash -lc 'php bin/vm.php repro.php' # Error: Undefined constant "__COMPILER_HALT_OFFSET__"
| Engine |
Expected |
| Zend |
int(N) — byte offset of halt in compiled file |
| This compiler |
same int on VM and AOT |
Scope (this repo)
| Layer |
Path |
| Compiler |
lib/Compiler.php — record halt byte offset per compilation unit (extend existing #3479 trailing-bytes fields) |
| php-cfg / parse |
expose offset from Stmt\HaltCompiler site |
| VM |
lower as script magic constant like __LINE__ / __FILE__ |
| JIT/AOT |
constexpr per module; no host \__COMPILER_HALT_OFFSET__ |
| Tests |
test/compliance/cases/language/compiler_halt_offset.phpt |
Done when
Related
Category
languageProblem
__halt_compiler()lowering landed (#3479), but the companion magic constant__COMPILER_HALT_OFFSET__is still undefined at runtime. PHAR stubs and codegen tools rely on the byte offset of the first halt instruction.Verified 2026-06-04: halt stops execution, but reading the constant fatals.
php-src reference
Zend/zend_compile.c—zend_compile_halt_compiler()setsZEND_COMPILE_HALT_OFFSETZend/zend_language_scanner.l—T_COMPILER_HALT_OFFSEText/phar/phar.c— stub layout uses offsetRepro
int(N)— byte offset of halt in compiled fileScope (this repo)
lib/Compiler.php— record halt byte offset per compilation unit (extend existing#3479trailing-bytes fields)Stmt\HaltCompilersite__LINE__/__FILE__\__COMPILER_HALT_OFFSET__test/compliance/cases/language/compiler_halt_offset.phptDone when
__halt_compiler()call (Zend allows both)./script/ci-fast.sh --filter compiler_halt_offsetgreenRelated
__halt_compiler()parse stop + trailing bytes