Skip to content

Fix hash crypto LLVM IR validation for bootstrap-aot-link (#7189) - #8500

Merged
PurHur merged 1 commit into
masterfrom
agent/bootstrap-aot-link-hash-crypto-ir-lane-b
Jun 14, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/bootstrap-aot-link-hash-crypto-ir-lane-b

Conversation

@PurHur

@PurHur PurHur commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Lane B bootstrap fallback — no eligible compile/link issue in lane (# % 3 == 1 without stdlib/php-runtime ownership; 1000 open issues scanned).

make bootstrap-aot-link was red: hash()/hash_hmac() AOT compile failed LLVM module verify in StringHashCryptoNativeJit (#7189 / #7437).

Fixes in lib/JIT/Builtin/StringHashCryptoNativeJit.php:

  • Align __phpc_hc_sha256_transform / __phpc_hc_sha1_transform external decls with emitters (i32* state, not i8*)
  • u32() uses zExtOrBitCast (was truncOrBitCast on i8 md5 block loads)
  • HKDF: compute infoData/infoLen in body block; init loop slots after positionAtEnd($loopHead) (dominance)
  • HMAC xor + PBKDF2 F xor: truncate i32 xor to i8 before store
  • emitCompilerHashHmac bad-algo path: ValueError + sealOpenBlock (parity with emitCompilerHash)
  • i32 index → i64 gep: zExtOrBitCast throughout digest update loops

Verification

# IR verify + compile (was: Module verification failed)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/compile.php -o /tmp/test_md5 -r "echo hash(\"md5\", \"x\");"
/tmp/test_md5'
# 85dc13cc07bad5da979ec35911792e76

# JIT hash + hmac
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/jit.php -r "echo hash(\"md5\", \"x\"); echo hash_hmac(\"sha256\", \"bootstrap\", \"secret\");"'
# 9dd4e461268c8034f5c8564e155c67a687556723e465a154c47b66fcccb32a33c4be5af9c6ca0b8165b203b3a9557c11

# bootstrap hash fixture — compile now succeeds (was: compile failed)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
PHP_COMPILER_BOOTSTRAP_AOT_LINK=1 php bin/compile.php -o /tmp/sh test/bootstrap-aot/stdlib_hash.php'

vendor/bin/phpunit test/unit/JIT/StringHashCryptoRuntimeStandaloneTest.php
# OK (2 tests)

Follow-up: AOT runtime digest for hash("md5", …) still returns wrong bytes + segfault on hash_hmac in native binary (VM/JIT OK). make bootstrap-aot-link compile phase unblocked; full gate still red on unrelated targets + AOT digest runtime.

Relates to #7189, #7437, #1492.

Made with Cursor

Correct StringHashCryptoNativeJit helper signatures (sha256/sha1 transform
i32* state), zExt/trunc casts, HKDF infoData dominance, HMAC/PBKDF2 i8
stores, and emitCompilerHashHmac bad-algo path — unblocks AOT compile of
hash()/hash_hmac() call sites that previously failed module verify.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit ff5e490 into master Jun 14, 2026
@PurHur
PurHur deleted the agent/bootstrap-aot-link-hash-crypto-ir-lane-b branch June 14, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant