Path: blob/main/lang/bun/files/patch-scripts_build_config.ts
46591 views
-- Add BUN_HOST_OS environment variable support to override host OS detection.1-- When building with a Linux bootstrap bun binary on FreeBSD, bun reports2-- host.os = "linux" which triggers cross-compilation mode (dep_cargo_cross,3-- rustup target add, cross-compile clang flags). Setting BUN_HOST_OS=freebsd4-- makes the build treat FreeBSD as native, using dep_cargo (no rustup needed)5-- and native LLVM/clang without cross-compile sysroot flags.6--7-- Also inline WEBKIT_VERSION to break a circular ES module dependency:8-- deps/index.ts → deps/webkit.ts → source.ts → config.ts → deps/webkit.ts9-- Bun 1.3.14 enforces strict TDZ for circular ES modules; inlining breaks cycle.1011--- scripts/build/config.ts.orig 2026-04-27 07:22:36 UTC12+++ scripts/build/config.ts13@@ -11,7 +11,9 @@14import { homedir, arch as hostArch, platform as hostPlatform } from "node:os";15import { isAbsolute, join, relative, resolve, sep } from "node:path";16import { NODEJS_ABI_VERSION, NODEJS_VERSION } from "./deps/nodejs-headers.ts";17-import { WEBKIT_VERSION } from "./deps/webkit.ts";18+// WEBKIT_VERSION inlined here (was imported from deps/webkit.ts) to break circular module dep:19+// deps/index.ts → deps/webkit.ts → source.ts → config.ts → deps/webkit.ts20+const WEBKIT_VERSION = "bdf6aab38a9c6f99df3fd1486406ab6b74180fbb";21import { assert, BuildError } from "./error.ts";22import { clangTargetArch } from "./tools.ts";23import { cyan, dim, green } from "./tty.ts";24@@ -341,9 +343,12 @@2526/**27* Host platform detection. Only used for picking defaults.28+ * The BUN_HOST_OS environment variable can override the detected OS.29+ * This is needed when using a Linux bun bootstrap binary on FreeBSD.30*/31export function detectHost(): Host {32- const plat = hostPlatform();33+ const envOs = process.env.BUN_HOST_OS;34+ const plat = envOs !== undefined ? envOs : hostPlatform();35const os: OS =36plat === "linux"37? "linux"383940