fix: use native Windows ARM64 binary for Bun >= 1.3.10 (#165)

Bun v1.3.10 ships native Windows ARM64 binaries. Update
getArchitecture() and getAvx2() to be version-aware so that
windows-11-arm runners download bun-windows-aarch64.zip instead of
falling back to bun-windows-x64-baseline.zip. The x64 fallback is
preserved for older versions that lack ARM64 assets.

Closes #164

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dariel Dato-on
2026-02-26 15:21:29 -06:00
committed by GitHub
parent ab8cb4e8f8
commit 0ff83bfc51
6 changed files with 263 additions and 97 deletions
+5 -3
View File
@@ -61,13 +61,15 @@ async function getSemverDownloadUrl(options: Input): Promise<string> {
}
}
const eversion = encodeURIComponent(tag ?? version);
const resolvedTag = tag ?? version;
const eversion = encodeURIComponent(resolvedTag);
const eos = encodeURIComponent(os ?? getPlatform());
const earch = encodeURIComponent(
getArchitecture(os ?? getPlatform(), arch ?? process.arch),
getArchitecture(os ?? getPlatform(), arch ?? process.arch, resolvedTag),
);
const eavx2 = encodeURIComponent(
getAvx2(os ?? getPlatform(), arch ?? process.arch, avx2) === false
getAvx2(os ?? getPlatform(), arch ?? process.arch, avx2, resolvedTag) ===
false
? "-baseline"
: "",
);
+41 -14
View File
@@ -3,6 +3,10 @@ import { info } from "node:console";
import { createHash } from "node:crypto";
import { existsSync, readFileSync, renameSync } from "node:fs";
import { resolve, basename } from "node:path";
import { compareVersions, validate } from "compare-versions";
// First Bun version that ships native Windows ARM64 binaries.
const WINDOWS_ARM64_MIN_VERSION = "1.3.10";
export function getCacheKey(url: string): string {
return `bun-${createHash("sha1").update(url).digest("base64")}`;
@@ -47,28 +51,51 @@ export function getPlatform(): string {
return platform;
}
export function getArchitecture(os: string, arch: string): string {
if (os === "windows" && (arch === "aarch64" || arch === "arm64")) {
warning(
[
"⚠️ Bun does not provide native arm64 builds for Windows.",
"Using x64 baseline build which will run through Microsoft's x64 emulation layer.",
"This may result in reduced performance and potential compatibility issues.",
"💡 For best performance, consider using x64 Windows runners or other platforms with native support.",
].join("\n"),
);
export function hasNativeWindowsArm64(version?: string): boolean {
if (!version) return false;
const cleaned = version.replace(/^bun-v/, "");
// Non-semver versions like "canary" represent latest builds which ship ARM64.
if (!validate(cleaned)) return true;
return compareVersions(cleaned, WINDOWS_ARM64_MIN_VERSION) >= 0;
}
return "x64";
export function getArchitecture(
os: string,
arch: string,
version?: string,
): string {
if (os === "windows" && (arch === "aarch64" || arch === "arm64")) {
if (!hasNativeWindowsArm64(version)) {
warning(
[
"⚠️ This version of Bun does not provide native arm64 builds for Windows.",
"Using x64 baseline build which will run through Microsoft's x64 emulation layer.",
"This may result in reduced performance and potential compatibility issues.",
"💡 For best performance, consider using Bun >= 1.3.10, x64 Windows runners, or other platforms with native support.",
].join("\n"),
);
return "x64";
}
}
if (arch === "arm64") return "aarch64";
return arch;
}
export function getAvx2(os: string, arch: string, avx2?: boolean): boolean {
// Temporary workaround for absence of arm64 builds on Windows (#130)
export function getAvx2(
os: string,
arch: string,
avx2?: boolean,
version?: string,
): boolean {
// Workaround for absence of arm64 builds on Windows before 1.3.10 (#130)
if (os === "windows" && (arch === "aarch64" || arch === "arm64")) {
return false;
if (!hasNativeWindowsArm64(version)) {
return false;
}
// Native ARM64 builds don't use AVX2 suffix
return true;
}
return avx2 ?? true;