From 36d346522790a33141ce25ba5d8013de83ca6daa Mon Sep 17 00:00:00 2001 From: PurHur Date: Fri, 22 May 2026 16:37:13 +0200 Subject: [PATCH] Add bootstrap AOT lint target for require_once chain (#120) Introduce test/bootstrap-aot/require_chain/ and auto-discover test/bootstrap-aot/*/main.php in bootstrap-profile for multi-file chains. Co-authored-by: Cursor --- docs/bootstrap-profile.json | 19 ++++++++++++++----- docs/bootstrap-selfhost.md | 5 +++-- script/bootstrap-lib.php | 4 ++++ test/bootstrap-aot/require_chain/helper.php | 13 +++++++++++++ test/bootstrap-aot/require_chain/main.php | 8 ++++++++ test/unit/BootstrapProfileTest.php | 1 + 6 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 test/bootstrap-aot/require_chain/helper.php create mode 100644 test/bootstrap-aot/require_chain/main.php diff --git a/docs/bootstrap-profile.json b/docs/bootstrap-profile.json index 604465d7..dda5d615 100644 --- a/docs/bootstrap-profile.json +++ b/docs/bootstrap-profile.json @@ -296,6 +296,7 @@ "lib/Lint/UnsupportedRegistry.php", "lib/Module.php", "lib/ModuleAbstract.php", + "lib/NullSafeLivenessDetector.php", "lib/OpCode.php", "lib/Printer.php", "lib/Runtime.php", @@ -330,27 +331,35 @@ ], "aot_lint_targets": [ "examples/000-HelloWorld/example.php", + "test/bootstrap-aot/class_const_fetch.php", "test/bootstrap-aot/class_constants.php", "test/bootstrap-aot/class_nullable_property.php", "test/bootstrap-aot/echo_hello.php", + "test/bootstrap-aot/instanceof_check.php", "test/bootstrap-aot/minimal_class.php", "test/bootstrap-aot/namespace_hello.php", "test/bootstrap-aot/nullable_types.php", + "test/bootstrap-aot/require_chain/main.php", "test/bootstrap-aot/throw_logic.php" ], "aot_link_targets": [ "examples/000-HelloWorld/example.php", + "test/bootstrap-aot/class_const_fetch.php", + "test/bootstrap-aot/class_constants.php", "test/bootstrap-aot/class_nullable_property.php", "test/bootstrap-aot/echo_hello.php", + "test/bootstrap-aot/instanceof_check.php", "test/bootstrap-aot/minimal_class.php", "test/bootstrap-aot/namespace_hello.php", - "test/bootstrap-aot/nullable_types.php" + "test/bootstrap-aot/nullable_types.php", + "test/bootstrap-aot/require_chain/main.php", + "test/bootstrap-aot/throw_logic.php" ], "totals": { - "inventory_files": 299, + "inventory_files": 300, "excluded": 2, - "eligible": 297, - "aot_lint_targets": 8, - "aot_link_targets": 8 + "eligible": 298, + "aot_lint_targets": 11, + "aot_link_targets": 11 } } diff --git a/docs/bootstrap-selfhost.md b/docs/bootstrap-selfhost.md index 30374e1d..45717bfe 100644 --- a/docs/bootstrap-selfhost.md +++ b/docs/bootstrap-selfhost.md @@ -23,7 +23,7 @@ Regenerate: `make bootstrap-profile` (inventory + profile + optional `bootstrap- ## Bootstrap AOT lint ladder -Add scripts under `test/bootstrap-aot/*.php` — picked up automatically by `script/bootstrap-profile.php` ([#514](https://github.com/PurHur/php-compiler/issues/514)): +Add scripts under `test/bootstrap-aot/*.php` — picked up automatically by `script/bootstrap-profile.php` ([#514](https://github.com/PurHur/php-compiler/issues/514)). Multi-file `require_once` chains: `test/bootstrap-aot//main.php` (helpers alongside; issue [#120](https://github.com/PurHur/php-compiler/issues/120)): - `echo_hello.php` — baseline procedural - `nullable_types.php` — `?string` parameters (self-host typing) @@ -31,8 +31,9 @@ Add scripts under `test/bootstrap-aot/*.php` — picked up automatically by `scr - `minimal_class.php` — one public method (ClassMethod lowering) - `class_nullable_property.php` — nullable property with `= null` default - `class_constants.php` — class `Const_` declarations (issue #84) +- `require_chain/main.php` — `require_once` helper with shared functions (issue #120) -`php bin/compile.php -l lib/OpCode.php` passes after `TYPE_DECLARE_CLASS_CONST` lowering; `lib/Frame.php` still needs namespaces. Next: `require_once` chain ([#120](https://github.com/PurHur/php-compiler/issues/120)). +`php bin/compile.php -l lib/OpCode.php` passes after `TYPE_DECLARE_CLASS_CONST` lowering; `lib/Frame.php` still needs namespaces. ## Non-goals (initial bootstrap) diff --git a/script/bootstrap-lib.php b/script/bootstrap-lib.php index 70d7eaff..dd6e65ca 100644 --- a/script/bootstrap-lib.php +++ b/script/bootstrap-lib.php @@ -212,6 +212,10 @@ function bootstrapDefaultAotLintTargets(string $root): array foreach (glob($root.'/test/bootstrap-aot/*.php') ?: [] as $path) { $targets[] = substr($path, strlen($root) + 1); } + // Multi-file chains: test/bootstrap-aot//main.php (issue #120). + foreach (glob($root.'/test/bootstrap-aot/*/main.php') ?: [] as $path) { + $targets[] = substr($path, strlen($root) + 1); + } sort($targets, SORT_STRING); return array_values(array_unique($targets)); diff --git a/test/bootstrap-aot/require_chain/helper.php b/test/bootstrap-aot/require_chain/helper.php new file mode 100644 index 00000000..3cbbb85e --- /dev/null +++ b/test/bootstrap-aot/require_chain/helper.php @@ -0,0 +1,13 @@ +assertContains('test/bootstrap-aot/class_nullable_property.php', $profile['aot_lint_targets']); $this->assertContains('test/bootstrap-aot/class_constants.php', $profile['aot_lint_targets']); $this->assertContains('test/bootstrap-aot/throw_logic.php', $profile['aot_lint_targets']); + $this->assertContains('test/bootstrap-aot/require_chain/main.php', $profile['aot_lint_targets']); $this->assertContains('lib/AOT/Linker.php', $profile['excluded_files']); }