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 @@ -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
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions docs/bootstrap-selfhost.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)) |
Expand Down
33 changes: 33 additions & 0 deletions script/bootstrap-selfhost-lib-spine-vm-smoke.sh
Original file line number Diff line number Diff line change
@@ -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}"
12 changes: 12 additions & 0 deletions script/bootstrap-wave-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
;;
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions script/ci-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions script/ci-defaults.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions script/ci-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)..."
Expand Down
1 change: 1 addition & 0 deletions src/cli_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 8 additions & 1 deletion test/selfhost/compiler_lib_spine_smoke/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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', '<?php echo "vm-spine-ok\n";', []);
} else {
echo "compiler_lib_spine_smoke bundle OK\n";
}
61 changes: 61 additions & 0 deletions test/unit/BootstrapLibSpineVmSmokeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

namespace PHPCompiler;

use PHPUnit\Framework\TestCase;

/** @group aot-lint */
final class BootstrapLibSpineVmSmokeTest extends TestCase
{
private static string $root;

public static function setUpBeforeClass(): void
{
self::$root = dirname(__DIR__, 2);
}

public function testVmSpineSmokeScriptExists(): void
{
$script = self::$root.'/script/bootstrap-selfhost-lib-spine-vm-smoke.sh';
$this->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);
}
}