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