diff --git a/Makefile b/Makefile index 7a77fe0a84e..da9ce3ff05c 100755 --- a/Makefile +++ b/Makefile @@ -182,7 +182,7 @@ test-harness: .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-lib-spine-smoke bootstrap-selfhost-helloworld bootstrap-loop-gen1-link bootstrap-loop-probe bootstrap-loop-probe-dry 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-lib-spine-smoke bootstrap-selfhost-lib-spine-vm-smoke bootstrap-selfhost-helloworld bootstrap-loop-gen1-link bootstrap-loop-probe bootstrap-loop-probe-dry bootstrap-wave-check bootstrap-inventory: php script/bootstrap-inventory.php bootstrap-profile: bootstrap-inventory @@ -203,6 +203,8 @@ bootstrap-selfhost-compile-smoke-run: ./script/bootstrap-selfhost-compile-smoke-run.sh bootstrap-selfhost-lib-spine-smoke: ./script/bootstrap-selfhost-lib-spine-smoke-link.sh +bootstrap-selfhost-lib-spine-vm-smoke: + ./script/bootstrap-selfhost-lib-spine-vm-smoke.sh bootstrap-selfhost-helloworld: ./script/bootstrap-selfhost-helloworld-probe.sh bootstrap-loop-gen1-link: diff --git a/docs/bootstrap-selfhost.md b/docs/bootstrap-selfhost.md index 781499e0584..cd16d84f94a 100644 --- a/docs/bootstrap-selfhost.md +++ b/docs/bootstrap-selfhost.md @@ -22,6 +22,7 @@ | Self-host native link | `./script/bootstrap-selfhost-link.sh` | ✅ `build/selfhost` prints `compiler_minimal bundle OK` ([#557](https://github.com/PurHur/php-compiler/issues/557), [#913](https://github.com/PurHur/php-compiler/issues/913)) | | M2 lib spine smoke lint | `php bin/compile.php -l test/selfhost/compiler_lib_spine_smoke/main.php` | ✅ **582** units ([#1492](https://github.com/PurHur/php-compiler/issues/1492), [#1419](https://github.com/PurHur/php-compiler/issues/1419) | M2 lib spine smoke native run | `./script/bootstrap-selfhost-lib-spine-smoke-link.sh` or `BOOTSTRAP_LIB_SPINE_SMOKE=1 make bootstrap-selfhost-lib-spine-smoke` | ✅ `build/selfhost-lib-spine-smoke` prints `compiler_lib_spine_smoke bundle OK` | +| M2 lib spine VM `-r` smoke | `./script/bootstrap-selfhost-lib-spine-vm-smoke.sh` or `BOOTSTRAP_LIB_SPINE_VM_SMOKE=1 make bootstrap-selfhost-lib-spine-vm-smoke` | ✅ same binary + `PHP_COMPILER_VM_SPINE_SMOKE=1` prints `vm-spine-ok` ([#1846](https://github.com/PurHur/php-compiler/issues/1846); CI opt-in `BOOTSTRAP_LIB_SPINE_VM_SMOKE_GATE=1`) | | M3 HelloWorld self-host probe lint | `php bin/compile.php -l test/selfhost/compiler_helloworld_smoke/main.php` | ✅ `compiler_compile_smoke` spine + `helloworld_compile_smoke` driver (linkable) | | M3 HelloWorld compile driver lint | `php bin/compile.php -l test/selfhost/compiler_helloworld_smoke/compile_driver.php` | ✅ `Runtime::parseAndCompile` + mode-file dispatch (native link opt-in) | | M3 HelloWorld self-host probe | `./script/bootstrap-selfhost-helloworld-probe.sh` or `make bootstrap-selfhost-helloworld` | 🚧 **partial** — bundle link ✅; HelloWorld AOT **run** native ✅; **emit uses Zend fallback** until native runtime compile passes ([#1492](https://github.com/PurHur/php-compiler/issues/1492); probe sets `M3_NATIVE_COMPILE=1` / `emit_path=native` only on selfhost compile-driver success; `BOOTSTRAP_M3_HELLOWORLD_STRICT=1` fails without fallback — see [bootstrap-m5-fast-path.md](bootstrap-m5-fast-path.md)) | diff --git a/script/bootstrap-selfhost-lib-spine-vm-smoke.sh b/script/bootstrap-selfhost-lib-spine-vm-smoke.sh new file mode 100755 index 00000000000..ce16f9a6960 --- /dev/null +++ b/script/bootstrap-selfhost-lib-spine-vm-smoke.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# M2 lib spine VM -r smoke: reuse build/selfhost-lib-spine-smoke, run bin/vm.php -r echo path (#1846). +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +OUT="${ROOT}/build/selfhost-lib-spine-smoke" +LINK="${ROOT}/script/bootstrap-selfhost-lib-spine-smoke-link.sh" +# shellcheck source=php-env.sh +source "$(dirname "$0")/php-env.sh" +ci_apply_llvm_memory_env + +if [[ -z "${PHP_COMPILER_LLVM_PATH:-}" || ! -f "${PHP_COMPILER_LLVM_PATH}/libLLVM-9.so.1" ]]; then + echo "bootstrap-selfhost-lib-spine-vm-smoke: LLVM 9 not found (skip)" >&2 + exit 2 +fi + +if [[ ! -x "${OUT}" ]]; then + "${LINK}" +else + # Re-link when spine entry is newer than the native binary. + ENTRY="${ROOT}/test/selfhost/compiler_lib_spine_smoke/main.php" + if [[ "${ENTRY}" -nt "${OUT}" ]]; then + "${LINK}" + fi +fi + +test -x "${OUT}" +out="$({ PHP_COMPILER_VM_SPINE_SMOKE=1 "${OUT}"; })" +if ! grep -q 'vm-spine-ok' <<< "${out}"; then + echo "bootstrap-selfhost-lib-spine-vm-smoke: unexpected stdout (want vm-spine-ok)" >&2 + printf '%s\n' "${out}" >&2 + exit 1 +fi +echo "bootstrap-selfhost-lib-spine-vm-smoke: OK ${OUT}" diff --git a/script/bootstrap-wave-check.sh b/script/bootstrap-wave-check.sh index 0bc3f28ae0a..394810610ae 100755 --- a/script/bootstrap-wave-check.sh +++ b/script/bootstrap-wave-check.sh @@ -8,10 +8,14 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)" FAIL_FAST=0 WITH_COMPILE_SMOKE=0 WITH_LIB_SPINE_SMOKE=0 +WITH_LIB_SPINE_VM_SMOKE=0 WITH_HELLOWORLD=0 if [[ "${BOOTSTRAP_LIB_SPINE_SMOKE:-0}" == "1" ]]; then WITH_LIB_SPINE_SMOKE=1 fi +if [[ "${BOOTSTRAP_LIB_SPINE_VM_SMOKE:-0}" == "1" ]]; then + WITH_LIB_SPINE_VM_SMOKE=1 +fi if [[ "${BOOTSTRAP_M3_HELLOWORLD:-0}" == "1" ]]; then WITH_HELLOWORLD=1 fi @@ -26,6 +30,9 @@ while [[ $# -gt 0 ]]; do --with-lib-spine-smoke) WITH_LIB_SPINE_SMOKE=1 ;; + --with-lib-spine-vm-smoke) + WITH_LIB_SPINE_VM_SMOKE=1 + ;; --with-helloworld) WITH_HELLOWORLD=1 ;; @@ -107,6 +114,11 @@ if [[ "${WITH_LIB_SPINE_SMOKE}" -eq 1 ]]; then print_summary fi +if [[ "${WITH_LIB_SPINE_VM_SMOKE}" -eq 1 ]]; then + run_step "selfhost-lib-spine-vm-smoke" ./script/bootstrap-selfhost-lib-spine-vm-smoke.sh + print_summary +fi + if [[ "${WITH_HELLOWORLD}" -eq 1 ]]; then run_step "selfhost-helloworld-probe" ./script/bootstrap-selfhost-helloworld-probe.sh print_summary diff --git a/script/ci-common.sh b/script/ci-common.sh index c33ce5c1c33..25bc4140ccd 100644 --- a/script/ci-common.sh +++ b/script/ci-common.sh @@ -221,6 +221,19 @@ ci_run_bootstrap_selfhost_probe() { "$_CI_SCRIPT_DIR/bootstrap-selfhost-compile-probe.sh" "${probe_args[@]}" } +# M2 lib spine VM -r smoke (issue #1846); default off until green in llvm tail. +ci_run_bootstrap_lib_spine_vm_smoke() { + if [[ "${BOOTSTRAP_LIB_SPINE_VM_SMOKE_GATE:-0}" != "1" ]]; then + return 0 + fi + if ! ci_llvm_ready; then + echo "bootstrap-selfhost-lib-spine-vm-smoke: skipped (LLVM 9 not available)" + return 0 + fi + echo "bootstrap-selfhost-lib-spine-vm-smoke (BOOTSTRAP_LIB_SPINE_VM_SMOKE_GATE=1, issue #1846)..." + "$_CI_SCRIPT_DIR/bootstrap-selfhost-lib-spine-vm-smoke.sh" +} + # M4 bootstrap-loop dry-run probe (issue #1777, #1498); default off until M3 strict is stable. ci_run_bootstrap_loop_probe() { if [[ "${BOOTSTRAP_LOOP_PROBE_GATE:-0}" != "1" ]]; then diff --git a/script/ci-defaults.env b/script/ci-defaults.env index 1577e38f560..c13539a69f9 100755 --- a/script/ci-defaults.env +++ b/script/ci-defaults.env @@ -21,6 +21,7 @@ export DEPLOY_SMOKE_GATE="${DEPLOY_SMOKE_GATE:-1}" export DEPLOY_SMOKE_003_EXECUTE="${DEPLOY_SMOKE_003_EXECUTE:-1}" # default on (#1530) export BOOTSTRAP_SELFHOST_PROBE_UPDATE="${BOOTSTRAP_SELFHOST_PROBE_UPDATE:-0}" export BOOTSTRAP_LOOP_PROBE_GATE="${BOOTSTRAP_LOOP_PROBE_GATE:-0}" +export BOOTSTRAP_LIB_SPINE_VM_SMOKE_GATE="${BOOTSTRAP_LIB_SPINE_VM_SMOKE_GATE:-0}" export CAPABILITY_SYNTAX_CHECK="${CAPABILITY_SYNTAX_CHECK:-1}" export M2_SPINE_ISSUE_HYGIENE_GATE="${M2_SPINE_ISSUE_HYGIENE_GATE:-1}" # default on (#1819); opt-out for bulk spine PRs export WAVE3_ROADMAP_SYNC_GATE="${WAVE3_ROADMAP_SYNC_GATE:-1}" # default on (#1814); opt-out WAVE3_ROADMAP_SYNC_GATE=0 for doc-only iteration diff --git a/script/ci-local.sh b/script/ci-local.sh index 72b60c2b160..e5aa1ae3cb3 100755 --- a/script/ci-local.sh +++ b/script/ci-local.sh @@ -65,6 +65,7 @@ if ci_llvm_ready; then ci_run_bootstrap_aot_lint BOOTSTRAP_SELFHOST_PROBE_GATE="${BOOTSTRAP_SELFHOST_PROBE_GATE:-1}" ci_run_bootstrap_selfhost_probe ci_run_bootstrap_loop_probe + ci_run_bootstrap_lib_spine_vm_smoke if ci_should_run_jit; then echo "PHPUnit: AOT lint only (@group aot-lint)..." diff --git a/src/cli_driver.php b/src/cli_driver.php index 76c7b30557c..a2bf022a123 100644 --- a/src/cli_driver.php +++ b/src/cli_driver.php @@ -16,6 +16,7 @@ function php_compiler_cli_should_skip_entry_driver(): bool if ( (defined('PHP_COMPILER_LIB_SPINE_SMOKE') && PHP_COMPILER_LIB_SPINE_SMOKE) || php_compiler_cli_should_skip_entry_driver() + || ('1' === getenv('PHP_COMPILER_VM_SPINE_SMOKE') || 'true' === strtolower((string) getenv('PHP_COMPILER_VM_SPINE_SMOKE'))) ) { return; } diff --git a/test/selfhost/compiler_lib_spine_smoke/main.php b/test/selfhost/compiler_lib_spine_smoke/main.php index 64bdec8b29c..8259b472c70 100644 --- a/test/selfhost/compiler_lib_spine_smoke/main.php +++ b/test/selfhost/compiler_lib_spine_smoke/main.php @@ -6,6 +6,7 @@ * M2 lib spine smoke: compiler_minimal closure plus vm.php-path lib and ext/standard units (issue #1056). * Gate: php bin/compile.php -l test/selfhost/compiler_lib_spine_smoke/main.php * Native: ./script/bootstrap-selfhost-lib-spine-smoke-link.sh + * VM -r: ./script/bootstrap-selfhost-lib-spine-vm-smoke.sh (#1846) */ require_once __DIR__.'/../../../lib/AOT/ProjectGraph.php'; @@ -593,5 +594,11 @@ require_once __DIR__.'/../../../src/yay-php8-compat.php'; // src/cli.php + compat shims — deferred (#1467): String_.php JIT link failure when bundled; cli_driver split ready for M4. // bin/vm.php — deferred (#1423 M4): entry pulls src/cli.php + vendor/autoload argv driver; bundle vm_run_smoke.php instead. +require_once __DIR__.'/../../../test/bootstrap-aot/vm_run_smoke.php'; -echo "compiler_lib_spine_smoke bundle OK\n"; +$vmSpineSmoke = getenv('PHP_COMPILER_VM_SPINE_SMOKE'); +if ('1' === $vmSpineSmoke || 'true' === strtolower((string) $vmSpineSmoke)) { + vm_run_smoke('Command line code', 'assertFileExists($script); + $this->assertFileIsReadable($script); + } + + public function testVmSpineSmokeScriptDocumentsEnvAndArtifact(): void + { + $script = (string) file_get_contents(self::$root.'/script/bootstrap-selfhost-lib-spine-vm-smoke.sh'); + $this->assertStringContainsString('PHP_COMPILER_VM_SPINE_SMOKE=1', $script); + $this->assertStringContainsString('selfhost-lib-spine-smoke', $script); + $this->assertStringContainsString('vm-spine-ok', $script); + $this->assertStringContainsString('bootstrap-selfhost-lib-spine-smoke-link.sh', $script); + } + + public function testSpineEntryBundlesVmRunSmoke(): void + { + $entry = (string) file_get_contents(self::$root.'/test/selfhost/compiler_lib_spine_smoke/main.php'); + $this->assertStringContainsString('vm_run_smoke.php', $entry); + $this->assertStringContainsString('PHP_COMPILER_VM_SPINE_SMOKE', $entry); + $this->assertStringContainsString('vm-spine-ok', $entry); + } + + public function testMakefileDefinesVmSpineSmokeTarget(): void + { + $makefile = (string) file_get_contents(self::$root.'/Makefile'); + $this->assertStringContainsString('bootstrap-selfhost-lib-spine-vm-smoke:', $makefile); + } + + public function testCliDriverSkipsArgvWhenVmSpineSmoke(): void + { + $driver = (string) file_get_contents(self::$root.'/src/cli_driver.php'); + $this->assertStringContainsString('PHP_COMPILER_VM_SPINE_SMOKE', $driver); + } + + public function testWaveCheckDocumentsVmSpineSmokeFlag(): void + { + $script = (string) file_get_contents(self::$root.'/script/bootstrap-wave-check.sh'); + $this->assertStringContainsString('--with-lib-spine-vm-smoke', $script); + $this->assertStringContainsString('BOOTSTRAP_LIB_SPINE_VM_SMOKE', $script); + } +}