Repository navigation
v8: fix cross-compiled aarch64 wee8 snapshot targeting wrong ISA (x86_64 blob in arm64 lib) - #5179
Conversation
✅ Deploy Preview for nifty-bassi-e26446 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
phlax
left a comment
There was a problem hiding this comment.
code looks good - can we cut the comments down a bit
also wondering if we need the fallback - this will all be published together i think
| # until a release is cut with the corrected artifact and //:versions.bzl is | ||
| # bumped, then restore the line below: | ||
| # ":linux_aarch64": "@%s//:wee8" % wee8_prebuilt_repo_name("aarch64"), | ||
| ":linux_aarch64": "@v8//:wee8", |
There was a problem hiding this comment.
i think we shouldnt need this - or is this for toolshed testing?
There was a problem hiding this comment.
Agreed — dropped it. It wasn't needed for toolshed testing (CI builds the wee8 artifacts from source via //v8:wee8_packages, not through this alias), and as you say it publishes together: once this fix merges, the next bins release rebuilds the aarch64 artifact and _release.yml auto-bumps versions.bzl's wee8_sha256 in the same commit. Reverted bazel/v8/BUILD to main, so the PR is now just the wee8_package.bzl fix.
| # as x86_64), which segfaults the instant V8 calls a builtin on real arm64 | ||
| # hardware (observed as the wee8_compile_tool SIGSEGV in Envoy arm64 CI). Pinning | ||
| # the flag to the target ISA makes mksnapshot emit the correct arch. See | ||
| # https://github.com/envoyproxy/toolshed/pull/5177. |
There was a problem hiding this comment.
lets make this comment a bit briefer
There was a problem hiding this comment.
Trimmed to 4 lines.
The prebuilt aarch64 libwee8.a shipped an x86_64 builtins snapshot embedded inside an otherwise-correct AArch64 library, so wee8_compile_tool (and any V8 consumer) SIGSEGVs on the first builtin call on real arm64 (the arm64 CI segfault in envoyproxy/envoy#47108). The wee8 packaging transition set only //command_line_option:platforms for the target arch, not V8's @v8//bazel/config:v8_target_cpu. V8's mksnapshot runs as an exec (build-host) tool but emits code for the ISA its v8_target_cpu_transition resolves, which falls back to mapping[--cpu] when the flag is "none". We never set --cpu, so on an x86_64 build host it resolved to x64 and mksnapshot emitted an x86_64 embedded blob. Set @v8//bazel/config:v8_target_cpu on the transition to the target ISA (aarch64->arm64, x86_64->x64). Validated by rebuilding the aarch64 archive and disassembling v8_Default_embedded_blob_code_ in embedded.pic.o: now AArch64 (2638 ret, 4162 stp x29,x30 prologues, 6435 nops on the 4-byte grid; x86 REX.W byte share fell from 4.3% to 0.26%), versus pure x86_64 before. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Dario Cillerai <[email protected]>
aa931c3 to
7fbdb37
Compare
v8: fix the aarch64 wee8 prebuilt (x86_64 snapshot in an AArch64 library)
Supersedes #5177 (which only added the source fallback). This PR fixes the underlying build defect and keeps the interim fallback until a corrected artifact is released.
Root cause
The published aarch64
libwee8.aembeds an x86_64 builtins snapshot inside an otherwise-correct AArch64 library. Every object member is clean AArch64, but the embedded blobv8_Default_embedded_blob_code_inembedded.pic.ois x86_64 machine code. On real arm64 hardware V8 finishes snapshot setup and jumps into x86_64 bytes on the first builtin call (while compiling the.wasmfixture) →SIGSEGV, no V8CHECK/backtrace. This is thewee8_compile_tool failed: (Segmentation fault)in envoyproxy/envoy#47108 arm64 CI.Why it shipped: the wee8 packaging transition set only
//command_line_option:platformsfor the target arch, not V8's@v8//bazel/config:v8_target_cpu. V8'smksnapshotruns as an exec (build-host) tool but emits code for the ISA itsv8_target_cpu_transitionresolves, which falls back tomapping[--cpu]when that flag is"none"(the default). We never set--cpu, so on the x86_64 build host it resolved tox64and mksnapshot emitted an x86_64 embedded blob. The release pipeline's symbol-count /.o-arch checks don't inspect blob content, so it passed.Fix
Set
@v8//bazel/config:v8_target_cpuon the wee8 transition to the target ISA (aarch64→arm64,x86_64→x64) so mksnapshot emits the correct arch.Validation (no arm64 hardware needed)
Rebuilt the aarch64 archive and disassembled
v8_Default_embedded_blob_code_in the freshembedded.pic.o:ret(c0 03 5f d6)stp x29,x30prologuenopon 4-byte grid0x48) byte shareFirst bytes now decode as a textbook AArch64 epilogue (
ldp x29,x30,[sp],#16 ; ret), versus an x86-64 XMM-save prologue before.Sequencing
The build fix corrects future artifacts; the currently-published prebuilt (
bins-v0.2.12) still contains the broken snapshot. So the aarch64 alias keeps the from-source fallback here. Once a release is cut with the corrected artifact and//:versions.bzlis bumped, a follow-up can restore":linux_aarch64"to the prebuilt.