Skip to content

deps: rebuild V8 without sandbox (enables zero-copy ArrayBuffer)#7

Merged
yneves merged 11 commits into
mainfrom
rebuild-v8-deps-no-sandbox
May 20, 2026
Merged

deps: rebuild V8 without sandbox (enables zero-copy ArrayBuffer)#7
yneves merged 11 commits into
mainfrom
rebuild-v8-deps-no-sandbox

Conversation

@yneves
Copy link
Copy Markdown
Collaborator

@yneves yneves commented May 19, 2026

Summary

  • Rebuilt V8 monolith for all 4 platforms with v8_enable_sandbox=false
  • Removed -DV8_ENABLE_SANDBOX from cgo.go
  • Added local dep modules under deps/{os}_{arch}/ with replace directives
  • SandboxEnabled() now returns false
  • NewArrayBufferExternal uses true zero-copy (no memcpy fallback)

Build sources

Platform Method
linux/amd64 CI (build-v8-deps workflow)
linux/arm64 CI (cross-compile x86→arm64, sysroot + custom libcxx)
darwin/arm64 CI (native)
darwin/amd64 Local (cross-compile arm64→x64, patched find_sdk.py + custom libcxx)

Test plan

  • All tests pass locally (go test ./...)
  • TestNewArrayBufferExternal_SharedMemory no longer skipped
  • TestNewArrayBufferExternal_JSWritesGoMemory no longer skipped
  • CI passes (unit tests on both OS)
  • Downstream compat (blindfox, er) still builds

yneves added 11 commits May 19, 2026 18:17
Rebuilt from V8 commit 5297e56d91816747d539abca52b578e5832135f0
with v8_enable_sandbox=false for all 4 platforms:
- linux/amd64 (CI)
- linux/arm64 (CI cross-compile with sysroot + custom libcxx)
- darwin/arm64 (CI)
- darwin/amd64 (local cross-compile from arm64)

Removes -DV8_ENABLE_SANDBOX from cgo.go so NewArrayBufferExternal
uses the true zero-copy path (no memcpy fallback).

Adds local dep modules under deps/{os}_{arch}/ with replace
directives in go.mod.
GNU ld on Ubuntu rejects llvm-ar's 64-bit symbol table format
when using -L/-l flags ('skipping incompatible'). Pass archives
as direct paths instead, which forces the linker to read them
regardless of symbol table format.
V8's clang enables ThinLTO by default in release builds, producing
LLVM bitcode objects that GNU ld cannot link. Add use_thin_lto=false
to both the CI workflow and local build script.
llvm-ar produces archives in a format GNU ld cannot read
('unknown architecture'). Use system ar for Linux targets
which produces compatible GNU-format archives.
V8's clang produces ELF objects with features GNU ld cannot parse
('unknown architecture'). Use LLVM's lld linker via -fuse-ld=lld
for Linux targets. Install lld in CI.
…ves)

CGo's security policy rejects -fuse-ld=lld in #cgo LDFLAGS.
Set it via CGO_LDFLAGS environment variable in CI instead.
V8's clang produces ELF objects with features GNU ld cannot parse.
Use system gcc for the native linux/amd64 build to produce
standard GNU-compatible ELF objects. Keep clang for cross-compile
targets (linux/arm64, darwin/*) where it's required.

Revert lld workaround — not needed with gcc objects.
Rebuilt with is_clang=false to produce standard GNU ELF objects
compatible with GNU ld.
Instead of passing -fuse-ld=lld via CGO_LDFLAGS (which causes
segfaults), install lld and make it the default ld via
update-alternatives. Restore clang-built V8 archives.
Use gcc-built V8 archives (GNU ld compatible) with
--start-group/--end-group to resolve cross-archive dependencies.
Remove lld workaround.
@yneves yneves self-assigned this May 20, 2026
@yneves yneves merged commit 76df82b into main May 20, 2026
2 checks passed
@yneves yneves deleted the rebuild-v8-deps-no-sandbox branch May 20, 2026 11:23
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