From f8f3b6f6945e5456fc02be286412778cd8e66742 Mon Sep 17 00:00:00 2001 From: Sam <30577766+Samasaur1@users.noreply.github.com> Date: Wed, 29 Apr 2026 22:14:21 -0700 Subject: [PATCH] Fall back to Zig-bundled Darwin headers when an SDK can't be found Currently, cross to Darwin uses the Darwin headers bundled with Zig. However, if you're running a build _on_ Darwin, an error is thrown if the SDK can't be found, even though the bundled headers are still available. Now, we continue to search for and prefer the installed SDK, but if it can't be found, we fall back to the bundled headers rather than failing the build. --- pkg/apple-sdk/build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/apple-sdk/build.zig b/pkg/apple-sdk/build.zig index a61cd3843..f897919f4 100644 --- a/pkg/apple-sdk/build.zig +++ b/pkg/apple-sdk/build.zig @@ -49,15 +49,15 @@ pub fn addPaths( }); if (!gop.found_existing) init: { - if (comptime builtin.os.tag.isDarwin()) { + if (comptime builtin.os.tag.isDarwin()) darwin: { // Detect our SDK using the "findNative" Zig stdlib function. // This is really important because it forces using `xcrun` to // find the SDK path. - const libc = try std.zig.LibCInstallation.findNative(.{ + const libc = std.zig.LibCInstallation.findNative(.{ .allocator = b.allocator, .target = &step.rootModuleTarget(), .verbose = false, - }); + }) catch break :darwin; // Render the file compatible with the `--libc` Zig flag. var stream: std.io.Writer.Allocating = .init(b.allocator);