diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-05-20 16:54:52 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-05-22 17:45:07 +0200 |
| commit | e306d04473818ac8b58779aa1ff20b12edb8e94a (patch) | |
| tree | 44d01d290362c86b4b0c1b0208636727ea8095e3 /src | |
| parent | f8a1a2c4a18a2a5f274029c4c59f3a8e83f36b6b (diff) | |
| download | zig-e306d04473818ac8b58779aa1ff20b12edb8e94a.tar.gz zig-e306d04473818ac8b58779aa1ff20b12edb8e94a.zip | |
Return an error when macOS ABI is not {none, simulator, macabi}
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 9 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 5 | ||||
| -rw-r--r-- | src/link/MachO/Dylib.zig | 1 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 2c15cb95a3..31782e732b 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1719,6 +1719,15 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { const have_bin_emit = comp.bin_file.options.emit != null or comp.whole_bin_sub_path != null; if (have_bin_emit and !comp.bin_file.options.skip_linker_dependencies) { + if (comp.getTarget().isDarwin()) { + switch (comp.getTarget().abi) { + .none, + .simulator, + .macabi, + => {}, + else => return error.LibCUnavailable, + } + } // If we need to build glibc for the target, add work items for it. // We go through the work queue so that building can be done in parallel. if (comp.wantBuildGLibCFromSource()) { diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 5f071af017..452bb9b497 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -86,6 +86,9 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 { .spirv64 => return error.@"LLVM backend does not support SPIR-V", }; + var arena = std.heap.ArenaAllocator.init(allocator); + defer arena.deinit(); + const llvm_os = blk: { if (target.os.tag.isDarwin()) { const min_version = target.os.version_range.semver.min; @@ -96,7 +99,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 { .watchos => "watchos", else => unreachable, }; - break :blk try std.fmt.allocPrintZ(allocator, "{s}{d}.{d}.{d}", .{ + break :blk try std.fmt.allocPrintZ(arena.allocator(), "{s}{d}.{d}.{d}", .{ llvm_os, min_version.major, min_version.minor, diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig index b8b8f50e67..73e7913d71 100644 --- a/src/link/MachO/Dylib.zig +++ b/src/link/MachO/Dylib.zig @@ -305,6 +305,7 @@ const TargetMatcher = struct { const abi: ?[]const u8 = switch (target.abi) { .none => null, .simulator => "simulator", + .macabi => "maccatalyst", else => unreachable, }; if (abi) |x| { |
