Compare commits

...

3 Commits

Author SHA1 Message Date
Dylan Conway
e858c19590 Merge branch 'main' into claude/windows-arm64-shim 2026-02-26 13:25:00 -08:00
autofix-ci[bot]
9785cea48a [autofix.ci] apply automated fixes 2026-02-26 07:11:08 +00:00
Dylan Conway
3558f5d808 build: compile windows shim for native arch on aarch64
Previously the node_modules/.bin shim executable was hardcoded to build
for x86_64+nehalem even when building bun for Windows ARM64. This meant
every binary in node_modules/.bin ran under x64 emulation.

The shim source (bun_shim_impl.zig) has no arch-specific code -- it uses
only NTDLL/kernel32 APIs and std.os.windows.teb() which already has a
native aarch64 implementation. The resulting ARM64 binary is 12.5KB.
2026-02-25 23:07:06 -08:00
2 changed files with 20 additions and 15 deletions

View File

@@ -98,7 +98,7 @@ const BunBuildOptions = struct {
pub fn windowsShim(this: *BunBuildOptions, b: *Build) WindowsShim {
return this.windows_shim orelse {
this.windows_shim = WindowsShim.create(b);
this.windows_shim = WindowsShim.create(b, this.arch);
return this.windows_shim.?;
};
}
@@ -759,7 +759,6 @@ fn configureObj(b: *Build, opts: *BunBuildOptions, obj: *Compile) void {
obj.no_link_obj = opts.os != .windows and !opts.no_llvm;
if (opts.enable_asan and !enableFastBuild(b)) {
if (@hasField(Build.Module, "sanitize_address")) {
if (opts.enable_fuzzilli) {
@@ -986,10 +985,16 @@ const WindowsShim = struct {
exe: *Compile,
dbg: *Compile,
fn create(b: *Build) WindowsShim {
fn create(b: *Build, arch: Arch) WindowsShim {
const target = b.resolveTargetQuery(.{
.cpu_model = .{ .explicit = &std.Target.x86.cpu.nehalem },
.cpu_arch = .x86_64,
.cpu_model = switch (arch) {
.aarch64 => .baseline,
else => .{ .explicit = &std.Target.x86.cpu.nehalem },
},
.cpu_arch = switch (arch) {
.aarch64 => .aarch64,
else => .x86_64,
},
.os_tag = .windows,
.os_version_min = getOSVersionMin(.windows),
});

View File

@@ -228,16 +228,16 @@ To build for macOS x64:
The order of the `--target` flag does not matter, as long as they're delimited by a `-`.
| --target | Operating System | Architecture | Modern | Baseline | Libc |
| --------------------- | ---------------- | ------------ | ------ | -------- | ----- |
| bun-linux-x64 | Linux | x64 | ✅ | ✅ | glibc |
| bun-linux-arm64 | Linux | arm64 | ✅ | N/A | glibc |
| bun-windows-x64 | Windows | x64 | ✅ | ✅ | - |
| bun-windows-arm64 | Windows | arm64 | ✅ | N/A | - |
| bun-darwin-x64 | macOS | x64 | ✅ | ✅ | - |
| bun-darwin-arm64 | macOS | arm64 | ✅ | N/A | - |
| bun-linux-x64-musl | Linux | x64 | ✅ | ✅ | musl |
| bun-linux-arm64-musl | Linux | arm64 | ✅ | N/A | musl |
| --target | Operating System | Architecture | Modern | Baseline | Libc |
| -------------------- | ---------------- | ------------ | ------ | -------- | ----- |
| bun-linux-x64 | Linux | x64 | ✅ | ✅ | glibc |
| bun-linux-arm64 | Linux | arm64 | ✅ | N/A | glibc |
| bun-windows-x64 | Windows | x64 | ✅ | ✅ | - |
| bun-windows-arm64 | Windows | arm64 | ✅ | N/A | - |
| bun-darwin-x64 | macOS | x64 | ✅ | ✅ | - |
| bun-darwin-arm64 | macOS | arm64 | ✅ | N/A | - |
| bun-linux-x64-musl | Linux | x64 | ✅ | ✅ | musl |
| bun-linux-arm64-musl | Linux | arm64 | ✅ | N/A | musl |
<Warning>
On x64 platforms, Bun uses SIMD optimizations which require a modern CPU supporting AVX2 instructions. The `-baseline`