Path: blob/main/lang/bun/files/patch-build.zig
49052 views
-- Fix Zig 0.15.x API compatibility issues when building bun for FreeBSD:1-- 1. FreeBSD sysroot string literal: use @as([]const u8, "/") instead of bare "/"2-- because *const [1:0]u8 cannot coerce to ?[]const u8 in oven-sh/zig fork3-- 2. SemanticVersion format: use {d}.{d}.{d} instead of {f} for compatibility4-- 3. validateGeneratedPath: skip panic when generated files are not yet present56--- build.zig.orig 2026-05-12 22:12:49 UTC7+++ build.zig8@@ -90,7 +90,7 @@ const BunBuildOptions = struct {9opts.addOption(bool, "enable_valgrind", this.enable_valgrind);10opts.addOption(bool, "enable_tinycc", this.enable_tinycc);11opts.addOption(bool, "use_mimalloc", this.use_mimalloc);12- opts.addOption([]const u8, "reported_nodejs_version", b.fmt("{f}", .{this.reported_nodejs_version}));13+ 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}));14opts.addOption(bool, "zig_self_hosted_backend", this.no_llvm);15opts.addOption(bool, "override_no_export_cpp_apis", this.override_no_export_cpp_apis);1617@@ -226,7 +226,7 @@ pub fn build(b: *Build) !void {18// linkLibC() gets FreeBSD libc via `zig build --libc <file>`. On a19// native FreeBSD host the system root is the sysroot.20const freebsd_sysroot = b.option([]const u8, "freebsd_sysroot", "FreeBSD sysroot (extracted base.txz) for translate-c headers") orelse21- if (os == .freebsd and builtin.os.tag == .freebsd) "/" else null;22+ if (os == .freebsd and builtin.os.tag == .freebsd) @as([]const u8, "/") else null;23if (os == .freebsd and freebsd_sysroot == null) {24std.debug.panic("-Dfreebsd_sysroot is required when cross-compiling to FreeBSD (zig does not bundle FreeBSD libc headers)", .{});25}26@@ -1106,13 +1106,8 @@ fn validateGeneratedPath(path: []const u8) void {27}2829fn validateGeneratedPath(path: []const u8) void {30- if (!exists(path)) {31- std.debug.panic(32- \\Generated file '{s}' is missing!33- \\34- \\Make sure to use CMake and Ninja, or pass a manual codegen folder with '-Dgenerated-code=...'35- , .{path});36- }37+ // Skip validation - generated files may not exist before codegen runs38+ _ = path;39}4041const WindowsShim = struct {424344