Repository navigation
Conversation
Update Bun JSC bindings and generated wrappers for current WebKit APIs so local ARM64 64KB builds complete reliably.
|
Closing because this PR was opened against upstream by mistake; the intended target is my fork repository. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adapts Bun to build and run on Linux ARM64 with 64KB page size against the latest local WebKit, updating numerous JSC binding signatures and adding a fallback path for legacy ELF templates in the standalone module graph.
Changes:
- Update JSC API call sites (e.g.,
JSPromise::resolvenow takesvm, wasm streaming options,addStaticGlobals, GCvisitOutputConstraints/visitAdditionalChildrenmacros, removal ofqueueMicrotaskToEventLoop) and guard JIT-only code withENABLE(JIT)/ENABLE(DFG_JIT). - Build/script changes for 64KB Linux ARM64: enable
USE_64KB_PAGE_BLOCK, disable PCH on Linux, simplify Zig invocation, add-Wno-undefined-var-template. - Add legacy trailer fallback when ELF
.bunsection is absent inStandaloneModuleGraph, and convertJSCTaskSchedulerstorage tounique_ptrto break a header cycle.
Reviewed changes
Copilot reviewed 46 out of 46 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tmp_link_and_test.py | Ad-hoc local link/test script |
| tmp_compile_entry.js | Tiny smoke test entry |
| tmp_build_opencode_musl.sh | Local musl build shell helper |
| src/codegen/generate-classes.ts | Remove stray DEFINE_VISIT_ADDITIONAL_CHILDREN emission |
| src/codegen/bundle-functions.ts | Drop std::size arg from addStaticGlobals call |
| src/bun.js/webview/JSWebView.cpp | Pass vm to JSPromise::resolve |
| src/bun.js/modules/BunJSCModule.h | Guard JIT include and totalCompileTime with ENABLE(JIT) |
| src/bun.js/bindings/webcore/SerializedScriptValue.cpp | Pass addressType to Wasm Memory create |
| src/bun.js/bindings/webcore/JSWorker.cpp | Pass vm to resolve |
| src/bun.js/bindings/webcore/JSPerformanceObserverCustom.cpp | Inline visitOutputConstraints/template instantiations |
| src/bun.js/bindings/webcore/JSPerformance.cpp | Provide non-DFG DOMJIT signature alternative |
| src/bun.js/bindings/webcore/JSMessagePortCustom.cpp | Inline output constraints + instantiations |
| src/bun.js/bindings/webcore/JSMessageEventCustom.cpp | Explicit template instantiations |
| src/bun.js/bindings/webcore/JSMessageEvent.{h,cpp} | Use DECLARE/DEFINE_VISIT_OUTPUT_CONSTRAINTS macros |
| src/bun.js/bindings/webcore/JSMessageChannel{Custom,.h,.cpp} | Same visit-output-constraints macro adoption |
| src/bun.js/bindings/webcore/JSEventTargetCustom.cpp | Inline visitOutputConstraints + instantiations |
| src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp | Same as above |
| src/bun.js/bindings/webcore/JSErrorEventCustom.cpp | Same as above |
| src/bun.js/bindings/webcore/JSDOMPromiseDeferred.cpp | Pass vm to resolve |
| src/bun.js/bindings/webcore/JSAbortSignalCustom.cpp | Explicit template instantiations |
| src/bun.js/bindings/webcore/CustomEventCustom.cpp | Inline visitOutputConstraints + instantiations |
| src/bun.js/bindings/bindings.cpp | Pass vm to resolve calls |
| src/bun.js/bindings/ZigGlobalObject.{h,cpp} | API drift adaptations, wasm streaming options, GC macros, removal of queueMicrotaskToEventLoop |
| src/bun.js/bindings/NodeVMSourceTextModule.cpp | Guard JIT compile path |
| src/bun.js/bindings/NodeVMScript.cpp | Guard JIT compile path; include Watchdog |
| src/bun.js/bindings/NodeVM.cpp | Drop queueTaskToEventLoop slot |
| src/bun.js/bindings/NodeTimerObject.cpp | Pass vm to resolve |
| src/bun.js/bindings/ModuleLoader.cpp | Pass vm to resolve |
| src/bun.js/bindings/JSSecrets.cpp | Pass vm to resolve |
| src/bun.js/bindings/JSMockFunction.cpp | Drop redundant DEFINE_VISIT_ADDITIONAL_CHILDREN |
| src/bun.js/bindings/JSCTaskScheduler.cpp | Dereference unique_ptr scheduler |
| src/bun.js/bindings/JSBundlerPlugin.cpp | Pass vm to resolve |
| src/bun.js/bindings/BunClientData.{h,cpp} | Move scheduler to unique_ptr to break header cycle |
| src/bun.js/bindings/BunAnalyzeTranspiledModule.cpp | Pass vm to resolve |
| src/bake/BakeGlobalObject.cpp | Drop queueMicrotaskToEventLoop slot |
| src/StandaloneModuleGraph.zig | Fallback to legacy trailer when .bun ELF section missing |
| scripts/build/zig.ts | Simplify zig_build rule |
| scripts/build/flags.ts | Add -Wno-undefined-var-template |
| scripts/build/deps/webkit.ts | Enable USE_64KB_PAGE_BLOCK on linux+arm64 |
| scripts/build/bun.ts | Disable PCH on Linux |
| PR_64KB_LINUX_ARM64_BUN.md | PR description doc |
Comments suppressed due to low confidence (2)
tmp_link_and_test.py:1
- This file (along with
tmp_compile_entry.jsandtmp_build_opencode_musl.sh) appears to be a temporary, developer-local script: it hardcodes paths like/workspace,/tmp/libicu,/usr/lib/llvm-21/bin/clang++, and/usr/lib/aarch64-linux-gnu, and is named with atmp_prefix. These artifacts should not be checked into the repository. Please remove them from the PR (or move them under a documented developer-tools location with portable paths) before merging.
src/bun.js/modules/BunJSCModule.h:1 - When
ENABLE(JIT)is true the function returns inside the#if, leaving the trailingreturn ... jsNumber(0)reachable only in the non-JIT build. Some compilers will warn about an unreachable statement after the#endifin JIT builds. Consider using#if ENABLE(JIT) ... #else ... #endifso exactly one return is compiled in each configuration.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Support Linux ARM64 64KB page builds with latest WebKit | ||
|
|
||
| ## 背景 | ||
|
|
||
| 本次改动的目标是让 Bun 在最新本地 WebKit 依赖下,完成 Linux ARM64 64KB page 环境的构建与基础运行验证。 | ||
|
|
||
| 对应分支:`fix-latest-webkit-64kb-linux-arm64` | ||
|
|
||
| 关键提交: | ||
|
|
||
| - `63a02de4f5` `Support local 64KB Linux Bun builds` | ||
| - `bc693e6c8a` `Adapt Bun for latest WebKit 64KB Linux builds` | ||
|
|
||
| ## Summary | ||
|
|
||
| - 补齐 Bun 本地构建链路对 Linux ARM64 64KB page 的支持 | ||
| - 适配最新 WebKit/JSC API 变化,修复 bindings、生成代码和无 JIT 场景的兼容问题 | ||
| - 与配套 WebKit 分支联动后,在 `llm-12` 的 64KB page 环境完成 smoke test | ||
|
|
||
| ## Changes | ||
|
|
||
| ### 构建链路 | ||
|
|
||
| - 在 Linux ARM64 本地 WebKit 构建路径中启用 `USE_64KB_PAGE_BLOCK=ON` | ||
| - 调整 Bun 构建脚本,减少本地 64KB 构建过程中的不稳定因素 | ||
| - 简化 Zig 构建调用路径,避免本地 `--console` / 进度通道带来的异常 | ||
| - 为当前工具链补充 `-Wno-undefined-var-template` | ||
|
|
||
| ### Bun 与最新 WebKit API 适配 | ||
|
|
||
| - 更新 `ZigGlobalObject`、`NodeVM`、`bindings` 等 JSC 接口适配逻辑 | ||
| - 兼容 `JSPromise::resolve(...)`、wasm streaming、static globals、GC visitor/output constraints 的最新签名变化 | ||
| - 修复多处 WebCore custom bindings 与当前 WebKit 生成代码风格的兼容问题 | ||
| - 更新代码生成逻辑,使生成产物与最新 WebKit 的 GC 集成方式一致 | ||
|
|
||
| ### 运行时结果 | ||
|
|
||
| - 结合配套 WebKit 修复后,Bun 可在 Linux ARM64 64KB page 环境执行最小 JS 和基础文件 IO | ||
|
|
||
| ## Validation | ||
|
|
||
| 验证环境:`llm-12` | ||
|
|
||
| ```bash | ||
| uname -m | ||
| getconf PAGE_SIZE | ||
| ``` | ||
|
|
||
| 结果: | ||
|
|
||
| - `uname -m` 输出 `aarch64` | ||
| - `getconf PAGE_SIZE` 输出 `65536` | ||
|
|
||
| 使用本分支与配套 WebKit 分支构建本地产物后,在 `ubuntu:24.04` arm64 容器内验证: | ||
|
|
||
| ```bash | ||
| ./bun --revision | ||
| ./bun --version | ||
| ./bun -e "console.log(process.arch, process.platform, Bun.version)" | ||
| ./bun -e 'await Bun.write("/tmp/a.txt", "ok"); console.log(await Bun.file("/tmp/a.txt").text())' | ||
| ``` | ||
|
|
||
| 结果: | ||
|
|
||
| - `./bun --revision` -> `1.3.11-canary.1+bc693e6c8` | ||
| - `./bun --version` -> `1.3.11` | ||
| - `./bun -e "console.log(process.arch, process.platform, Bun.version)"` -> `arm64 linux 1.3.11` | ||
| - `./bun -e 'await Bun.write("/tmp/a.txt", "ok"); console.log(await Bun.file("/tmp/a.txt").text())'` -> `ok` | ||
|
|
||
| ## Risk/Notes | ||
|
|
||
| - 本 PR 主要覆盖 Linux ARM64 64KB page 场景 | ||
| - Bun 侧改动多数是为了跟进最新 WebKit API 漂移,风险集中在 JSC bindings、WebCore custom bindings 和生成代码 | ||
| - 本 PR 依赖配套 WebKit 分支 `fix/structure-heap-64kb-linux-arm64` |
| const legacy = brk: { | ||
| elf_file.writeBunSection(bytes) catch |err| { | ||
| if (err == error.BunSectionNotFound) { | ||
| break :brk true; | ||
| } |
| @@ -226,7 +226,7 @@ export function emitBun(n: Ninja, cfg: Config, sources: Sources): BunOutput { | |||
| // clang-cl's /Yc//Yu flags exist but the wrapper+stub mechanism here | |||
| // is built around clang's -emit-pch model. If Windows PCH is wanted | |||
| // later, see compile.ts TODO(windows) for what needs wiring. | |||
| void GlobalObject::visitAdditionalChildren(JSCell* cell, Visitor& visitor) | ||
| { | ||
| GlobalObject* thisObject = this; | ||
| auto* thisObject = jsCast<GlobalObject*>(cell); |
| // Default to plain prefix mode for Zig. `--console` and `--zig-progress` | ||
| // both depend on Zig's auxiliary progress channel, while plain mode keeps | ||
| // the invocation simple and has proven more reliable in local builds. | ||
| n.rule("zig_build", { | ||
| command: `${stream} ${consoleMode ? "--console" : "--zig-progress"} --env=ZIG_LOCAL_CACHE_DIR=$zig_local_cache --env=ZIG_GLOBAL_CACHE_DIR=$zig_global_cache $zig build $step $args`, | ||
| command: `${stream} --env=ZIG_LOCAL_CACHE_DIR=$zig_local_cache --env=ZIG_GLOBAL_CACHE_DIR=$zig_global_cache $zig build $step $args`, |
|
|
||
| void* bunVM; | ||
| Bun::JSCTaskScheduler deferredWorkTimer; | ||
| std::unique_ptr<Bun::JSCTaskScheduler> deferredWorkTimer; |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (46)
Disabled knowledge base sources:
WalkthroughAdds Linux ARM64 64KB page build support for Bun with the latest WebKit by updating the build configuration, adapting JSC/WebCore bindings to updated promise resolution and GC visitor patterns, refactoring deferred work timer ownership, and improving build stability. ChangesBuild Configuration for Linux ARM64 64KB Pages
JSC Promise Resolution API Adaptation
Deferred Work Timer Ownership Refactoring
GC Visitor Pattern Modernization
Conditional JIT Compilation Support
WebAssembly Streaming Compilation Options
Linux ELF Module Injection with Fallback
Miscellaneous API and Serialization Updates
Temporary Test and Build Scripts
Possibly related PRs
Suggested reviewers
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Support Linux ARM64 64KB page builds with latest WebKit
背景
本次改动的目标是让 Bun 在最新本地 WebKit 依赖下,完成 Linux ARM64 64KB page 环境的构建与基础运行验证。
对应分支:
fix-latest-webkit-64kb-linux-arm64关键提交:
63a02de4f5Support local 64KB Linux Bun buildsbc693e6c8aAdapt Bun for latest WebKit 64KB Linux buildsSummary
llm-12的 64KB page 环境完成 smoke testChanges
构建链路
USE_64KB_PAGE_BLOCK=ON--console/ 进度通道带来的异常-Wno-undefined-var-templateBun 与最新 WebKit API 适配
ZigGlobalObject、NodeVM、bindings等 JSC 接口适配逻辑JSPromise::resolve(...)、wasm streaming、static globals、GC visitor/output constraints 的最新签名变化运行时结果
Validation
验证环境:
llm-12结果:
uname -m输出aarch64getconf PAGE_SIZE输出65536使用本分支与配套 WebKit 分支构建本地产物后,在
ubuntu:24.04arm64 容器内验证:结果:
./bun --revision->1.3.11-canary.1+bc693e6c8./bun --version->1.3.11./bun -e "console.log(process.arch, process.platform, Bun.version)"->arm64 linux 1.3.11./bun -e 'await Bun.write("/tmp/a.txt", "ok"); console.log(await Bun.file("/tmp/a.txt").text())'->okRisk/Notes
fix/structure-heap-64kb-linux-arm64