Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/lang/bun/files/patch-build.zig
46591 views
1
-- Fix Zig 0.15.x API compatibility issues when building bun for FreeBSD:
2
-- 1. FreeBSD sysroot string literal: use @as([]const u8, "/") instead of bare "/"
3
-- because *const [1:0]u8 cannot coerce to ?[]const u8 in oven-sh/zig fork
4
-- 2. SemanticVersion format: use {d}.{d}.{d} instead of {f} for compatibility
5
-- 3. validateGeneratedPath: skip panic when generated files are not yet present
6
7
--- build.zig.orig 2026-04-27 07:25:40 UTC
8
+++ build.zig
9
@@ -90,7 +90,7 @@ const BunBuildOptions = struct {
10
opts.addOption(bool, "enable_valgrind", this.enable_valgrind);
11
opts.addOption(bool, "enable_tinycc", this.enable_tinycc);
12
opts.addOption(bool, "use_mimalloc", this.use_mimalloc);
13
- opts.addOption([]const u8, "reported_nodejs_version", b.fmt("{f}", .{this.reported_nodejs_version}));
14
+ opts.addOption([]const u8, "reported_nodejs_version", b.fmt("{d}.{d}.{d}", .{this.reported_nodejs_version.major, this.reported_nodejs_version.minor, this.reported_nodejs_version.patch}));
15
opts.addOption(bool, "zig_self_hosted_backend", this.no_llvm);
16
opts.addOption(bool, "override_no_export_cpp_apis", this.override_no_export_cpp_apis);
17
18
@@ -226,7 +226,7 @@ pub fn build(b: *Build) !void {
19
// linkLibC() gets FreeBSD libc via `zig build --libc <file>`. On a
20
// native FreeBSD host the system root is the sysroot.
21
const freebsd_sysroot = b.option([]const u8, "freebsd_sysroot", "FreeBSD sysroot (extracted base.txz) for translate-c headers") orelse
22
- if (os == .freebsd and builtin.os.tag == .freebsd) "/" else null;
23
+ if (os == .freebsd and builtin.os.tag == .freebsd) @as([]const u8, "/") else null;
24
if (os == .freebsd and freebsd_sysroot == null) {
25
std.debug.panic("-Dfreebsd_sysroot is required when cross-compiling to FreeBSD (zig does not bundle FreeBSD libc headers)", .{});
26
}
27
@@ -1086,13 +1086,8 @@ fn validateGeneratedPath(path: []const u8) void {
28
}
29
30
fn validateGeneratedPath(path: []const u8) void {
31
- if (!exists(path)) {
32
- std.debug.panic(
33
- \\Generated file '{s}' is missing!
34
- \\
35
- \\Make sure to use CMake and Ninja, or pass a manual codegen folder with '-Dgenerated-code=...'
36
- , .{path});
37
- }
38
+ // Skip validation - generated files may not exist before codegen runs
39
+ _ = path;
40
}
41
42
const WindowsShim = struct {
43
44