This document describes the build process for Windows. If you run into problems, please join the #contributing channel on our Discord for help. It is strongly recommended to use PowerShell 7 (Documentation Index
Fetch the complete documentation index at: https://bun.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
pwsh.exe) instead of the default powershell.exe.
Prerequisites
Enable Scripts
By default, running unverified scripts are blocked.System Dependencies
Bun v1.1 or later. We use Bun to run it’s own code generators.- LLVM 21.1.8
- Go
- Rust (via rustup)
- NASM
- Perl
- Ruby
- Node.js
The pinned Rust nightly toolchain in
rust-toolchain.toml is automatically installed by rustup on first build.Scoop (x64)
ARM64
Please do not use WinGet/other package manager for these, as you will likely install Strawberry Perl instead of a more
minimal installation of Perl. Strawberry Perl includes many other utilities that get installed into
$Env:PATH that
will conflict with MSVC and break the build.Scoop
Cygwin is not required for ARM64 builds as WebKit is provided as a pre-built binary.
.\scripts\vs-shell.ps1 sourced. This script is available in the Bun repository and can be loaded by executing it:
mt.exe
It is not recommended to install
ninja / cmake into your global path, because you may run into a situation where
you try to build bun without .\scripts\vs-shell.ps1 sourced.Building
bun-debug.exe in the build/debug folder.
$Env:PATH. The simplest way to do so is to open the start menu, type “Path”, and then navigate the environment variables menu to add C:\.....\bun\build\debug to the user environment variable PATH. You should then restart your editor (if it does not update still, log out and log back in).
Extra paths
- WebKit is extracted to
build/debug/cache/webkit/
Tests
You can run the test suite either usingbun test <path> or by using the wrapper script bun node:test <path>. The bun node:test command runs every test file in a separate instance of bun.exe, to prevent a crash in the test runner from stopping the entire suite.
Troubleshooting
.rc file fails to build
llvm-rc.exe is odd. don’t use it. use rc.exe, to do this make sure you are in a visual studio dev terminal, check rc /? to ensure it is Microsoft Resource Compiler
failed to write output ‘bun-debug.exe’: permission denied
you cannot overwritebun-debug.exe if it is already open. you likely have a running instance, maybe in the vscode debugger?
Cross-compiling from Linux
Windows binaries (both x64 and arm64) can also be built on a Linux host. The build uses the host LLVM’sclang-cl, lld-link, llvm-lib and llvm-rc — which are part of every LLVM distribution — plus an “xwin splat” of the MSVC CRT/STL and Windows SDK for headers and import libraries.
Prerequisites
- The same LLVM version a native build uses (see
scripts/bootstrap.shllvm_version_exact), installed so thatclang-cl,lld-link,llvm-libandllvm-rcare available. On Debian/Ubuntu,apt.llvm.orgpackages provide all of them. nasm(only needed for Windows x64 — BoringSSL’s x64 assembly is NASM syntax).- Rust std for the Windows targets (
rust-toolchain.tomllists them;rustup target add x86_64-pc-windows-msvc aarch64-pc-windows-msvcif missing). - A Windows sysroot: an xwin splat of the MSVC CRT, Windows SDK, and ATL laid out like a Visual Studio install. Note that downloading these components means accepting Microsoft’s license terms for them.
/opt/winsysroot (or /opt/xwin) automatically; elsewhere, set WINDOWS_SYSROOT=<path> or pass --winsysroot=<path> (a user-writable path also lets configure manage the aliases for you). Configure validates the splat at the start of every cross build. CI agents bake the same splat into their images (.buildkite/Dockerfile, scripts/bootstrap.sh); when an agent doesn’t have one, the build fetches it into its cache dir at configure time.
Building
build/debug-windows-x64/bun-debug.exe, build/release-windows-aarch64/bun-profile.exe + bun.exe, etc. Equivalent raw flags: bun run build --os=windows --arch=aarch64.
Cross-compiled executables are not run on the host (the --revision smoke test is skipped), so test them on a Windows machine or under Wine.
LTO
x64 release cross builds support ThinLTO with cross-language (Rust↔C++) LTO, and CI’s windows x64 cross lane builds with it by default. Locally it’s opt-in:-flto=thin, makes rustc emit LLVM bitcode (-Clinker-plugin-lto), pulls the bun-webkit-windows-amd64-lto ThinLTO prebuilt, and links everything with rustc’s bundled lld-link (its LLVM is new enough to read both compilers’ bitcode). There is no LTO for arm64 (no -lto WebKit prebuilt — LLVM’s CodeView emitter can’t handle ARM64 NEON tuple registers during LTO codegen) or for --baseline.