mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:24:33 +01:00
compiler: fix build from source on macOS
This commit is contained in:
parent
54865e0483
commit
1264469a41
4 changed files with 14 additions and 14 deletions
|
|
@ -177,9 +177,9 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
|
|||
var self: LibCInstallation = .{};
|
||||
|
||||
if (is_darwin and args.target.os.tag.isDarwin()) {
|
||||
if (!std.zig.system.darwin.isSdkInstalled(gpa))
|
||||
if (!std.zig.system.darwin.isSdkInstalled(gpa, io))
|
||||
return error.DarwinSdkNotFound;
|
||||
const sdk = std.zig.system.darwin.getSdk(gpa, args.target) orelse
|
||||
const sdk = std.zig.system.darwin.getSdk(gpa, io, args.target) orelse
|
||||
return error.DarwinSdkNotFound;
|
||||
defer gpa.free(sdk);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
const std = @import("../../std.zig");
|
||||
const NativePaths = @This();
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const std = @import("../../std.zig");
|
||||
const Io = std.Io;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const process = std.process;
|
||||
const mem = std.mem;
|
||||
|
||||
const NativePaths = @This();
|
||||
|
||||
arena: Allocator,
|
||||
include_dirs: std.ArrayList([]const u8) = .empty,
|
||||
lib_dirs: std.ArrayList([]const u8) = .empty,
|
||||
|
|
@ -13,7 +14,7 @@ framework_dirs: std.ArrayList([]const u8) = .empty,
|
|||
rpaths: std.ArrayList([]const u8) = .empty,
|
||||
warnings: std.ArrayList([]const u8) = .empty,
|
||||
|
||||
pub fn detect(arena: Allocator, native_target: *const std.Target) !NativePaths {
|
||||
pub fn detect(arena: Allocator, io: Io, native_target: *const std.Target) !NativePaths {
|
||||
var self: NativePaths = .{ .arena = arena };
|
||||
var is_nix = false;
|
||||
if (process.getEnvVarOwned(arena, "NIX_CFLAGS_COMPILE")) |nix_cflags_compile| {
|
||||
|
|
@ -115,8 +116,8 @@ pub fn detect(arena: Allocator, native_target: *const std.Target) !NativePaths {
|
|||
|
||||
// TODO: consider also adding macports paths
|
||||
if (builtin.target.os.tag.isDarwin()) {
|
||||
if (std.zig.system.darwin.isSdkInstalled(arena)) sdk: {
|
||||
const sdk = std.zig.system.darwin.getSdk(arena, native_target) orelse break :sdk;
|
||||
if (std.zig.system.darwin.isSdkInstalled(arena, io)) sdk: {
|
||||
const sdk = std.zig.system.darwin.getSdk(arena, io, native_target) orelse break :sdk;
|
||||
try self.addLibDir(try std.fs.path.join(arena, &.{ sdk, "usr/lib" }));
|
||||
try self.addFrameworkDir(try std.fs.path.join(arena, &.{ sdk, "System/Library/Frameworks" }));
|
||||
try self.addIncludeDir(try std.fs.path.join(arena, &.{ sdk, "usr/include" }));
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ pub fn flush(
|
|||
else => |e| return diags.fail("failed to write code signature: {s}", .{@errorName(e)}),
|
||||
};
|
||||
const emit = self.base.emit;
|
||||
invalidateKernelCache(emit.root_dir.handle, emit.sub_path) catch |err| switch (err) {
|
||||
invalidateKernelCache(io, emit.root_dir.handle, emit.sub_path) catch |err| switch (err) {
|
||||
else => |e| return diags.fail("failed to invalidate kernel cache: {t}", .{e}),
|
||||
};
|
||||
}
|
||||
|
|
@ -3621,11 +3621,11 @@ pub fn getTarget(self: *const MachO) *const std.Target {
|
|||
/// into a new inode, remove the original file, and rename the copy to match
|
||||
/// the original file. This is super messy, but there doesn't seem any other
|
||||
/// way to please the XNU.
|
||||
pub fn invalidateKernelCache(dir: Io.Dir, sub_path: []const u8) !void {
|
||||
pub fn invalidateKernelCache(io: Io, dir: Io.Dir, sub_path: []const u8) !void {
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
if (builtin.target.os.tag.isDarwin() and builtin.target.cpu.arch == .aarch64) {
|
||||
try dir.copyFile(sub_path, dir, sub_path, .{});
|
||||
try dir.copyFile(sub_path, dir, sub_path, io, .{});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3985,9 +3985,8 @@ fn createModule(
|
|||
resolved_target.is_native_os and resolved_target.is_native_abi and
|
||||
create_module.want_native_include_dirs)
|
||||
{
|
||||
var paths = std.zig.system.NativePaths.detect(arena, target) catch |err| {
|
||||
fatal("unable to detect native system paths: {s}", .{@errorName(err)});
|
||||
};
|
||||
var paths = std.zig.system.NativePaths.detect(arena, io, target) catch |err|
|
||||
fatal("unable to detect native system paths: {t}", .{err});
|
||||
for (paths.warnings.items) |warning| {
|
||||
warn("{s}", .{warning});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue