Skip to content

Commit 9ab7eec

Browse files
committed
represent Mac Catalyst as aarch64-maccatalyst-none rather than aarch64-ios-macabi
Apple's own headers and tbd files prefer to think of Mac Catalyst as a distinct OS target. Earlier, when DriverKit support was added to LLVM, it was represented a distinct OS. So why Apple decided to only represent Mac Catalyst as an ABI in the target triple is beyond me. But this isn't the first time they've ignored established target triple norms (see: armv7k and aarch64_32) and it probably won't be the last. While doing this, I also audited all Darwin OS prongs throughout the codebase and made sure they cover all the tags.
1 parent 2e6f7d3 commit 9ab7eec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+272
-240
lines changed

lib/compiler/aro/aro/Compilation.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {
335335
.openbsd => try define(w, "__OpenBSD__"),
336336
.dragonfly => try define(w, "__DragonFly__"),
337337
.illumos => try defineStd(w, "sun", is_gnu),
338+
.maccatalyst,
338339
.macos,
339340
.tvos,
340341
.ios,
@@ -635,7 +636,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {
635636
},
636637
.aarch64, .aarch64_be => {
637638
try define(w, "__aarch64__");
638-
if (comp.target.os.tag == .macos) {
639+
if (comp.target.os.tag.isDarwin()) {
639640
try define(w, "__AARCH64_SIMD__");
640641
if (ptr_width == 32) {
641642
try define(w, "__ARM64_ARCH_8_32__");
@@ -992,7 +993,7 @@ fn writeBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefinesMode
992993
\\
993994
);
994995
if (comp.langopts.standard.atLeast(.c11)) switch (comp.target.os.tag) {
995-
.openbsd, .driverkit, .ios, .macos, .tvos, .visionos, .watchos => {
996+
.openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => {
996997
try w.writeAll("#define __STDC_NO_THREADS__ 1\n");
997998
},
998999
.ps4, .ps5 => {

lib/compiler/aro/aro/Driver.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,7 @@ pub fn getPICMode(d: *Driver, lastpic: []const u8) Compilation.Error!struct { ba
14671467
// generation, independent of the argument order.
14681468
if (kernel_or_kext and
14691469
(!(target.os.tag != .ios) or (target.os.isAtLeast(.ios, .{ .major = 6, .minor = 0, .patch = 0 }) orelse false)) and
1470+
(!(target.os.tag != .maccatalyst) or (target.os.isAtLeast(.maccatalyst, .{ .major = 6, .minor = 0, .patch = 0 }) orelse false)) and
14701471
!(target.os.tag != .watchos) and
14711472
!(target.os.tag != .driverkit))
14721473
{

lib/compiler/aro/aro/TypeStore.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ fn generateVaListType(ts: *TypeStore, comp: *Compilation) !QualType {
20912091
.xcore,
20922092
=> return .void_pointer,
20932093
.aarch64, .aarch64_be => switch (comp.target.os.tag) {
2094-
.driverkit, .ios, .macos, .tvos, .visionos, .watchos, .windows => return .char_pointer,
2094+
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .windows => return .char_pointer,
20952095
else => .aarch64_va_list,
20962096
},
20972097
.arm, .armeb, .thumb, .thumbeb => .arm_va_list,

lib/compiler/aro/aro/target.zig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
674674
.emscripten => "emscripten",
675675
.uefi => "windows",
676676
.macos => "macosx",
677-
.ios => "ios",
677+
.ios, .maccatalyst => "ios",
678678
.tvos => "tvos",
679679
.watchos => "watchos",
680680
.driverkit => "driverkit",
@@ -703,7 +703,8 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
703703
writer.writeByte('-') catch unreachable;
704704

705705
const llvm_abi = switch (target.abi) {
706-
.none, .ilp32 => "unknown",
706+
.none => if (target.os.tag == .maccatalyst) "macabi" else "unknown",
707+
.ilp32 => "unknown",
707708
.gnu => "gnu",
708709
.gnuabin32 => "gnuabin32",
709710
.gnuabi64 => "gnuabi64",
@@ -728,7 +729,6 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
728729
.msvc => "msvc",
729730
.itanium => "itanium",
730731
.simulator => "simulator",
731-
.macabi => "macabi",
732732
.ohos => "ohos",
733733
.ohoseabi => "ohoseabi",
734734
};
@@ -742,6 +742,7 @@ pub fn isPIEDefault(target: std.Target) DefaultPIStatus {
742742
return switch (target.os.tag) {
743743
.haiku,
744744

745+
.maccatalyst,
745746
.macos,
746747
.ios,
747748
.tvos,
@@ -809,6 +810,7 @@ pub fn isPICdefault(target: std.Target) DefaultPIStatus {
809810
return switch (target.os.tag) {
810811
.haiku,
811812

813+
.maccatalyst,
812814
.macos,
813815
.ios,
814816
.tvos,
@@ -917,6 +919,7 @@ pub fn isPICDefaultForced(target: std.Target) DefaultPIStatus {
917919
return if (target.cpu.arch == .x86_64) .yes else .no;
918920
},
919921

922+
.maccatalyst,
920923
.macos,
921924
.ios,
922925
.tvos,

lib/compiler_rt/clear_cache.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn clear_cache(start: usize, end: usize) callconv(.c) void {
4949
else => false,
5050
};
5151
const apple = switch (os) {
52-
.ios, .macos, .watchos, .tvos, .visionos => true,
52+
.ios, .maccatalyst, .macos, .watchos, .tvos, .visionos => true,
5353
else => false,
5454
};
5555
if (x86) {

lib/std/Build/Cache.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ pub const Manifest = struct {
538538
// disambiguates by returning EEXIST, indicating original
539539
// failure was a race, or ENOENT, indicating deletion of
540540
// the directory of our open handle.
541-
if (builtin.os.tag != .macos) {
541+
if (!builtin.os.tag.isDarwin()) {
542542
self.diagnostic = .{ .manifest_create = error.FileNotFound };
543543
return error.CacheCheckFailed;
544544
}

lib/std/Io.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ pub const Evented = switch (builtin.os.tag) {
564564
.x86_64, .aarch64 => @import("Io/IoUring.zig"),
565565
else => void, // context-switching code not implemented yet
566566
},
567-
.dragonfly, .freebsd, .netbsd, .openbsd, .macos, .ios, .tvos, .visionos, .watchos => switch (builtin.cpu.arch) {
567+
.dragonfly, .freebsd, .netbsd, .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (builtin.cpu.arch) {
568568
.x86_64, .aarch64 => @import("Io/Kqueue.zig"),
569569
else => void, // context-switching code not implemented yet
570570
},

lib/std/Io/Threaded.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5140,11 +5140,11 @@ fn clockToPosix(clock: Io.Clock) posix.clockid_t {
51405140
return switch (clock) {
51415141
.real => posix.CLOCK.REALTIME,
51425142
.awake => switch (native_os) {
5143-
.macos, .ios, .watchos, .tvos => posix.CLOCK.UPTIME_RAW,
5143+
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => posix.CLOCK.UPTIME_RAW,
51445144
else => posix.CLOCK.MONOTONIC,
51455145
},
51465146
.boot => switch (native_os) {
5147-
.macos, .ios, .watchos, .tvos => posix.CLOCK.MONOTONIC_RAW,
5147+
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => posix.CLOCK.MONOTONIC_RAW,
51485148
// On freebsd derivatives, use MONOTONIC_FAST as currently there's
51495149
// no precision tradeoff.
51505150
.freebsd, .dragonfly => posix.CLOCK.MONOTONIC_FAST,
@@ -5687,7 +5687,7 @@ fn futexWait(t: *Threaded, ptr: *const std.atomic.Value(u32), expect: u32) Io.Ca
56875687
else => unreachable,
56885688
};
56895689
},
5690-
.driverkit, .ios, .macos, .tvos, .visionos, .watchos => {
5690+
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => {
56915691
const c = std.c;
56925692
const flags: c.UL = .{
56935693
.op = .COMPARE_AND_WAIT,
@@ -5774,7 +5774,7 @@ pub fn futexWaitUncancelable(ptr: *const std.atomic.Value(u32), expect: u32) voi
57745774
else => recoverableOsBugDetected(),
57755775
}
57765776
},
5777-
.driverkit, .ios, .macos, .tvos, .visionos, .watchos => {
5777+
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => {
57785778
const c = std.c;
57795779
const flags: c.UL = .{
57805780
.op = .COMPARE_AND_WAIT,
@@ -5872,7 +5872,7 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void {
58725872
else => return recoverableOsBugDetected(), // deadlock due to operating system bug
58735873
}
58745874
},
5875-
.driverkit, .ios, .macos, .tvos, .visionos, .watchos => {
5875+
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => {
58765876
const c = std.c;
58775877
const flags: c.UL = .{
58785878
.op = .COMPARE_AND_WAIT,

lib/std/Progress.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,11 +1549,13 @@ const have_sigwinch = switch (builtin.os.tag) {
15491549
.netbsd,
15501550
.openbsd,
15511551
.haiku,
1552-
.macos,
1552+
.driverkit,
15531553
.ios,
1554-
.watchos,
1554+
.maccatalyst,
1555+
.macos,
15551556
.tvos,
15561557
.visionos,
1558+
.watchos,
15571559
.dragonfly,
15581560
.freebsd,
15591561
.serenity,

lib/std/Target.zig

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub const Os = struct {
3939

4040
driverkit,
4141
ios,
42+
maccatalyst,
4243
macos,
4344
tvos,
4445
visionos,
@@ -78,6 +79,7 @@ pub const Os = struct {
7879
return switch (tag) {
7980
.driverkit,
8081
.ios,
82+
.maccatalyst,
8183
.macos,
8284
.tvos,
8385
.visionos,
@@ -121,6 +123,7 @@ pub const Os = struct {
121123
.windows, .uefi => ".dll",
122124
.driverkit,
123125
.ios,
126+
.maccatalyst,
124127
.macos,
125128
.tvos,
126129
.visionos,
@@ -180,8 +183,9 @@ pub const Os = struct {
180183
.openbsd,
181184

182185
.driverkit,
183-
.macos,
184186
.ios,
187+
.maccatalyst,
188+
.macos,
185189
.tvos,
186190
.visionos,
187191
.watchos,
@@ -546,7 +550,7 @@ pub const Os = struct {
546550
.max = .{ .major = 15, .minor = 6, .patch = 0 },
547551
},
548552
},
549-
.ios => .{
553+
.ios, .maccatalyst => .{
550554
.semver = .{
551555
.min = .{ .major = 15, .minor = 0, .patch = 0 },
552556
.max = .{ .major = 18, .minor = 6, .patch = 0 },
@@ -759,7 +763,6 @@ pub const Abi = enum {
759763
msvc,
760764
itanium,
761765
simulator,
762-
macabi,
763766
ohos,
764767
ohoseabi,
765768

@@ -885,8 +888,6 @@ pub const Abi = enum {
885888
=> .eabihf,
886889
else => .none,
887890
},
888-
.ios => if (arch == .x86_64) .macabi else .none,
889-
.tvos, .visionos, .watchos => if (arch == .x86_64) .simulator else .none,
890891
.windows => .gnu,
891892
.uefi => .msvc,
892893
.@"3ds" => .eabihf,
@@ -902,7 +903,12 @@ pub const Abi = enum {
902903
.serenity,
903904
.dragonfly,
904905
.driverkit,
906+
.ios,
907+
.maccatalyst,
905908
.macos,
909+
.tvos,
910+
.visionos,
911+
.watchos,
906912
.ps3,
907913
.ps4,
908914
.ps5,
@@ -1018,7 +1024,7 @@ pub const ObjectFormat = enum {
10181024

10191025
pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat {
10201026
return switch (os_tag) {
1021-
.driverkit, .ios, .macos, .tvos, .visionos, .watchos => .macho,
1027+
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => .macho,
10221028
.plan9 => .plan9,
10231029
.uefi, .windows => .coff,
10241030
else => switch (arch) {
@@ -1988,7 +1994,7 @@ pub const Cpu = struct {
19881994
},
19891995
.armeb, .thumbeb => &arm.cpu.baseline,
19901996
.aarch64 => switch (os.tag) {
1991-
.driverkit, .macos => &aarch64.cpu.apple_m1,
1997+
.driverkit, .maccatalyst, .macos => &aarch64.cpu.apple_m1,
19921998
.ios, .tvos => &aarch64.cpu.apple_a7,
19931999
.visionos => &aarch64.cpu.apple_m2,
19942000
.watchos => &aarch64.cpu.apple_s4,
@@ -2014,8 +2020,8 @@ pub const Cpu = struct {
20142020
.sparc => &sparc.cpu.v9, // glibc does not work with 'plain' v8.
20152021
.x86 => &x86.cpu.pentium4,
20162022
.x86_64 => switch (os.tag) {
2017-
.driverkit => &x86.cpu.nehalem,
2018-
.ios, .macos, .tvos, .visionos, .watchos => &x86.cpu.core2,
2023+
.driverkit, .maccatalyst => &x86.cpu.nehalem,
2024+
.macos => &x86.cpu.core2,
20192025
.ps4 => &x86.cpu.btver2,
20202026
.ps5 => &x86.cpu.znver2,
20212027
else => generic(arch),
@@ -2112,7 +2118,7 @@ pub inline fn isMuslLibC(target: *const Target) bool {
21122118

21132119
pub inline fn isDarwinLibC(target: *const Target) bool {
21142120
return switch (target.abi) {
2115-
.none, .macabi, .simulator => target.os.tag.isDarwin(),
2121+
.none, .simulator => target.os.tag.isDarwin(),
21162122
else => false,
21172123
};
21182124
}
@@ -2141,8 +2147,9 @@ pub fn requiresLibC(target: *const Target) bool {
21412147
return switch (target.os.tag) {
21422148
.illumos,
21432149
.driverkit,
2144-
.macos,
21452150
.ios,
2151+
.maccatalyst,
2152+
.macos,
21462153
.tvos,
21472154
.watchos,
21482155
.visionos,
@@ -2307,6 +2314,7 @@ pub const DynamicLinker = struct {
23072314

23082315
.driverkit,
23092316
.ios,
2317+
.maccatalyst,
23102318
.macos,
23112319
.tvos,
23122320
.visionos,
@@ -2722,6 +2730,7 @@ pub const DynamicLinker = struct {
27222730

27232731
.driverkit,
27242732
.ios,
2733+
.maccatalyst,
27252734
.macos,
27262735
.tvos,
27272736
.visionos,
@@ -3234,6 +3243,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
32343243

32353244
.driverkit,
32363245
.ios,
3246+
.maccatalyst,
32373247
.macos,
32383248
.tvos,
32393249
.visionos,

0 commit comments

Comments
 (0)