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.
This commit is contained in:
Sam
2026-04-29 22:14:21 -07:00
parent 6590196661
commit f8f3b6f694
+3 -3
View File
@@ -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);