authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-05-20 16:54:52+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-05-22 17:45:07+02:00
loge306d04473818ac8b58779aa1ff20b12edb8e94a
tree44d01d290362c86b4b0c1b0208636727ea8095e3
parentf8a1a2c4a18a2a5f274029c4c59f3a8e83f36b6b

Return an error when macOS ABI is not {none, simulator, macabi}


3 files changed, 14 insertions(+), 1 deletions(-)

src/Compilation.zig+9
...@@ -1719,6 +1719,15 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1719,6 +1719,15 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1719 const have_bin_emit = comp.bin_file.options.emit != null or comp.whole_bin_sub_path != null;1719 const have_bin_emit = comp.bin_file.options.emit != null or comp.whole_bin_sub_path != null;
17201720
1721 if (have_bin_emit and !comp.bin_file.options.skip_linker_dependencies) {1721 if (have_bin_emit and !comp.bin_file.options.skip_linker_dependencies) {
1722 if (comp.getTarget().isDarwin()) {
1723 switch (comp.getTarget().abi) {
1724 .none,
1725 .simulator,
1726 .macabi,
1727 => {},
1728 else => return error.LibCUnavailable,
1729 }
1730 }
1722 // If we need to build glibc for the target, add work items for it.1731 // If we need to build glibc for the target, add work items for it.
1723 // We go through the work queue so that building can be done in parallel.1732 // We go through the work queue so that building can be done in parallel.
1724 if (comp.wantBuildGLibCFromSource()) {1733 if (comp.wantBuildGLibCFromSource()) {
src/codegen/llvm.zig+4-1
...@@ -86,6 +86,9 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 {...@@ -86,6 +86,9 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 {
86 .spirv64 => return error.@"LLVM backend does not support SPIR-V",86 .spirv64 => return error.@"LLVM backend does not support SPIR-V",
87 };87 };
8888
89 var arena = std.heap.ArenaAllocator.init(allocator);
90 defer arena.deinit();
91
89 const llvm_os = blk: {92 const llvm_os = blk: {
90 if (target.os.tag.isDarwin()) {93 if (target.os.tag.isDarwin()) {
91 const min_version = target.os.version_range.semver.min;94 const min_version = target.os.version_range.semver.min;
...@@ -96,7 +99,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 {...@@ -96,7 +99,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 {
96 .watchos => "watchos",99 .watchos => "watchos",
97 else => unreachable,100 else => unreachable,
98 };101 };
99 break :blk try std.fmt.allocPrintZ(allocator, "{s}{d}.{d}.{d}", .{102 break :blk try std.fmt.allocPrintZ(arena.allocator(), "{s}{d}.{d}.{d}", .{
100 llvm_os,103 llvm_os,
101 min_version.major,104 min_version.major,
102 min_version.minor,105 min_version.minor,
src/link/MachO/Dylib.zig+1
...@@ -305,6 +305,7 @@ const TargetMatcher = struct {...@@ -305,6 +305,7 @@ const TargetMatcher = struct {
305 const abi: ?[]const u8 = switch (target.abi) {305 const abi: ?[]const u8 = switch (target.abi) {
306 .none => null,306 .none => null,
307 .simulator => "simulator",307 .simulator => "simulator",
308 .macabi => "maccatalyst",
308 else => unreachable,309 else => unreachable,
309 };310 };
310 if (abi) |x| {311 if (abi) |x| {