authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-09 15:45:42-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-05-09 15:45:42-07:00
log68629fedefd46bad4feed7f9244a3208199d6a0e
tree0d483126b4222796eea87349b79330bb76fc733e
parentc9ad1b51993e45942e38079325dcb7b5ce41e877
parent47e840a9b99c6ca371c89a73350617ba0cad877c
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #19918 from ziglang/xros

Add support for VisionOS

27 files changed, 120 insertions(+), 80 deletions(-)

build.zig+1-1
......@@ -705,7 +705,7 @@ fn addCmakeCfgOptionsToExe(
705705 };
706706 exe.linkSystemLibrary("unwind");
707707 },
708 .ios, .macos, .watchos, .tvos => {
708 .ios, .macos, .watchos, .tvos, .visionos => {
709709 exe.linkLibCpp();
710710 },
711711 .windows => {
lib/compiler/aro/aro/Compilation.zig+2-2
......@@ -912,12 +912,12 @@ fn generateVaListType(comp: *Compilation) !Type {
912912 const kind: Kind = switch (comp.target.cpu.arch) {
913913 .aarch64 => switch (comp.target.os.tag) {
914914 .windows => @as(Kind, .char_ptr),
915 .ios, .macos, .tvos, .watchos => .char_ptr,
915 .ios, .macos, .tvos, .watchos, .visionos => .char_ptr,
916916 else => .aarch64_va_list,
917917 },
918918 .sparc, .wasm32, .wasm64, .bpfel, .bpfeb, .riscv32, .riscv64, .avr, .spirv32, .spirv64 => .void_ptr,
919919 .powerpc => switch (comp.target.os.tag) {
920 .ios, .macos, .tvos, .watchos, .aix => @as(Kind, .char_ptr),
920 .ios, .macos, .tvos, .watchos, .visionos, .aix => @as(Kind, .char_ptr),
921921 else => return Type{ .specifier = .void }, // unknown
922922 },
923923 .x86, .msp430 => .char_ptr,
lib/compiler/aro/aro/target.zig+1
......@@ -706,6 +706,7 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
706706 .ios => "ios",
707707 .tvos => "tvos",
708708 .watchos => "watchos",
709 .visionos => "xros",
709710 .driverkit => "driverkit",
710711 .shadermodel => "shadermodel",
711712 .liteos => "liteos",
lib/compiler_rt/clear_cache.zig+1-1
......@@ -45,7 +45,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
4545 else => false,
4646 };
4747 const apple = switch (os) {
48 .ios, .macos, .watchos, .tvos => true,
48 .ios, .macos, .watchos, .tvos, .visionos => true,
4949 else => false,
5050 };
5151 if (x86) {
lib/std/Target.zig+18-12
......@@ -47,7 +47,7 @@ pub const Os = struct {
4747 tvos,
4848 watchos,
4949 driverkit,
50 xros,
50 visionos,
5151 mesa3d,
5252 contiki,
5353 amdpal,
......@@ -67,7 +67,7 @@ pub const Os = struct {
6767
6868 pub inline fn isDarwin(tag: Tag) bool {
6969 return switch (tag) {
70 .ios, .macos, .watchos, .tvos => true,
70 .ios, .macos, .watchos, .tvos, .visionos => true,
7171 else => false,
7272 };
7373 }
......@@ -108,7 +108,7 @@ pub const Os = struct {
108108 pub fn dynamicLibSuffix(tag: Tag) [:0]const u8 {
109109 return switch (tag) {
110110 .windows, .uefi => ".dll",
111 .ios, .macos, .watchos, .tvos => ".dylib",
111 .ios, .macos, .watchos, .tvos, .visionos => ".dylib",
112112 else => ".so",
113113 };
114114 }
......@@ -178,7 +178,7 @@ pub const Os = struct {
178178 .ios,
179179 .tvos,
180180 .watchos,
181 .xros,
181 .visionos,
182182 .netbsd,
183183 .openbsd,
184184 .dragonfly,
......@@ -434,7 +434,12 @@ pub const Os = struct {
434434 .max = .{ .major = 17, .minor = 1, .patch = 0 },
435435 },
436436 },
437 .xros => @panic("TODO what version is xros on right now?"),
437 .visionos => .{
438 .semver = .{
439 .min = .{ .major = 1, .minor = 0, .patch = 0 },
440 .max = .{ .major = 1, .minor = 0, .patch = 0 },
441 },
442 },
438443 .netbsd => .{
439444 .semver = .{
440445 .min = .{ .major = 8, .minor = 0, .patch = 0 },
......@@ -531,7 +536,7 @@ pub const Os = struct {
531536 .ios,
532537 .tvos,
533538 .watchos,
534 .xros,
539 .visionos,
535540 .dragonfly,
536541 .openbsd,
537542 .haiku,
......@@ -691,7 +696,7 @@ pub const Abi = enum {
691696 .ios,
692697 .tvos,
693698 .watchos,
694 .xros,
699 .visionos,
695700 .driverkit,
696701 .shadermodel,
697702 .liteos, // TODO: audit this
......@@ -768,7 +773,7 @@ pub const ObjectFormat = enum {
768773 pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat {
769774 return switch (os_tag) {
770775 .windows, .uefi => .coff,
771 .ios, .macos, .watchos, .tvos => .macho,
776 .ios, .macos, .watchos, .tvos, .visionos => .macho,
772777 .plan9 => .plan9,
773778 else => switch (arch) {
774779 .wasm32, .wasm64 => .wasm,
......@@ -1633,6 +1638,7 @@ pub inline fn hasDynamicLinker(target: Target) bool {
16331638 .tvos,
16341639 .watchos,
16351640 .macos,
1641 .visionos,
16361642 .uefi,
16371643 .windows,
16381644 .emscripten,
......@@ -1807,7 +1813,7 @@ pub const DynamicLinker = struct {
18071813 .tvos,
18081814 .watchos,
18091815 .macos,
1810 .xros,
1816 .visionos,
18111817 => init("/usr/lib/dyld"),
18121818
18131819 // Operating systems in this list have been verified as not having a standard
......@@ -2287,7 +2293,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
22872293 },
22882294 },
22892295
2290 .macos, .ios, .tvos, .watchos, .xros => switch (c_type) {
2296 .macos, .ios, .tvos, .watchos, .visionos => switch (c_type) {
22912297 .char => return 8,
22922298 .short, .ushort => return 16,
22932299 .int, .uint, .float => return 32,
......@@ -2407,7 +2413,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
24072413
24082414 else => 4,
24092415 },
2410 .ios, .tvos, .watchos => 4,
2416 .ios, .tvos, .watchos, .visionos => 4,
24112417 else => 8,
24122418 },
24132419
......@@ -2500,7 +2506,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
25002506 else => {},
25012507 },
25022508 },
2503 .ios, .tvos, .watchos => switch (c_type) {
2509 .ios, .tvos, .watchos, .visionos => switch (c_type) {
25042510 .longdouble => return 4,
25052511 else => {},
25062512 },
lib/std/Thread.zig+6-6
......@@ -39,7 +39,7 @@ impl: Impl,
3939pub const max_name_len = switch (native_os) {
4040 .linux => 15,
4141 .windows => 31,
42 .macos, .ios, .watchos, .tvos => 63,
42 .macos, .ios, .watchos, .tvos, .visionos => 63,
4343 .netbsd => 31,
4444 .freebsd => 15,
4545 .openbsd => 23,
......@@ -114,7 +114,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
114114 else => |err| return windows.unexpectedStatus(err),
115115 }
116116 },
117 .macos, .ios, .watchos, .tvos => if (use_pthreads) {
117 .macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
118118 // There doesn't seem to be a way to set the name for an arbitrary thread, only the current one.
119119 if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;
120120
......@@ -217,7 +217,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
217217 else => |err| return windows.unexpectedStatus(err),
218218 }
219219 },
220 .macos, .ios, .watchos, .tvos => if (use_pthreads) {
220 .macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
221221 const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
222222 switch (err) {
223223 .SUCCESS => return std.mem.sliceTo(buffer, 0),
......@@ -266,7 +266,7 @@ pub const Id = switch (native_os) {
266266 .haiku,
267267 .wasi,
268268 => u32,
269 .macos, .ios, .watchos, .tvos => u64,
269 .macos, .ios, .watchos, .tvos, .visionos => u64,
270270 .windows => windows.DWORD,
271271 else => usize,
272272};
......@@ -588,7 +588,7 @@ const PosixThreadImpl = struct {
588588 .linux => {
589589 return LinuxThreadImpl.getCurrentId();
590590 },
591 .macos, .ios, .watchos, .tvos => {
591 .macos, .ios, .watchos, .tvos, .visionos => {
592592 var thread_id: u64 = undefined;
593593 // Pass thread=null to get the current thread ID.
594594 assert(c.pthread_threadid_np(null, &thread_id) == 0);
......@@ -1434,7 +1434,7 @@ test "setName, getName" {
14341434 context.test_done_event.wait();
14351435
14361436 switch (native_os) {
1437 .macos, .ios, .watchos, .tvos => {
1437 .macos, .ios, .watchos, .tvos, .visionos => {
14381438 const res = thread.setName("foobar");
14391439 try std.testing.expectError(error.Unsupported, res);
14401440 },
lib/std/builtin.zig+3-3
......@@ -597,11 +597,11 @@ pub const VaListX86_64 = extern struct {
597597pub const VaList = switch (builtin.cpu.arch) {
598598 .aarch64, .aarch64_be => switch (builtin.os.tag) {
599599 .windows => *u8,
600 .ios, .macos, .tvos, .watchos => *u8,
600 .ios, .macos, .tvos, .watchos, .visionos => *u8,
601601 else => @compileError("disabled due to miscompilations"), // VaListAarch64,
602602 },
603603 .arm => switch (builtin.os.tag) {
604 .ios, .macos, .tvos, .watchos => *u8,
604 .ios, .macos, .tvos, .watchos, .visionos => *u8,
605605 else => *anyopaque,
606606 },
607607 .amdgcn => *u8,
......@@ -611,7 +611,7 @@ pub const VaList = switch (builtin.cpu.arch) {
611611 .mips, .mipsel, .mips64, .mips64el => *anyopaque,
612612 .riscv32, .riscv64 => *anyopaque,
613613 .powerpc, .powerpcle => switch (builtin.os.tag) {
614 .ios, .macos, .tvos, .watchos, .aix => *u8,
614 .ios, .macos, .tvos, .watchos, .visionos, .aix => *u8,
615615 else => VaListPowerPc,
616616 },
617617 .powerpc64, .powerpc64le => *u8,
lib/std/c.zig+17-17
......@@ -35,7 +35,7 @@ pub inline fn versionCheck(comptime glibc_version: std.SemanticVersion) bool {
3535pub usingnamespace switch (native_os) {
3636 .linux => @import("c/linux.zig"),
3737 .windows => @import("c/windows.zig"),
38 .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
38 .macos, .ios, .tvos, .watchos, .visionos => @import("c/darwin.zig"),
3939 .freebsd, .kfreebsd => @import("c/freebsd.zig"),
4040 .netbsd => @import("c/netbsd.zig"),
4141 .dragonfly => @import("c/dragonfly.zig"),
......@@ -63,7 +63,7 @@ pub const pthread_mutex_t = switch (native_os) {
6363 else => @compileError("unsupported ABI"),
6464 };
6565 },
66 .macos, .ios, .tvos, .watchos => extern struct {
66 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
6767 sig: c_long = 0x32AAABA7,
6868 data: [data_len]u8 = [_]u8{0} ** data_len,
6969
......@@ -113,7 +113,7 @@ pub const pthread_cond_t = switch (native_os) {
113113 .linux => extern struct {
114114 data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,
115115 },
116 .macos, .ios, .tvos, .watchos => extern struct {
116 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
117117 sig: c_long = 0x3CB0B1BB,
118118 data: [data_len]u8 = [_]u8{0} ** data_len,
119119 const data_len = if (@sizeOf(usize) == 8) 40 else 24;
......@@ -166,7 +166,7 @@ pub const pthread_rwlock_t = switch (native_os) {
166166 data: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,
167167 },
168168 },
169 .macos, .ios, .tvos, .watchos => extern struct {
169 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
170170 sig: c_long = 0x2DA8B3B4,
171171 data: [192]u8 = [_]u8{0} ** 192,
172172 },
......@@ -214,7 +214,7 @@ pub const AT = switch (native_os) {
214214 /// Remove directory instead of unlinking file
215215 pub const REMOVEDIR = 0x200;
216216 },
217 .macos, .ios, .tvos, .watchos => struct {
217 .macos, .ios, .tvos, .watchos, .visionos => struct {
218218 pub const FDCWD = -2;
219219 /// Use effective ids in access check
220220 pub const EACCESS = 0x0010;
......@@ -458,7 +458,7 @@ pub const O = switch (native_os) {
458458 DIRECTORY: bool = false,
459459 _: u10 = 0,
460460 },
461 .macos, .ios, .tvos, .watchos => packed struct(u32) {
461 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
462462 ACCMODE: std.posix.ACCMODE = .RDONLY,
463463 NONBLOCK: bool = false,
464464 APPEND: bool = false,
......@@ -620,7 +620,7 @@ pub const MAP = switch (native_os) {
620620 NORESERVE: bool = false,
621621 _: u27 = 0,
622622 },
623 .macos, .ios, .tvos, .watchos => packed struct(u32) {
623 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
624624 TYPE: enum(u4) {
625625 SHARED = 0x01,
626626 PRIVATE = 0x02,
......@@ -685,7 +685,7 @@ pub const cc_t = u8;
685685/// Indices into the `cc` array in the `termios` struct.
686686pub const V = switch (native_os) {
687687 .linux => linux.V,
688 .macos, .ios, .tvos, .watchos, .netbsd, .openbsd => enum {
688 .macos, .ios, .tvos, .watchos, .visionos, .netbsd, .openbsd => enum {
689689 EOF,
690690 EOL,
691691 EOL2,
......@@ -784,7 +784,7 @@ pub const V = switch (native_os) {
784784
785785pub const NCCS = switch (native_os) {
786786 .linux => linux.NCCS,
787 .macos, .ios, .tvos, .watchos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
787 .macos, .ios, .tvos, .watchos, .visionos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
788788 .haiku => 11,
789789 .solaris, .illumos => 19,
790790 .emscripten, .wasi => 32,
......@@ -793,7 +793,7 @@ pub const NCCS = switch (native_os) {
793793
794794pub const termios = switch (native_os) {
795795 .linux => linux.termios,
796 .macos, .ios, .tvos, .watchos => extern struct {
796 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
797797 iflag: tc_iflag_t,
798798 oflag: tc_oflag_t,
799799 cflag: tc_cflag_t,
......@@ -843,7 +843,7 @@ pub const termios = switch (native_os) {
843843
844844pub const tc_iflag_t = switch (native_os) {
845845 .linux => linux.tc_iflag_t,
846 .macos, .ios, .tvos, .watchos => packed struct(u64) {
846 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
847847 IGNBRK: bool = false,
848848 BRKINT: bool = false,
849849 IGNPAR: bool = false,
......@@ -953,7 +953,7 @@ pub const tc_iflag_t = switch (native_os) {
953953
954954pub const tc_oflag_t = switch (native_os) {
955955 .linux => linux.tc_oflag_t,
956 .macos, .ios, .tvos, .watchos => packed struct(u64) {
956 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
957957 OPOST: bool = false,
958958 ONLCR: bool = false,
959959 OXTABS: bool = false,
......@@ -1050,7 +1050,7 @@ pub const CSIZE = switch (native_os) {
10501050
10511051pub const tc_cflag_t = switch (native_os) {
10521052 .linux => linux.tc_cflag_t,
1053 .macos, .ios, .tvos, .watchos => packed struct(u64) {
1053 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
10541054 CIGNORE: bool = false,
10551055 _1: u5 = 0,
10561056 CSTOPB: bool = false,
......@@ -1186,7 +1186,7 @@ pub const tc_cflag_t = switch (native_os) {
11861186
11871187pub const tc_lflag_t = switch (native_os) {
11881188 .linux => linux.tc_lflag_t,
1189 .macos, .ios, .tvos, .watchos => packed struct(u64) {
1189 .macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
11901190 ECHOKE: bool = false,
11911191 ECHOE: bool = false,
11921192 ECHOK: bool = false,
......@@ -1312,7 +1312,7 @@ pub const tc_lflag_t = switch (native_os) {
13121312
13131313pub const speed_t = switch (native_os) {
13141314 .linux => linux.speed_t,
1315 .macos, .ios, .tvos, .watchos, .openbsd => enum(u64) {
1315 .macos, .ios, .tvos, .watchos, .visionos, .openbsd => enum(u64) {
13161316 B0 = 0,
13171317 B50 = 50,
13181318 B75 = 75,
......@@ -1535,7 +1535,7 @@ pub const fstatat = switch (native_os) {
15351535};
15361536
15371537pub const getdirentries = switch (native_os) {
1538 .macos, .ios, .tvos, .watchos => private.__getdirentries64,
1538 .macos, .ios, .tvos, .watchos, .visionos => private.__getdirentries64,
15391539 else => private.getdirentries,
15401540};
15411541
......@@ -1569,7 +1569,7 @@ pub const readdir = switch (native_os) {
15691569};
15701570
15711571pub const realpath = switch (native_os) {
1572 .macos, .ios, .tvos, .watchos => private.@"realpath$DARWIN_EXTSN",
1572 .macos, .ios, .tvos, .watchos, .visionos => private.@"realpath$DARWIN_EXTSN",
15731573 else => private.realpath,
15741574};
15751575
lib/std/crypto/tlcsprng.zig+1
......@@ -29,6 +29,7 @@ const os_has_fork = switch (native_os) {
2929 .illumos,
3030 .tvos,
3131 .watchos,
32 .visionos,
3233 .haiku,
3334 => true,
3435
lib/std/debug.zig+2-2
......@@ -706,7 +706,7 @@ pub const StackIterator = struct {
706706 const unwind_state = &self.unwind_state.?;
707707 const module = try unwind_state.debug_info.getModuleForAddress(unwind_state.dwarf_context.pc);
708708 switch (native_os) {
709 .macos, .ios, .watchos, .tvos => {
709 .macos, .ios, .watchos, .tvos, .visionos => {
710710 // __unwind_info is a requirement for unwinding on Darwin. It may fall back to DWARF, but unwinding
711711 // via DWARF before attempting to use the compact unwind info will produce incorrect results.
712712 if (module.unwind_info) |unwind_info| {
......@@ -2132,7 +2132,7 @@ pub const DebugInfo = struct {
21322132};
21332133
21342134pub const ModuleDebugInfo = switch (native_os) {
2135 .macos, .ios, .watchos, .tvos => struct {
2135 .macos, .ios, .watchos, .tvos, .visionos => struct {
21362136 base_address: usize,
21372137 vmaddr_slide: usize,
21382138 mapped_memory: []align(mem.page_size) const u8,
lib/std/dynamic_library.zig+2-2
......@@ -16,7 +16,7 @@ pub const DynLib = struct {
1616 else
1717 DlDynLib,
1818 .windows => WindowsDynLib,
19 .macos, .tvos, .watchos, .ios, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynLib,
19 .macos, .tvos, .watchos, .ios, .visionos, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynLib,
2020 else => @compileError("unsupported platform"),
2121 };
2222
......@@ -461,7 +461,7 @@ test "dynamic_library" {
461461 const libname = switch (native_os) {
462462 .linux, .freebsd, .openbsd, .solaris, .illumos => "invalid_so.so",
463463 .windows => "invalid_dll.dll",
464 .macos, .tvos, .watchos, .ios => "invalid_dylib.dylib",
464 .macos, .tvos, .watchos, .ios, .visionos => "invalid_dylib.dylib",
465465 else => return error.SkipZigTest,
466466 };
467467
lib/std/mem.zig+1-1
......@@ -13,7 +13,7 @@ const native_endian = builtin.cpu.arch.endian();
1313pub const page_size = switch (builtin.cpu.arch) {
1414 .wasm32, .wasm64 => 64 * 1024,
1515 .aarch64 => switch (builtin.os.tag) {
16 .macos, .ios, .watchos, .tvos => 16 * 1024,
16 .macos, .ios, .watchos, .tvos, .visionos => 16 * 1024,
1717 else => 4 * 1024,
1818 },
1919 .sparc64 => 8 * 1024,
lib/std/os.zig+2-1
......@@ -76,6 +76,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {
7676 .ios,
7777 .watchos,
7878 .tvos,
79 .visionos,
7980 .linux,
8081 .solaris,
8182 .illumos,
......@@ -110,7 +111,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
110111 const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice);
111112 return out_buffer[0..end_index];
112113 },
113 .macos, .ios, .watchos, .tvos => {
114 .macos, .ios, .watchos, .tvos, .visionos => {
114115 // On macOS, we can use F.GETPATH fcntl command to query the OS for
115116 // the path to the file descriptor.
116117 @memset(out_buffer[0..MAX_PATH_BYTES], 0);
lib/std/posix.zig+11-11
......@@ -604,7 +604,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
604604 }
605605 }
606606 switch (native_os) {
607 .netbsd, .openbsd, .macos, .ios, .tvos, .watchos => {
607 .netbsd, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => {
608608 system.arc4random_buf(buffer.ptr, buffer.len);
609609 return;
610610 },
......@@ -823,7 +823,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
823823 // Prevents EINVAL.
824824 const max_count = switch (native_os) {
825825 .linux => 0x7ffff000,
826 .macos, .ios, .watchos, .tvos => maxInt(i32),
826 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
827827 else => maxInt(isize),
828828 };
829829 while (true) {
......@@ -962,7 +962,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
962962 // Prevent EINVAL.
963963 const max_count = switch (native_os) {
964964 .linux => 0x7ffff000,
965 .macos, .ios, .watchos, .tvos => maxInt(i32),
965 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
966966 else => maxInt(isize),
967967 };
968968
......@@ -1069,7 +1069,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
10691069/// On these systems, the read races with concurrent writes to the same file descriptor.
10701070pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
10711071 const have_pread_but_not_preadv = switch (native_os) {
1072 .windows, .macos, .ios, .watchos, .tvos, .haiku => true,
1072 .windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
10731073 else => false,
10741074 };
10751075 if (have_pread_but_not_preadv) {
......@@ -1211,7 +1211,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
12111211
12121212 const max_count = switch (native_os) {
12131213 .linux => 0x7ffff000,
1214 .macos, .ios, .watchos, .tvos => maxInt(i32),
1214 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
12151215 else => maxInt(isize),
12161216 };
12171217 while (true) {
......@@ -1370,7 +1370,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
13701370 // Prevent EINVAL.
13711371 const max_count = switch (native_os) {
13721372 .linux => 0x7ffff000,
1373 .macos, .ios, .watchos, .tvos => maxInt(i32),
1373 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
13741374 else => maxInt(isize),
13751375 };
13761376
......@@ -1423,7 +1423,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
14231423/// If `iov.len` is larger than `IOV_MAX`, a partial write will occur.
14241424pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usize {
14251425 const have_pwrite_but_not_pwritev = switch (native_os) {
1426 .windows, .macos, .ios, .watchos, .tvos, .haiku => true,
1426 .windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
14271427 else => false,
14281428 };
14291429
......@@ -1846,7 +1846,7 @@ pub fn execveZ(
18461846 .NOTDIR => return error.NotDir,
18471847 .TXTBSY => return error.FileBusy,
18481848 else => |err| switch (native_os) {
1849 .macos, .ios, .tvos, .watchos => switch (err) {
1849 .macos, .ios, .tvos, .watchos, .visionos => switch (err) {
18501850 .BADEXEC => return error.InvalidExe,
18511851 .BADARCH => return error.InvalidExe,
18521852 else => return unexpectedErrno(err),
......@@ -6123,7 +6123,7 @@ pub fn sendfile(
61236123 const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1);
61246124 const max_count = switch (native_os) {
61256125 .linux => 0x7ffff000,
6126 .macos, .ios, .watchos, .tvos => maxInt(i32),
6126 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
61276127 else => maxInt(size_t),
61286128 };
61296129
......@@ -6268,7 +6268,7 @@ pub fn sendfile(
62686268 }
62696269 }
62706270 },
6271 .macos, .ios, .tvos, .watchos => sf: {
6271 .macos, .ios, .tvos, .watchos, .visionos => sf: {
62726272 var hdtr_data: std.c.sf_hdtr = undefined;
62736273 var hdtr: ?*std.c.sf_hdtr = null;
62746274 if (headers.len != 0 or trailers.len != 0) {
......@@ -7244,7 +7244,7 @@ pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError!
72447244 else => |err| return unexpectedErrno(err),
72457245 },
72467246
7247 .macos, .ios, .tvos, .watchos => switch (errno(std.c.ptrace(
7247 .macos, .ios, .tvos, .watchos, .visionos => switch (errno(std.c.ptrace(
72487248 @intCast(request),
72497249 pid,
72507250 @ptrFromInt(addr),
lib/std/process.zig+2-1
......@@ -1456,6 +1456,7 @@ pub fn getUserInfo(name: []const u8) !UserInfo {
14561456 .linux,
14571457 .macos,
14581458 .watchos,
1459 .visionos,
14591460 .tvos,
14601461 .ios,
14611462 .freebsd,
......@@ -1599,7 +1600,7 @@ pub const can_execv = switch (native_os) {
15991600
16001601/// Tells whether spawning child processes is supported (e.g. via ChildProcess)
16011602pub const can_spawn = switch (native_os) {
1602 .wasi, .watchos, .tvos => false,
1603 .wasi, .watchos, .tvos, .visionos => false,
16031604 else => true,
16041605};
16051606
lib/std/start.zig+1
......@@ -576,6 +576,7 @@ fn maybeIgnoreSigpipe() void {
576576 .ios,
577577 .watchos,
578578 .tvos,
579 .visionos,
579580 .dragonfly,
580581 .freebsd,
581582 => true,
lib/std/time.zig+1-1
......@@ -205,7 +205,7 @@ pub const Instant = struct {
205205 },
206206 // On darwin, use UPTIME_RAW instead of MONOTONIC as it ticks while
207207 // suspended.
208 .macos, .ios, .tvos, .watchos => posix.CLOCK.UPTIME_RAW,
208 .macos, .ios, .tvos, .watchos, .visionos => posix.CLOCK.UPTIME_RAW,
209209 // On freebsd derivatives, use MONOTONIC_FAST as currently there's
210210 // no precision tradeoff.
211211 .freebsd, .dragonfly => posix.CLOCK.MONOTONIC_FAST,
lib/std/zig/LibCDirs.zig+1-1
......@@ -222,7 +222,7 @@ pub fn detectFromBuilding(
222222fn libCGenericName(target: std.Target) [:0]const u8 {
223223 switch (target.os.tag) {
224224 .windows => return "mingw",
225 .macos, .ios, .tvos, .watchos => return "darwin",
225 .macos, .ios, .tvos, .watchos, .visionos => return "darwin",
226226 else => {},
227227 }
228228 switch (target.abi) {
lib/std/zig/system/darwin.zig+1
......@@ -45,6 +45,7 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 {
4545 },
4646 .watchos => if (is_simulator_abi) "watchsimulator" else "watchos",
4747 .tvos => if (is_simulator_abi) "appletvsimulator" else "appletvos",
48 .visionos => if (is_simulator_abi) "xrsimulator" else "xros",
4849 else => return null,
4950 };
5051 const argv = &[_][]const u8{ "/usr/bin/xcrun", "--sdk", sdk, "--show-sdk-path" };
src/Compilation.zig+1-1
......@@ -5280,7 +5280,7 @@ pub fn addCCArgs(
52805280 // doesn't matter which one gets overridden.
52815281 argv.appendAssumeCapacity("-Wno-overriding-option");
52825282 },
5283 .ios, .tvos, .watchos => switch (target.cpu.arch) {
5283 .ios => switch (target.cpu.arch) {
52845284 // Pass the proper -m<os>-version-min argument for darwin.
52855285 .x86, .x86_64 => {
52865286 const ver = target.os.version_range.semver.min;
src/codegen/llvm.zig+4-4
......@@ -145,7 +145,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
145145 .driverkit => "driverkit",
146146 .shadermodel => "shadermodel",
147147 .liteos => "liteos",
148 .xros => "xros",
148 .visionos => "xros",
149149 .serenity => "serenity",
150150 .vulkan => "vulkan",
151151
......@@ -256,7 +256,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
256256 .elfiamcu => .ELFIAMCU,
257257 .tvos => .TvOS,
258258 .watchos => .WatchOS,
259 .xros => .XROS,
259 .visionos => .XROS,
260260 .mesa3d => .Mesa3D,
261261 .amdpal => .AMDPAL,
262262 .hermit => .HermitCore,
......@@ -618,7 +618,7 @@ const DataLayoutBuilder = struct {
618618 abi = size;
619619 pref = size;
620620 } else switch (self.target.os.tag) {
621 .macos, .ios => {},
621 .macos, .ios, .watchos, .tvos, .visionos => {},
622622 .uefi, .windows => {
623623 pref = size;
624624 force_abi = size >= 32;
......@@ -11578,7 +11578,7 @@ fn ccAbiPromoteInt(
1157811578 else => return null,
1157911579 };
1158011580 return switch (target.os.tag) {
11581 .macos => switch (int_info.bits) {
11581 .macos, .ios, .watchos, .tvos, .visionos => switch (int_info.bits) {
1158211582 0...16 => int_info.signedness,
1158311583 else => null,
1158411584 },
src/libtsan.zig+1-1
......@@ -125,7 +125,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v
125125 }
126126
127127 const platform_tsan_sources = switch (target.os.tag) {
128 .ios, .macos, .watchos, .tvos => &darwin_tsan_sources,
128 .ios, .macos, .watchos, .tvos, .visionos => &darwin_tsan_sources,
129129 .windows => &windows_tsan_sources,
130130 else => &unix_tsan_sources,
131131 };
src/link/MachO.zig+26-10
......@@ -891,6 +891,10 @@ pub fn resolveLibSystem(
891891 },
892892 };
893893
894 for (self.lib_dirs) |dir| {
895 if (try accessLibPath(arena, &test_path, &checked_paths, dir, "System")) break :success;
896 }
897
894898 try self.reportMissingLibraryError(checked_paths.items, "unable to find libSystem system library", .{});
895899 return error.MissingLibSystem;
896900 }
......@@ -3676,10 +3680,17 @@ pub inline fn getPageSize(self: MachO) u16 {
36763680
36773681pub fn requiresCodeSig(self: MachO) bool {
36783682 if (self.entitlements) |_| return true;
3683 // TODO: enable once we support this linker option
36793684 // if (self.options.adhoc_codesign) |cs| return cs;
3680 return switch (self.getTarget().cpu.arch) {
3681 .aarch64 => true,
3682 else => false,
3685 const target = self.getTarget();
3686 return switch (target.cpu.arch) {
3687 .aarch64 => switch (target.os.tag) {
3688 .macos => true,
3689 .watchos, .tvos, .ios, .visionos => target.abi == .simulator,
3690 else => false,
3691 },
3692 .x86_64 => false,
3693 else => unreachable,
36833694 };
36843695}
36853696
......@@ -4424,6 +4435,7 @@ pub const Platform = struct {
44244435 .TVOS, .TVOSSIMULATOR => .tvos,
44254436 .WATCHOS, .WATCHOSSIMULATOR => .watchos,
44264437 .MACCATALYST => .ios,
4438 .VISIONOS, .VISIONOSSIMULATOR => .visionos,
44274439 else => @panic("TODO"),
44284440 },
44294441 .abi = switch (cmd.platform) {
......@@ -4431,6 +4443,7 @@ pub const Platform = struct {
44314443 .IOSSIMULATOR,
44324444 .TVOSSIMULATOR,
44334445 .WATCHOSSIMULATOR,
4446 .VISIONOSSIMULATOR,
44344447 => .simulator,
44354448 else => .none,
44364449 },
......@@ -4481,6 +4494,7 @@ pub const Platform = struct {
44814494 },
44824495 .tvos => if (plat.abi == .simulator) .TVOSSIMULATOR else .TVOS,
44834496 .watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS,
4497 .visionos => if (plat.abi == .simulator) .VISIONOSSIMULATOR else .VISIONOS,
44844498 else => unreachable,
44854499 };
44864500 }
......@@ -4549,13 +4563,15 @@ const SupportedPlatforms = struct {
45494563// Source: https://github.com/apple-oss-distributions/ld64/blob/59a99ab60399c5e6c49e6945a9e1049c42b71135/src/ld/PlatformSupport.cpp#L52
45504564// zig fmt: off
45514565const supported_platforms = [_]SupportedPlatforms{
4552 .{ .macos, .none, 0xA0E00, 0xA0800 },
4553 .{ .ios, .none, 0xC0000, 0x70000 },
4554 .{ .tvos, .none, 0xC0000, 0x70000 },
4555 .{ .watchos, .none, 0x50000, 0x20000 },
4556 .{ .ios, .simulator, 0xD0000, 0x80000 },
4557 .{ .tvos, .simulator, 0xD0000, 0x80000 },
4558 .{ .watchos, .simulator, 0x60000, 0x20000 },
4566 .{ .macos, .none, 0xA0E00, 0xA0800 },
4567 .{ .ios, .none, 0xC0000, 0x70000 },
4568 .{ .tvos, .none, 0xC0000, 0x70000 },
4569 .{ .watchos, .none, 0x50000, 0x20000 },
4570 .{ .visionos, .none, 0x10000, 0x10000 },
4571 .{ .ios, .simulator, 0xD0000, 0x80000 },
4572 .{ .tvos, .simulator, 0xD0000, 0x80000 },
4573 .{ .watchos, .simulator, 0x60000, 0x20000 },
4574 .{ .visionos, .simulator, 0x10000, 0x10000 },
45594575};
45604576// zig fmt: on
45614577
src/link/MachO/Dylib.zig+3-1
......@@ -671,7 +671,7 @@ pub const TargetMatcher = struct {
671671 try self.target_strings.append(allocator, apple_string);
672672
673673 switch (platform) {
674 .IOSSIMULATOR, .TVOSSIMULATOR, .WATCHOSSIMULATOR => {
674 .IOSSIMULATOR, .TVOSSIMULATOR, .WATCHOSSIMULATOR, .VISIONOSSIMULATOR => {
675675 // For Apple simulator targets, linking gets tricky as we need to link against the simulator
676676 // hosts dylibs too.
677677 const host_target = try targetToAppleString(allocator, cpu_arch, .MACOS);
......@@ -714,9 +714,11 @@ pub const TargetMatcher = struct {
714714 .IOS => "ios",
715715 .TVOS => "tvos",
716716 .WATCHOS => "watchos",
717 .VISIONOS => "xros",
717718 .IOSSIMULATOR => "ios-simulator",
718719 .TVOSSIMULATOR => "tvos-simulator",
719720 .WATCHOSSIMULATOR => "watchos-simulator",
721 .VISIONOSSIMULATOR => "xros-simulator",
720722 .BRIDGEOS => "bridgeos",
721723 .MACCATALYST => "maccatalyst",
722724 .DRIVERKIT => "driverkit",
src/main.zig+1-1
......@@ -4432,7 +4432,7 @@ fn runOrTestHotSwap(
44324432 }
44334433
44344434 switch (builtin.target.os.tag) {
4435 .macos, .ios, .tvos, .watchos => {
4435 .macos, .ios, .tvos, .watchos, .visionos => {
44364436 const PosixSpawn = @import("DarwinPosixSpawn.zig");
44374437
44384438 var attr = try PosixSpawn.Attr.init();
src/target.zig+1
......@@ -26,6 +26,7 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {
2626 .ios,
2727 .watchos,
2828 .tvos,
29 .visionos,
2930 .freestanding,
3031 .wasi, // Wasm/WASI currently doesn't offer support for libunwind, so don't link it.
3132 => false,
test/llvm_targets.zig+9
......@@ -7,6 +7,12 @@ const targets = [_]std.Target.Query{
77 .{ .cpu_arch = .aarch64, .os_tag = .ios, .abi = .simulator },
88 .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .none },
99 .{ .cpu_arch = .aarch64, .os_tag = .macos, .abi = .none },
10 .{ .cpu_arch = .aarch64, .os_tag = .watchos, .abi = .none },
11 .{ .cpu_arch = .aarch64, .os_tag = .watchos, .abi = .simulator },
12 .{ .cpu_arch = .aarch64, .os_tag = .tvos, .abi = .none },
13 .{ .cpu_arch = .aarch64, .os_tag = .tvos, .abi = .simulator },
14 .{ .cpu_arch = .aarch64, .os_tag = .visionos, .abi = .none },
15 .{ .cpu_arch = .aarch64, .os_tag = .visionos, .abi = .simulator },
1016 .{ .cpu_arch = .aarch64, .os_tag = .uefi, .abi = .none },
1117 .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .gnu },
1218 .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .msvc },
......@@ -118,6 +124,9 @@ const targets = [_]std.Target.Query{
118124 .cpu_features_sub = std.Target.x86.featureSet(&.{ .mmx, .sse, .sse2, .avx, .avx2 }),
119125 },
120126 .{ .cpu_arch = .x86_64, .os_tag = .ios, .abi = .simulator },
127 .{ .cpu_arch = .x86_64, .os_tag = .watchos, .abi = .simulator },
128 .{ .cpu_arch = .x86_64, .os_tag = .tvos, .abi = .simulator },
129 .{ .cpu_arch = .x86_64, .os_tag = .visionos, .abi = .simulator },
121130 .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .none },
122131 .{ .cpu_arch = .x86_64, .os_tag = .macos, .abi = .none },
123132 .{ .cpu_arch = .x86_64, .os_tag = .uefi, .abi = .none },