Skip to content

v8: fix cross-compiled aarch64 wee8 snapshot targeting wrong ISA (x86_64 blob in arm64 lib) - #5179

Merged
phlax merged 1 commit into
envoyproxy:mainfrom
dcillera:wee8-aarch64-snapshot-fix
Sep 2, 2026
Merged

phlax merged 1 commit into
envoyproxy:mainfrom
dcillera:wee8-aarch64-snapshot-fix

Conversation

@dcillera

@dcillera dcillera commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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.a embeds an x86_64 builtins snapshot inside an otherwise-correct AArch64 library. Every object member is clean AArch64, but the embedded blob v8_Default_embedded_blob_code_ in embedded.pic.o is 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 .wasm fixture) → SIGSEGV, no V8 CHECK/backtrace. This is the wee8_compile_tool failed: (Segmentation fault) in envoyproxy/envoy#47108 arm64 CI.

Why it shipped: 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 that flag is "none" (the default). We never set --cpu, so on the x86_64 build host it resolved to x64 and 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_cpu on 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 fresh embedded.pic.o:

signature before (published) after (this PR)
AArch64 ret (c0 03 5f d6) 0 2,638
AArch64 stp x29,x30 prologue 0 4,162
AArch64 nop on 4-byte grid 0 6,435
x86 REX.W (0x48) byte share 4.3% 0.26% (incidental)

First 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.bzl is bumped, a follow-up can restore ":linux_aarch64" to the prebuilt.

@netlify

netlify Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for nifty-bassi-e26446 ready!

Name Link
🔨 Latest commit 7fbdb37
🔍 Latest deploy log https://app.netlify.com/projects/nifty-bassi-e26446/deploys/6a9834e9223ab10008c4c99d
😎 Deploy Preview https://deploy-preview-5179--nifty-bassi-e26446.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@phlax phlax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread bazel/v8/BUILD Outdated
# 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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we shouldnt need this - or is this for toolshed testing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread bazel/v8/wee8_package.bzl Outdated
# 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this comment a bit briefer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@dcillera
dcillera force-pushed the wee8-aarch64-snapshot-fix branch from aa931c3 to 7fbdb37 Compare September 2, 2026 14:38

@phlax phlax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @dcillera

@phlax
phlax merged commit ea151c1 into envoyproxy:main Sep 2, 2026
61 checks passed
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.

2 participants