Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ test-docker-exec:
.PHONY: test-docker-quick
test-docker-quick: test-docker-fast

.PHONY: bootstrap-inventory bootstrap-profile bootstrap-aot-lint bootstrap-aot-link bootstrap-aot-link-lib bootstrap-selfhost-probe bootstrap-selfhost-link bootstrap-selfhost-compile-smoke bootstrap-selfhost-runtime-compile-smoke bootstrap-selfhost-compiler-driver-smoke bootstrap-selfhost-jit-unit-probe bootstrap-selfhost-vm-unit-probe bootstrap-selfhost-lib-spine-smoke bootstrap-selfhost-lib-spine-vm-smoke bootstrap-selfhost-helloworld bootstrap-loop-gen1-link bootstrap-loop-probe bootstrap-loop-probe-dry bootstrap-loop-probe-dry-run bootstrap-wave-check
.PHONY: bootstrap-inventory bootstrap-profile bootstrap-aot-lint bootstrap-aot-link bootstrap-aot-link-lib bootstrap-selfhost-probe bootstrap-selfhost-link bootstrap-selfhost-compile-smoke bootstrap-selfhost-runtime-compile-smoke bootstrap-selfhost-compiler-driver-smoke bootstrap-selfhost-jit-unit-probe bootstrap-selfhost-vm-unit-probe bootstrap-selfhost-parser-unit-probe bootstrap-selfhost-lib-spine-smoke bootstrap-selfhost-lib-spine-vm-smoke bootstrap-selfhost-helloworld bootstrap-loop-gen1-link bootstrap-loop-probe bootstrap-loop-probe-dry bootstrap-loop-probe-dry-run bootstrap-wave-check
bootstrap-inventory:
php script/bootstrap-inventory.php
bootstrap-profile: bootstrap-inventory
Expand All @@ -265,6 +265,8 @@ bootstrap-selfhost-jit-unit-probe:
./script/bootstrap-selfhost-jit-unit-probe.sh
bootstrap-selfhost-vm-unit-probe:
./script/bootstrap-selfhost-vm-unit-probe.sh
bootstrap-selfhost-parser-unit-probe:
./script/bootstrap-selfhost-parser-unit-probe.sh
bootstrap-selfhost-lib-spine-smoke:
./script/bootstrap-selfhost-lib-spine-smoke-link.sh
bootstrap-selfhost-lib-spine-vm-smoke:
Expand Down
2 changes: 2 additions & 0 deletions docs/bootstrap-selfhost.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
| JIT unit probe native link | `./script/bootstrap-selfhost-jit-unit-probe.sh` or `make bootstrap-selfhost-jit-unit-probe` | ✅ `build/selfhost-jit-unit-probe` prints `jit_unit_probe bundle OK`; `BOOTSTRAP_JIT_UNIT_PROBE_GATE=1` opt-in in `ci-local.sh` llvm tail ([#2361](https://github.com/PurHur/php-compiler/issues/2361)) |
| VM unit probe lint | `php bin/compile.php -l test/selfhost/vm_unit_probe/main.php` | ✅ `compiler_minimal`-scale bundle + `lib/VM.php` + `vm_unit_probe_run.php` ([#2354](https://github.com/PurHur/php-compiler/issues/2354)) |
| VM unit probe native link | `./script/bootstrap-selfhost-vm-unit-probe.sh` or `make bootstrap-selfhost-vm-unit-probe` | ✅ `build/selfhost-vm-unit-probe` prints `vm_unit_probe bundle OK` (link-only; VM `echo` run via `vm_unit_probe_run.php` deferred — native init); `BOOTSTRAP_VM_UNIT_PROBE_GATE=1` opt-in in `ci-local.sh` llvm tail ([#2368](https://github.com/PurHur/php-compiler/issues/2368)) |
| Parser unit probe lint | `php bin/compile.php -l test/selfhost/parser_unit_probe/main.php` | ✅ `compiler_minimal`-scale bundle + `lib/Runtime.php` + `parser_unit_probe_parse.php` ([#2409](https://github.com/PurHur/php-compiler/issues/2409)) |
| Parser unit probe native link | `./script/bootstrap-selfhost-parser-unit-probe.sh` or `make bootstrap-selfhost-parser-unit-probe` | ✅ `build/selfhost-parser-unit-probe` prints `parser_unit_probe bundle OK` (link-only; `Runtime::parse` on fixture under Zend via PHPUnit); CI gate opt-in ([#2417](https://github.com/PurHur/php-compiler/issues/2417)) |
| Compiler compile smoke AOT echo run | `./script/bootstrap-selfhost-compile-smoke-run.sh` or `make bootstrap-selfhost-compile-smoke-run` | ✅ `build/selfhost-compile-smoke-echo` prints `compiler smoke` from `test/bootstrap-aot/compiler_smoke_standalone.php` (wave 7A; included in `--with-compile-smoke`) |
| Wave gate (lint + probe) | `./script/bootstrap-wave-check.sh` | ✅ selfhost-lint → aot-lint → probe; prints `NEXT_LOWER` |
| Self-host compile probe | `make bootstrap-selfhost-probe` | ✅ `-l` + `-o build/selfhost` ([#816](https://github.com/PurHur/php-compiler/issues/816), [#827](https://github.com/PurHur/php-compiler/issues/827), [#913](https://github.com/PurHur/php-compiler/issues/913)) |
Expand Down
2 changes: 1 addition & 1 deletion docs/self-host-target.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ That is **M5**. Everything below is the honest path from today’s bootstrap to
| **M2** | Spine grows toward full `bin/vm.php` inventory | ✅ **655/657** units (link) | **~93%** |
| **M3** | Self-host binary **compiles external PHP** (HelloWorld) without Zend emit | 🚧 partial (run ✅, emit 🚧) | **~35%** |

**M3 unit probe presenter** ([#2360](https://github.com/PurHur/php-compiler/issues/2360)): `make north-star3-verify` runs `008-SelfHostProbe` plus optional `bootstrap-selfhost-{compiler,jit,vm}-unit-probe.sh` when LLVM 9 and probe scripts are present. **VM unit probe** ([#2354](https://github.com/PurHur/php-compiler/issues/2354)): `make bootstrap-selfhost-vm-unit-probe` / `BOOTSTRAP_VM_UNIT_PROBE_GATE=1` in `ci-local.sh` llvm tail. Compiler/JIT unit probes: [#2216](https://github.com/PurHur/php-compiler/issues/2216), [#2332](https://github.com/PurHur/php-compiler/issues/2332).
**M3 unit probe presenter** ([#2360](https://github.com/PurHur/php-compiler/issues/2360)): `make north-star3-verify` runs `008-SelfHostProbe` plus optional `bootstrap-selfhost-{compiler,jit,vm}-unit-probe.sh` when LLVM 9 and probe scripts are present. **Parser unit probe** ([#2409](https://github.com/PurHur/php-compiler/issues/2409)): `make bootstrap-selfhost-parser-unit-probe` — CFG front-end (`Runtime` + `lib/Compiler.php` bundle); `north-star3-verify` step ([#2418](https://github.com/PurHur/php-compiler/issues/2418)) and CI gate ([#2417](https://github.com/PurHur/php-compiler/issues/2417)) follow. **VM unit probe** ([#2354](https://github.com/PurHur/php-compiler/issues/2354)): `make bootstrap-selfhost-vm-unit-probe` / `BOOTSTRAP_VM_UNIT_PROBE_GATE=1` in `ci-local.sh` llvm tail. Compiler/JIT unit probes: [#2216](https://github.com/PurHur/php-compiler/issues/2216), [#2332](https://github.com/PurHur/php-compiler/issues/2332).
| **M4** | Self-host binary **rebuilds** the next compiler tree | ⬜ | 0% |
| **M5** | Full self-host; Zend retired from loop | ⬜ north star | 0% |

Expand Down
4 changes: 3 additions & 1 deletion lib/Doctor.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ public static function runSelfhost(string $repoRoot): int
fwrite(STDOUT, " make bootstrap-selfhost-jit-unit-probe\n");
fwrite(STDOUT, ' BOOTSTRAP_JIT_UNIT_PROBE_GATE='.(self::gateEnabled('BOOTSTRAP_JIT_UNIT_PROBE_GATE', $jitUnitProbeDefault) ? '1' : '0')." (default {$jitUnitProbeDefault}) — ci-local LLVM tail ([#2332](https://github.com/PurHur/php-compiler/issues/2332), [#2361](https://github.com/PurHur/php-compiler/issues/2361))\n");
fwrite(STDOUT, " make bootstrap-selfhost-vm-unit-probe\n");
fwrite(STDOUT, ' BOOTSTRAP_VM_UNIT_PROBE_GATE='.(self::gateEnabled('BOOTSTRAP_VM_UNIT_PROBE_GATE', $vmUnitProbeDefault) ? '1' : '0')." (default {$vmUnitProbeDefault}) — ci-local LLVM tail ([#2354](https://github.com/PurHur/php-compiler/issues/2354), [#2368](https://github.com/PurHur/php-compiler/issues/2368))\n\n");
fwrite(STDOUT, ' BOOTSTRAP_VM_UNIT_PROBE_GATE='.(self::gateEnabled('BOOTSTRAP_VM_UNIT_PROBE_GATE', $vmUnitProbeDefault) ? '1' : '0')." (default {$vmUnitProbeDefault}) — ci-local LLVM tail ([#2354](https://github.com/PurHur/php-compiler/issues/2354), [#2368](https://github.com/PurHur/php-compiler/issues/2368))\n");
fwrite(STDOUT, " make bootstrap-selfhost-parser-unit-probe (#2409 CFG parse front-end)\n\n");

fwrite(STDOUT, "3. M3 emit (partial vs strict)\n");
fwrite(STDOUT, " BOOTSTRAP_M3_HELLOWORLD_STRICT_GATE=".(self::gateEnabled('BOOTSTRAP_M3_HELLOWORLD_STRICT_GATE', $m3HelloStrictDefault) ? '1' : '0')." (default {$m3HelloStrictDefault}) — ci-local LLVM tail\n");
Expand Down Expand Up @@ -483,6 +484,7 @@ private static function printSelfHostPresenterSection(string $repoRoot): void
: 'opt-in BOOTSTRAP_VM_UNIT_PROBE_GATE=1 for lib/VM.php native link (#2354, #2368)';
fwrite(STDOUT, " M3 VM probe make bootstrap-selfhost-vm-unit-probe\n");
fwrite(STDOUT, " {$vmUnitProbeDetail}\n");
fwrite(STDOUT, " M3 parser probe make bootstrap-selfhost-parser-unit-probe (#2409)\n");
$loopProbeGate = getenv('BOOTSTRAP_LOOP_PROBE_GATE');
$loopProbeOn = false !== $loopProbeGate && '1' === $loopProbeGate;
$m4LoopProbeGate = getenv('BOOTSTRAP_M4_LOOP_PROBE');
Expand Down
40 changes: 40 additions & 0 deletions script/bootstrap-selfhost-parser-unit-probe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# M3 parser unit probe: CFG front-end bundle native link + run (issue #2409).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
ENTRY="${ROOT}/test/selfhost/parser_unit_probe/main.php"
OUT="${ROOT}/build/selfhost-parser-unit-probe"

# shellcheck source=php-env.sh
source "$(dirname "$0")/php-env.sh"
ci_apply_llvm_memory_env

if [[ ! -f "${ENTRY}" ]]; then
echo "bootstrap-selfhost-parser-unit-probe: missing ${ENTRY}" >&2
exit 1
fi

if [[ -z "${PHP_COMPILER_LLVM_PATH:-}" || ! -f "${PHP_COMPILER_LLVM_PATH}/libLLVM-9.so.1" ]]; then
echo "bootstrap-selfhost-parser-unit-probe: LLVM 9 not found (skip)" >&2
exit 2
fi

mkdir -p "${ROOT}/build"
export PHP_COMPILER_SELFHOST_AOT=1
export PHP_COMPILER_JIT_PROGRESS_FILE="${ROOT}/build/.last-jit-func-parser-unit-probe"
rm -f "${OUT}" "${PHP_COMPILER_JIT_PROGRESS_FILE}"

if ! php "${ROOT}/bin/compile.php" -o "${OUT}" "${ENTRY}" 2>&1; then
echo "bootstrap-selfhost-parser-unit-probe: compile failed (progress gate; see stderr above)" >&2
exit 1
fi
test -x "${OUT}"

bundle_out="$("${OUT}")"
if ! grep -q 'parser_unit_probe bundle OK' <<< "${bundle_out}"; then
echo "bootstrap-selfhost-parser-unit-probe: unexpected link stdout (want parser_unit_probe bundle OK)" >&2
printf '%s\n' "${bundle_out}" >&2
exit 1
fi

echo "bootstrap-selfhost-parser-unit-probe: OK ${OUT}"
20 changes: 20 additions & 0 deletions test/selfhost/parser_unit_probe/fixture.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

/**
* Tiny CFG fixture: class + method + if (issue #2409).
* Parsed by parser_unit_probe_parse_smoke() under Zend; not executed in native bundle.
*/

class ParserUnitProbeFixture
{
public function run(bool $flag): int
{
if ($flag) {
return 1;
}

return 0;
}
}
122 changes: 122 additions & 0 deletions test/selfhost/parser_unit_probe/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

declare(strict_types=1);

/**
* M3 parser unit probe: compiler_minimal-scale bundle + CFG parse front-end slice (#2409).
* Gate: php bin/compile.php -l test/selfhost/parser_unit_probe/main.php
* Native: ./script/bootstrap-selfhost-parser-unit-probe.sh
* Zend parse: parser_unit_probe_parse_smoke() in parser_unit_probe_parse.php (PHPUnit).
*/

require_once __DIR__.'/../../../lib/OpCode.php';
require_once __DIR__.'/../../../lib/Block.php';
require_once __DIR__.'/../../../lib/Frame.php';
require_once __DIR__.'/../../../lib/Func.php';
require_once __DIR__.'/../../../lib/Func/PHP.php';
require_once __DIR__.'/../../../lib/VM/ClassProperty.php';
require_once __DIR__.'/../../../lib/VM/ScriptExit.php';
require_once __DIR__.'/../../../lib/JIT/OperandName.php';
require_once __DIR__.'/../../../lib/Printer.php';
require_once __DIR__.'/../../../lib/NullSafeLivenessDetector.php';
require_once __DIR__.'/../../../lib/Runtime.php';
require_once __DIR__.'/../../../lib/Web/ConstStringFolder.php';
require_once __DIR__.'/../../../lib/Web/IncludePathResolver.php';
require_once __DIR__.'/../../../lib/Web/LiteralIncludeDiscovery.php';
require_once __DIR__.'/../../../lib/OpCodeNames.php';
require_once __DIR__.'/../../../lib/VM/Variable.php';
require_once __DIR__.'/../../../lib/Web/DeployRoot.php';
require_once __DIR__.'/../../../lib/Web/SourceBundler.php';
require_once __DIR__.'/../../../lib/Module.php';
require_once __DIR__.'/../../../lib/ModuleAbstract.php';
require_once __DIR__.'/../../../lib/VM/Refcount.php';
require_once __DIR__.'/../../../lib/VM/ErrorReporter.php';
require_once __DIR__.'/../../../lib/VM/ScriptStack.php';
require_once __DIR__.'/../../../lib/VM/HashTable.php';
require_once __DIR__.'/../../../lib/VM/ClassEntry.php';
require_once __DIR__.'/../../../lib/VM/ObjectEntry.php';
require_once __DIR__.'/../../../lib/VM/TypeCheck.php';
require_once __DIR__.'/../../../lib/VM/Optimizer/AssignOp.php';
require_once __DIR__.'/../../../lib/VM/Optimizer.php';
require_once __DIR__.'/../../../lib/VM/Context.php';
require_once __DIR__.'/../../../lib/Handler.php';
require_once __DIR__.'/../../../lib/JIT/Call.php';
require_once __DIR__.'/../../../lib/JIT/Builtin.php';
require_once __DIR__.'/../../../lib/JIT/Result.php';
require_once __DIR__.'/../../../lib/Func/Internal.php';
require_once __DIR__.'/../../../lib/Func/JIT.php';
require_once __DIR__.'/../../../lib/JIT/Variable.php';
require_once __DIR__.'/../../../lib/JIT/IssetHelper.php';
require_once __DIR__.'/../../../lib/Web/Superglobals.php';
require_once __DIR__.'/../../../lib/JIT/Scope.php';
require_once __DIR__.'/../../../lib/JIT/Analyzer.php';
require_once __DIR__.'/../../../lib/JIT/BasicBlockHelper.php';
require_once __DIR__.'/../../../lib/JIT/JitValueBox.php';
require_once __DIR__.'/../../../lib/JIT/SelfHostBuiltinPolicy.php';
require_once __DIR__.'/../../../lib/JIT/CoalesceHelper.php';
require_once __DIR__.'/../../../lib/JIT/IncludeHelper.php';
require_once __DIR__.'/../../../lib/JIT/ScopeBuiltinHelper.php';
require_once __DIR__.'/../../../lib/JIT/NullsafeHelper.php';
require_once __DIR__.'/../../../lib/JIT/Progress.php';
require_once __DIR__.'/../../../lib/JIT/Call/Native.php';
require_once __DIR__.'/../../../lib/JIT/Call/ExternalMethod.php';
require_once __DIR__.'/../../../lib/JIT/Call/SplObjectStorageMethod.php';
require_once __DIR__.'/../../../lib/JIT/Call/Vararg.php';
require_once __DIR__.'/../../../lib/JIT/JitNativeString.php';
require_once __DIR__.'/../../../lib/JIT/JitStringArg.php';
require_once __DIR__.'/../../../lib/JIT/JitLongArg.php';
require_once __DIR__.'/../../../lib/JIT/JitBoolArg.php';
require_once __DIR__.'/../../../lib/JIT/SuperglobalInit.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/MemoryManager.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/MemoryManager/Native.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/MemoryManager/PHP.php';
require_once __DIR__.'/../../../lib/JIT/IteratorHelper.php';
require_once __DIR__.'/../../../lib/JIT/JitStringCompare.php';
require_once __DIR__.'/../../../lib/JIT/JitValueCompare.php';
require_once __DIR__.'/../../../lib/JIT/StringOffsetHelper.php';
require_once __DIR__.'/../../../lib/JIT/ValueEchoHelper.php';
require_once __DIR__.'/../../../lib/JIT/ScriptMagic.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/Refcount.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/Output.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/ErrorHandler.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/ScriptExit.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/IsNullFn.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/PendingHeaders.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/HttpResponseCode.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringJsonEncode.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringGetenv.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringQuotemeta.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringNl2br.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringStripslashes.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringAddslashes.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringUcwords.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringPregQuote.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringRandomBytes.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringFileGetContents.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringDeployPath.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringReadfile.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringHtmlspecialchars.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringDateTime.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringWordwrap.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringUrlencode.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/StringFilePutContents.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/Type/Value.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/Type/NativeArray.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/Type/MaskedArray.php';
require_once __DIR__.'/../../../lib/MethodVisibility.php';
require_once __DIR__.'/../../../lib/JIT/Helper.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/Internal.php';
require_once __DIR__.'/../../../lib/JIT/Builtin/VarArg.php';
require_once __DIR__.'/../../../lib/JIT/Context.php';
require_once __DIR__.'/../../../lib/JIT/HashTableHelper.php';
require_once __DIR__.'/../../../lib/JIT.php';
require_once __DIR__.'/../../../lib/VM/OutputBuffer.php';
require_once __DIR__.'/../../../lib/VM.php';
require_once __DIR__.'/../../../lib/Compiler.php';
require_once __DIR__.'/../../../lib/Lint/Issue.php';
require_once __DIR__.'/../../../lib/Lint/UnsupportedRegistry.php';
require_once __DIR__.'/../../../lib/Lint/LintCompiler.php';
require_once __DIR__.'/../../../lib/Lint/Linter.php';

// Native link-only: Runtime::parse on fixture under Zend (parser_unit_probe_parse.php; #2409).
echo "parser_unit_probe bundle OK\n";
33 changes: 33 additions & 0 deletions test/selfhost/parser_unit_probe/parser_unit_probe_parse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

/**
* PHPCfg front-end smoke: Runtime::parse on fixture.php (issue #2409).
* Invoked from PHPUnit under Zend; native bundle defers parse run (vendor PHPCfg at cold boot).
*/

function parser_unit_probe_fixture_path(): string
{
return __DIR__.'/fixture.php';
}

function parser_unit_probe_fixture_source(): string
{
return (string) file_get_contents(parser_unit_probe_fixture_path());
}

function parser_unit_probe_parse_smoke(): string
{
if (!class_exists(\PHPCompiler\Runtime::class)) {
return 'parser_unit_probe parse SKIP (no Runtime)';
}

$runtime = new \PHPCompiler\Runtime();
$script = $runtime->parse(parser_unit_probe_fixture_source(), parser_unit_probe_fixture_path());
if (!$script instanceof \PHPCfg\Script) {
return 'parser_unit_probe parse FAIL';
}

return 'parser_unit_probe parse OK';
}
Loading