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

This commit is contained in:
Jakub Konka 2022-05-20 16:54:52 +02:00
parent f8a1a2c4a1
commit e306d04473
3 changed files with 14 additions and 1 deletions

View File

@ -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()) {

View File

@ -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,

View File

@ -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| {