Skip to content

v8: fall back to from-source wee8 on aarch64 (prebuilt segfaults) - #5177

Closed
dcillera wants to merge 1 commit into
envoyproxy:mainfrom
dcillera:fix-aarch64
Closed

dcillera wants to merge 1 commit into
envoyproxy:mainfrom
dcillera:fix-aarch64

Conversation

@dcillera

@dcillera dcillera commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

The cross-compiled aarch64 prebuilt libwee8.a is currently runtime-broken: it makes wee8_compile_tool segfault when compiling .wasm fixtures. This surfaces in Envoy's arm64 release CI:

ERROR: test/extensions/common/wasm/test_data/BUILD:13:17: Action
  test/extensions/common/wasm/test_data/test_rust.wasm failed:
  (Segmentation fault): wee8_compile_tool failed
  bazel-out/aarch64-opt/bin/test/tools/wee8_compile/wee8_compile_tool ...

There is no downstream lever to scope a fallback: arm64 release runs natively under the same --config as x64, so the consumer (Envoy) has no per-cpu .bazelrc hook to redirect the engine only on aarch64. The fix has to live here.

Change

Point the //v8:wee8 alias' :linux_aarch64 case at @v8//:wee8 (build V8 from source, like //conditions:default) until the aarch64 artifact is repaired. The x86_64 libcxx/libstdcxx prebuilts are unaffected. The prior line is preserved in a comment for easy restoration once the artifact is fixed.

Verification

bazel query --enable_bzlmod --noenable_workspace 'labels(actual, //v8:wee8)' now resolves to:

@wee8_prebuilt_x86_64//:wee8
@wee8_prebuilt_x86_64_libstdcxx//:wee8
@v8//:wee8

— the aarch64 prebuilt is no longer referenced; aarch64 falls back to from-source.

Follow-up

Repair the cross-compiled aarch64 libwee8.a so wee8_compile_tool runs correctly on arm64, then restore the commented :linux_aarch64 prebuilt line.

🤖 Generated with Claude Code

The cross-compiled aarch64 prebuilt libwee8.a is runtime-broken: it makes
wee8_compile_tool segfault when compiling .wasm fixtures, which fails Envoy's
arm64 release CI (native arm64 run, same --config as x64, so there is no
per-cpu .bazelrc hook to scope a fallback downstream).

Point the //v8:wee8 alias' :linux_aarch64 case at @v8//:wee8 so aarch64 builds
V8 from source (like //conditions:default) until the artifact is repaired. The
x86_64 libcxx/libstdcxx prebuilts are unaffected. The prior line is preserved in
a comment for easy restoration once the aarch64 artifact is fixed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Dario Cillerai <[email protected]>
@netlify

netlify Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for nifty-bassi-e26446 ready!

Name Link
🔨 Latest commit aa2a386
🔍 Latest deploy log https://app.netlify.com/projects/nifty-bassi-e26446/deploys/6a97fa16e329f40008f08572
😎 Deploy Preview https://deploy-preview-5177--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.

@dcillera

dcillera commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Root cause confirmed: the aarch64 prebuilt embeds an x86-64 builtins snapshot

Following up on "until the artifact is repaired" — I ran static ELF forensics on the published aarch64 artifact and the defect is now pinned down.

Artifact: bins-v0.2.12 → v8-wee8-14.6.202.10-linux-aarch64.tar.xz (sha256 71d27770a30391df779acd04ed462066560dc1687531484d9aef1f7894fdf424).

Finding: the library is not arch-contaminated at the object level — all 1154 .o members are clean ELF … AArch64. The problem is one layer deeper, in V8's embedded snapshot. The symbol v8_Default_embedded_blob_code_ in embedded.pic.o (2,156,288 bytes of raw machine code V8 executes for every builtin) is x86-64, not AArch64:

first bytes: 48 81 ec 00 01 00 00  f3 48 0f 7f 04 24 ...
  →  sub    rsp,0x100
     movdqu XMMWORD PTR [rsp],      xmm0
     movdqu XMMWORD PTR [rsp+0x10], xmm1
     ...   (a classic x86-64 XMM-save prologue)

Whole-blob (2 MB) instruction-set fingerprint:

signature AArch64 x86-64
ret 0 9,436 (0xc3)
prologue (stp x29,x30 / push rbp) 0 7,985
nop on 4-byte grid 0 —
REX.W prefix (0x48) — 91,899 (4.3% of bytes)
call (0xe8) — 20,313

So it's arm64 C++ objects wrapping an x86-64 embedded-builtins blob. On real arm64 hardware V8 finishes Isolate/snapshot setup and, on the first call into a builtin (which happens while compiling the .wasm fixture), the CPU jumps into x86-64 bytes → SIGSEGV, with no V8 CHECK/backtrace — exactly the wee8_compile_tool failed: (Segmentation fault) seen in Envoy's arm64 release CI (envoyproxy/envoy#47108).

Why it shipped: the cross-build compiled V8's C++ for arm64 (V8_TARGET_ARCH_ARM64 define correct) but ran mksnapshot as the x86-64 host binary emitting x86-64 builtins. The release pipeline's symbol-count and .o-arch checks both pass because neither inspects the content of the embedded blob.

To repair the artifact (so aarch64 can go back to the prebuilt):

  1. Rebuild the aarch64 wee8 with mksnapshot generating arm64 code — build mksnapshot with v8_target_cpu="arm64" codegen, or run it under emulation.
  2. Add a release-pipeline gate that disassembles/fingerprints v8_Default_embedded_blob_code_ and asserts it is AArch64 before publishing (a symbol-count check is not sufficient — it never inspects the blob).

Until that lands, this PR's from-source fallback on aarch64 is the correct fix.

@dcillera

dcillera commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #5179, which fixes the underlying build defect (the wee8 transition now sets @v8//bazel/config:v8_target_cpu so mksnapshot emits the target ISA instead of an x86_64 snapshot) and keeps this source fallback as the interim until a corrected artifact is released. Closing in favour of #5179.

@dcillera dcillera closed this Sep 2, 2026
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