-- Fix Zig 0.15.x API compatibility issues when building bun for FreeBSD:
-- 1. FreeBSD sysroot string literal: use @as([]const u8, "/") instead of bare "/"
-- because *const [1:0]u8 cannot coerce to ?[]const u8 in oven-sh/zig fork
-- 2. SemanticVersion format: use {d}.{d}.{d} instead of {f} for compatibility
-- 3. validateGeneratedPath: skip panic when generated files are not yet present
--- build.zig.orig 2026-04-27 07:25:40 UTC
+++ build.zig
@@ -90,7 +90,7 @@ const BunBuildOptions = struct {
opts.addOption(bool, "enable_valgrind", this.enable_valgrind);
opts.addOption(bool, "enable_tinycc", this.enable_tinycc);
opts.addOption(bool, "use_mimalloc", this.use_mimalloc);
- opts.addOption([]const u8, "reported_nodejs_version", b.fmt("{f}", .{this.reported_nodejs_version}));
+ 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}));
opts.addOption(bool, "zig_self_hosted_backend", this.no_llvm);
opts.addOption(bool, "override_no_export_cpp_apis", this.override_no_export_cpp_apis);
@@ -226,7 +226,7 @@ pub fn build(b: *Build) !void {
const freebsd_sysroot = b.option([]const u8, "freebsd_sysroot", "FreeBSD sysroot (extracted base.txz) for translate-c headers") orelse
- if (os == .freebsd and builtin.os.tag == .freebsd) "/" else null;
+ if (os == .freebsd and builtin.os.tag == .freebsd) @as([]const u8, "/") else null;
if (os == .freebsd and freebsd_sysroot == null) {
std.debug.panic("-Dfreebsd_sysroot is required when cross-compiling to FreeBSD (zig does not bundle FreeBSD libc headers)", .{});
}
@@ -1086,13 +1086,8 @@ fn validateGeneratedPath(path: []const u8) void {
}
fn validateGeneratedPath(path: []const u8) void {
- if (!exists(path)) {
- std.debug.panic(
- \\Generated file '{s}' is missing!
- \\
- \\Make sure to use CMake and Ninja, or pass a manual codegen folder with '-Dgenerated-code=...'
- , .{path});
- }
+
+ _ = path;
}
const WindowsShim = struct {