diff --git a/Makefile b/Makefile index 426d2df26c1..a1749912310 100755 --- a/Makefile +++ b/Makefile @@ -375,6 +375,8 @@ bootstrap-gen0-refresh-argv-driver: ./script/bootstrap-gen0-refresh-argv-driver.sh helper-runtime-prelink-refresh: php script/emit-helper-runtime-object.php --prelink +helper-runtime-common-publish: + php script/emit-helper-runtime-common.php --from-prelinked helper-runtime-prelink-check: php script/check-helper-runtime-prelink.php bootstrap-init: diff --git a/lib/AOT/HelperRuntimeCommon.php b/lib/AOT/HelperRuntimeCommon.php index 00ec201c327..c9396227479 100644 --- a/lib/AOT/HelperRuntimeCommon.php +++ b/lib/AOT/HelperRuntimeCommon.php @@ -14,7 +14,7 @@ */ final class HelperRuntimeCommon { - /** Opt-in: PHP_COMPILER_HELPER_RUNTIME_COMMON=1 */ + /** Opt-in until units are re-emitted with AotGcSections: PHP_COMPILER_HELPER_RUNTIME_COMMON=1 */ public const ENV = 'PHP_COMPILER_HELPER_RUNTIME_COMMON'; /** @@ -129,8 +129,8 @@ public static function publishManifestMetadata(string $objectPath, string $bitco 'arch' => HelperRuntimeCache::archKey(), 'role' => 'committed per-arch split-compilation helper units (#15889)', ]; - $manifest['core_fingerprint'] = HelperRuntimeCache::coreFingerprint(); - $manifest['llvm_identity_token'] = HelperRuntimeCache::llvmIdentityToken(); + // Preserve arch-level fields written by --prelink (unit_count, total_bytes, …). + // Only refresh common.o metadata; do not rewrite core_fingerprint here (#36246). $manifest['common_object_sha256'] = hash_file('sha256', $objectPath) ?: ''; $manifest['common_object_bytes'] = is_file($objectPath) ? filesize($objectPath) : 0; $manifest['common_bitcode_bytes'] = is_file($bitcodePath) ? filesize($bitcodePath) : 0; diff --git a/prelinked/helper-runtime/x86_64-linux/common.bc b/prelinked/helper-runtime/x86_64-linux/common.bc new file mode 100644 index 00000000000..c070bd8ccb6 Binary files /dev/null and b/prelinked/helper-runtime/x86_64-linux/common.bc differ diff --git a/prelinked/helper-runtime/x86_64-linux/common.o b/prelinked/helper-runtime/x86_64-linux/common.o new file mode 100644 index 00000000000..d121dd677fb Binary files /dev/null and b/prelinked/helper-runtime/x86_64-linux/common.o differ diff --git a/prelinked/helper-runtime/x86_64-linux/manifest.json b/prelinked/helper-runtime/x86_64-linux/manifest.json index f7834f38fbf..8b6ae8efc72 100644 --- a/prelinked/helper-runtime/x86_64-linux/manifest.json +++ b/prelinked/helper-runtime/x86_64-linux/manifest.json @@ -9,5 +9,9 @@ "published_fresh": 1, "kept_live_unpublished": 0, "total_bytes": 829020666, - "refresh": "php script/publish-helper-units-prelink.php (targeted dom refresh #32122)" + "refresh": "php script/publish-helper-units-prelink.php (targeted dom refresh #32122)", + "common_object_sha256": "460cc7680f59db5030b3c900629ac91fe8b927a468491c50d634e80a8cc6459c", + "common_object_bytes": 1649928, + "common_bitcode_bytes": 1116, + "common_emitted_at": "2026-09-02T22:19:24+00:00" } diff --git a/script/check-helper-runtime-prelink.php b/script/check-helper-runtime-prelink.php index 31f37b919cb..5f1f6bfde15 100644 --- a/script/check-helper-runtime-prelink.php +++ b/script/check-helper-runtime-prelink.php @@ -19,6 +19,7 @@ */ use PHPCompiler\AOT\HelperRuntimeCache; +use PHPCompiler\AOT\HelperRuntimeCommon; $root = dirname(__DIR__); require $root.'/vendor/autoload.php'; @@ -34,6 +35,7 @@ exit($strict ? 1 : 0); } +$commonBroken = false; if (is_file($archManifestPath)) { $archManifest = json_decode((string) file_get_contents($archManifestPath), true); $committedCore = \is_array($archManifest) ? (string) ($archManifest['core_fingerprint'] ?? '') : ''; @@ -47,6 +49,17 @@ exit(1); } } + $expectedCommonSha = \is_array($archManifest) ? (string) ($archManifest['common_object_sha256'] ?? '') : ''; + if ('' !== $expectedCommonSha) { + $commonPath = HelperRuntimeCommon::commonObjectPath(); + if (!is_file($commonPath)) { + ++$commonBroken; + fwrite(STDOUT, " BROKEN common.o (manifest expects shared runtime prologue)\n"); + } elseif (!HelperRuntimeCommon::commonObjectIsLinkable()) { + ++$commonBroken; + fwrite(STDOUT, " STALE common.o (sha256 or core_fingerprint mismatch)\n"); + } + } } $fresh = 0; @@ -84,12 +97,16 @@ ++$fresh; } +$commonNote = HelperRuntimeCommon::commonObjectIsLinkable() + ? ', common.o fresh' + : (is_file(HelperRuntimeCommon::commonObjectPath()) ? ', common.o stale' : ', common.o absent'); fwrite(STDOUT, sprintf( - "check-helper-runtime-prelink: %s — %d fresh, %d stale, %d broken%s\n", + "check-helper-runtime-prelink: %s — %d fresh, %d stale, %d broken%s%s\n", $arch, $fresh, $stale, $broken, - ($stale + $broken) > 0 ? ' — refresh: php script/emit-helper-runtime-object.php --prelink' : '' + $commonBroken > 0 ? ', common broken' : $commonNote, + ($stale + $broken + $commonBroken) > 0 ? ' — refresh: php script/emit-helper-runtime-object.php --prelink; common: php script/emit-helper-runtime-common.php --from-prelinked' : '' )); -exit($strict && ($stale + $broken) > 0 ? 1 : 0); +exit($strict && ($stale + $broken + $commonBroken) > 0 ? 1 : 0);