mirror of
https://github.com/ziglang/zig.git
synced 2024-11-13 23:52:57 +00:00
add partial support for Apple's VisionOS - blocked by LLVM 18
This commit is contained in:
parent
12c0f34c97
commit
ecc56a6c03
@ -718,7 +718,7 @@ fn addCmakeCfgOptionsToExe(
|
||||
};
|
||||
exe.linkSystemLibrary("unwind");
|
||||
},
|
||||
.ios, .macos, .watchos, .tvos => {
|
||||
.ios, .macos, .watchos, .tvos, .visionos => {
|
||||
exe.linkLibCpp();
|
||||
},
|
||||
.windows => {
|
||||
|
4
lib/compiler/aro/aro/Compilation.zig
vendored
4
lib/compiler/aro/aro/Compilation.zig
vendored
@ -912,12 +912,12 @@ fn generateVaListType(comp: *Compilation) !Type {
|
||||
const kind: Kind = switch (comp.target.cpu.arch) {
|
||||
.aarch64 => switch (comp.target.os.tag) {
|
||||
.windows => @as(Kind, .char_ptr),
|
||||
.ios, .macos, .tvos, .watchos => .char_ptr,
|
||||
.ios, .macos, .tvos, .watchos, .visionos => .char_ptr,
|
||||
else => .aarch64_va_list,
|
||||
},
|
||||
.sparc, .wasm32, .wasm64, .bpfel, .bpfeb, .riscv32, .riscv64, .avr, .spirv32, .spirv64 => .void_ptr,
|
||||
.powerpc => switch (comp.target.os.tag) {
|
||||
.ios, .macos, .tvos, .watchos, .aix => @as(Kind, .char_ptr),
|
||||
.ios, .macos, .tvos, .watchos, .visionos, .aix => @as(Kind, .char_ptr),
|
||||
else => return Type{ .specifier = .void }, // unknown
|
||||
},
|
||||
.x86, .msp430 => .char_ptr,
|
||||
|
1
lib/compiler/aro/aro/target.zig
vendored
1
lib/compiler/aro/aro/target.zig
vendored
@ -706,6 +706,7 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
|
||||
.ios => "ios",
|
||||
.tvos => "tvos",
|
||||
.watchos => "watchos",
|
||||
.visionos => "xros",
|
||||
.driverkit => "driverkit",
|
||||
.shadermodel => "shadermodel",
|
||||
.liteos => "liteos",
|
||||
|
@ -45,7 +45,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
|
||||
else => false,
|
||||
};
|
||||
const apple = switch (os) {
|
||||
.ios, .macos, .watchos, .tvos => true,
|
||||
.ios, .macos, .watchos, .tvos, .visionos => true,
|
||||
else => false,
|
||||
};
|
||||
if (x86) {
|
||||
|
@ -46,6 +46,7 @@ pub const Os = struct {
|
||||
elfiamcu,
|
||||
tvos,
|
||||
watchos,
|
||||
visionos,
|
||||
driverkit,
|
||||
mesa3d,
|
||||
contiki,
|
||||
@ -65,7 +66,7 @@ pub const Os = struct {
|
||||
|
||||
pub inline fn isDarwin(tag: Tag) bool {
|
||||
return switch (tag) {
|
||||
.ios, .macos, .watchos, .tvos => true,
|
||||
.ios, .macos, .watchos, .tvos, .visionos => true,
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
@ -316,6 +317,12 @@ pub const Os = struct {
|
||||
.max = .{ .major = 17, .minor = 1, .patch = 0 },
|
||||
},
|
||||
},
|
||||
.visionos => return .{
|
||||
.semver = .{
|
||||
.min = .{ .major = 1, .minor = 0, .patch = 0 },
|
||||
.max = .{ .major = 1, .minor = 0, .patch = 0 },
|
||||
},
|
||||
},
|
||||
.netbsd => return .{
|
||||
.semver = .{
|
||||
.min = .{ .major = 8, .minor = 0, .patch = 0 },
|
||||
@ -380,6 +387,7 @@ pub const Os = struct {
|
||||
.ios,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.visionos,
|
||||
.netbsd,
|
||||
.openbsd,
|
||||
.dragonfly,
|
||||
@ -416,6 +424,7 @@ pub const Os = struct {
|
||||
.ios,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.visionos,
|
||||
.dragonfly,
|
||||
.openbsd,
|
||||
.haiku,
|
||||
@ -577,6 +586,7 @@ pub const Abi = enum {
|
||||
.ios,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.visionos,
|
||||
.driverkit,
|
||||
.shadermodel,
|
||||
.liteos, // TODO: audit this
|
||||
@ -652,7 +662,7 @@ pub const ObjectFormat = enum {
|
||||
pub fn default(os_tag: Os.Tag, cpu_arch: Cpu.Arch) ObjectFormat {
|
||||
return switch (os_tag) {
|
||||
.windows, .uefi => .coff,
|
||||
.ios, .macos, .watchos, .tvos => .macho,
|
||||
.ios, .macos, .watchos, .tvos, .visionos => .macho,
|
||||
.plan9 => .plan9,
|
||||
else => return switch (cpu_arch) {
|
||||
.wasm32, .wasm64 => .wasm,
|
||||
@ -1525,6 +1535,7 @@ pub inline fn hasDynamicLinker(self: Target) bool {
|
||||
.ios,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.visionos,
|
||||
.macos,
|
||||
.uefi,
|
||||
.windows,
|
||||
@ -1729,6 +1740,7 @@ pub fn standardDynamicLinkerPath_cpu_os_abi(cpu: Cpu, os_tag: Os.Tag, abi: Abi)
|
||||
.tvos,
|
||||
.watchos,
|
||||
.macos,
|
||||
.visionos,
|
||||
=> return copy(&result, "/usr/lib/dyld"),
|
||||
|
||||
// Operating systems in this list have been verified as not having a standard
|
||||
@ -2314,7 +2326,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
|
||||
},
|
||||
},
|
||||
|
||||
.macos, .ios, .tvos, .watchos => switch (c_type) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => switch (c_type) {
|
||||
.char => return 8,
|
||||
.short, .ushort => return 16,
|
||||
.int, .uint, .float => return 32,
|
||||
|
@ -171,6 +171,7 @@ fn updateOsVersionRange(self: *Query, os: Target.Os) void {
|
||||
.ios,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.visionos,
|
||||
.netbsd,
|
||||
.openbsd,
|
||||
.dragonfly,
|
||||
@ -613,6 +614,7 @@ fn parseOs(result: *Query, diags: *ParseOptions.Diagnostics, text: []const u8) !
|
||||
.ios,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.visionos,
|
||||
.netbsd,
|
||||
.openbsd,
|
||||
.linux,
|
||||
|
@ -39,7 +39,7 @@ impl: Impl,
|
||||
pub const max_name_len = switch (native_os) {
|
||||
.linux => 15,
|
||||
.windows => 31,
|
||||
.macos, .ios, .watchos, .tvos => 63,
|
||||
.macos, .ios, .watchos, .tvos, .visionos => 63,
|
||||
.netbsd => 31,
|
||||
.freebsd => 15,
|
||||
.openbsd => 23,
|
||||
@ -114,7 +114,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
|
||||
else => |err| return windows.unexpectedStatus(err),
|
||||
}
|
||||
},
|
||||
.macos, .ios, .watchos, .tvos => if (use_pthreads) {
|
||||
.macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
|
||||
// There doesn't seem to be a way to set the name for an arbitrary thread, only the current one.
|
||||
if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;
|
||||
|
||||
@ -217,7 +217,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
|
||||
else => |err| return windows.unexpectedStatus(err),
|
||||
}
|
||||
},
|
||||
.macos, .ios, .watchos, .tvos => if (use_pthreads) {
|
||||
.macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
|
||||
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
|
||||
switch (err) {
|
||||
.SUCCESS => return std.mem.sliceTo(buffer, 0),
|
||||
@ -266,7 +266,7 @@ pub const Id = switch (native_os) {
|
||||
.haiku,
|
||||
.wasi,
|
||||
=> u32,
|
||||
.macos, .ios, .watchos, .tvos => u64,
|
||||
.macos, .ios, .watchos, .tvos, .visionos => u64,
|
||||
.windows => windows.DWORD,
|
||||
else => usize,
|
||||
};
|
||||
@ -588,7 +588,7 @@ const PosixThreadImpl = struct {
|
||||
.linux => {
|
||||
return LinuxThreadImpl.getCurrentId();
|
||||
},
|
||||
.macos, .ios, .watchos, .tvos => {
|
||||
.macos, .ios, .watchos, .tvos, .visionos => {
|
||||
var thread_id: u64 = undefined;
|
||||
// Pass thread=null to get the current thread ID.
|
||||
assert(c.pthread_threadid_np(null, &thread_id) == 0);
|
||||
@ -1434,7 +1434,7 @@ test "setName, getName" {
|
||||
context.test_done_event.wait();
|
||||
|
||||
switch (native_os) {
|
||||
.macos, .ios, .watchos, .tvos => {
|
||||
.macos, .ios, .watchos, .tvos, .visionos => {
|
||||
const res = thread.setName("foobar");
|
||||
try std.testing.expectError(error.Unsupported, res);
|
||||
},
|
||||
|
@ -597,7 +597,7 @@ pub const VaListX86_64 = extern struct {
|
||||
pub const VaList = switch (builtin.cpu.arch) {
|
||||
.aarch64, .aarch64_be => switch (builtin.os.tag) {
|
||||
.windows => *u8,
|
||||
.ios, .macos, .tvos, .watchos => *u8,
|
||||
.ios, .macos, .tvos, .watchos, .visionos => *u8,
|
||||
else => @compileError("disabled due to miscompilations"), // VaListAarch64,
|
||||
},
|
||||
.arm => switch (builtin.os.tag) {
|
||||
|
@ -35,7 +35,7 @@ pub inline fn versionCheck(comptime glibc_version: std.SemanticVersion) bool {
|
||||
pub usingnamespace switch (native_os) {
|
||||
.linux => @import("c/linux.zig"),
|
||||
.windows => @import("c/windows.zig"),
|
||||
.macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
|
||||
.macos, .ios, .tvos, .watchos, .visionos => @import("c/darwin.zig"),
|
||||
.freebsd, .kfreebsd => @import("c/freebsd.zig"),
|
||||
.netbsd => @import("c/netbsd.zig"),
|
||||
.dragonfly => @import("c/dragonfly.zig"),
|
||||
@ -63,7 +63,7 @@ pub const pthread_mutex_t = switch (native_os) {
|
||||
else => @compileError("unsupported ABI"),
|
||||
};
|
||||
},
|
||||
.macos, .ios, .tvos, .watchos => extern struct {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
|
||||
sig: c_long = 0x32AAABA7,
|
||||
data: [data_len]u8 = [_]u8{0} ** data_len,
|
||||
|
||||
@ -113,7 +113,7 @@ pub const pthread_cond_t = switch (native_os) {
|
||||
.linux => extern struct {
|
||||
data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,
|
||||
},
|
||||
.macos, .ios, .tvos, .watchos => extern struct {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
|
||||
sig: c_long = 0x3CB0B1BB,
|
||||
data: [data_len]u8 = [_]u8{0} ** data_len,
|
||||
const data_len = if (@sizeOf(usize) == 8) 40 else 24;
|
||||
@ -166,7 +166,7 @@ pub const pthread_rwlock_t = switch (native_os) {
|
||||
data: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,
|
||||
},
|
||||
},
|
||||
.macos, .ios, .tvos, .watchos => extern struct {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
|
||||
sig: c_long = 0x2DA8B3B4,
|
||||
data: [192]u8 = [_]u8{0} ** 192,
|
||||
},
|
||||
@ -214,7 +214,7 @@ pub const AT = switch (native_os) {
|
||||
/// Remove directory instead of unlinking file
|
||||
pub const REMOVEDIR = 0x200;
|
||||
},
|
||||
.macos, .ios, .tvos, .watchos => struct {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => struct {
|
||||
pub const FDCWD = -2;
|
||||
/// Use effective ids in access check
|
||||
pub const EACCESS = 0x0010;
|
||||
@ -458,7 +458,7 @@ pub const O = switch (native_os) {
|
||||
DIRECTORY: bool = false,
|
||||
_: u10 = 0,
|
||||
},
|
||||
.macos, .ios, .tvos, .watchos => packed struct(u32) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
|
||||
ACCMODE: std.posix.ACCMODE = .RDONLY,
|
||||
NONBLOCK: bool = false,
|
||||
APPEND: bool = false,
|
||||
@ -620,7 +620,7 @@ pub const MAP = switch (native_os) {
|
||||
NORESERVE: bool = false,
|
||||
_: u27 = 0,
|
||||
},
|
||||
.macos, .ios, .tvos, .watchos => packed struct(u32) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
|
||||
TYPE: enum(u4) {
|
||||
SHARED = 0x01,
|
||||
PRIVATE = 0x02,
|
||||
@ -685,7 +685,7 @@ pub const cc_t = u8;
|
||||
/// Indices into the `cc` array in the `termios` struct.
|
||||
pub const V = switch (native_os) {
|
||||
.linux => linux.V,
|
||||
.macos, .ios, .tvos, .watchos, .netbsd, .openbsd => enum {
|
||||
.macos, .ios, .tvos, .watchos, .visionos, .netbsd, .openbsd => enum {
|
||||
EOF,
|
||||
EOL,
|
||||
EOL2,
|
||||
@ -784,7 +784,7 @@ pub const V = switch (native_os) {
|
||||
|
||||
pub const NCCS = switch (native_os) {
|
||||
.linux => linux.NCCS,
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
|
||||
.macos, .ios, .tvos, .watchos, .visionos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
|
||||
.haiku => 11,
|
||||
.solaris, .illumos => 19,
|
||||
.emscripten, .wasi => 32,
|
||||
@ -793,7 +793,7 @@ pub const NCCS = switch (native_os) {
|
||||
|
||||
pub const termios = switch (native_os) {
|
||||
.linux => linux.termios,
|
||||
.macos, .ios, .tvos, .watchos => extern struct {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
|
||||
iflag: tc_iflag_t,
|
||||
oflag: tc_oflag_t,
|
||||
cflag: tc_cflag_t,
|
||||
@ -843,7 +843,7 @@ pub const termios = switch (native_os) {
|
||||
|
||||
pub const tc_iflag_t = switch (native_os) {
|
||||
.linux => linux.tc_iflag_t,
|
||||
.macos, .ios, .tvos, .watchos => packed struct(u64) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
|
||||
IGNBRK: bool = false,
|
||||
BRKINT: bool = false,
|
||||
IGNPAR: bool = false,
|
||||
@ -953,7 +953,7 @@ pub const tc_iflag_t = switch (native_os) {
|
||||
|
||||
pub const tc_oflag_t = switch (native_os) {
|
||||
.linux => linux.tc_oflag_t,
|
||||
.macos, .ios, .tvos, .watchos => packed struct(u64) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
|
||||
OPOST: bool = false,
|
||||
ONLCR: bool = false,
|
||||
OXTABS: bool = false,
|
||||
@ -1050,7 +1050,7 @@ pub const CSIZE = switch (native_os) {
|
||||
|
||||
pub const tc_cflag_t = switch (native_os) {
|
||||
.linux => linux.tc_cflag_t,
|
||||
.macos, .ios, .tvos, .watchos => packed struct(u64) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
|
||||
CIGNORE: bool = false,
|
||||
_1: u5 = 0,
|
||||
CSTOPB: bool = false,
|
||||
@ -1186,7 +1186,7 @@ pub const tc_cflag_t = switch (native_os) {
|
||||
|
||||
pub const tc_lflag_t = switch (native_os) {
|
||||
.linux => linux.tc_lflag_t,
|
||||
.macos, .ios, .tvos, .watchos => packed struct(u64) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
|
||||
ECHOKE: bool = false,
|
||||
ECHOE: bool = false,
|
||||
ECHOK: bool = false,
|
||||
@ -1312,7 +1312,7 @@ pub const tc_lflag_t = switch (native_os) {
|
||||
|
||||
pub const speed_t = switch (native_os) {
|
||||
.linux => linux.speed_t,
|
||||
.macos, .ios, .tvos, .watchos, .openbsd => enum(u64) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos, .openbsd => enum(u64) {
|
||||
B0 = 0,
|
||||
B50 = 50,
|
||||
B75 = 75,
|
||||
@ -1535,7 +1535,7 @@ pub const fstatat = switch (native_os) {
|
||||
};
|
||||
|
||||
pub const getdirentries = switch (native_os) {
|
||||
.macos, .ios, .tvos, .watchos => private.__getdirentries64,
|
||||
.macos, .ios, .tvos, .watchos, .visionos => private.__getdirentries64,
|
||||
else => private.getdirentries,
|
||||
};
|
||||
|
||||
@ -1569,7 +1569,7 @@ pub const readdir = switch (native_os) {
|
||||
};
|
||||
|
||||
pub const realpath = switch (native_os) {
|
||||
.macos, .ios, .tvos, .watchos => private.@"realpath$DARWIN_EXTSN",
|
||||
.macos, .ios, .tvos, .watchos, .visionos => private.@"realpath$DARWIN_EXTSN",
|
||||
else => private.realpath,
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,7 @@ const os_has_fork = switch (native_os) {
|
||||
.illumos,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.visionos,
|
||||
.haiku,
|
||||
=> true,
|
||||
|
||||
|
@ -706,7 +706,7 @@ pub const StackIterator = struct {
|
||||
const unwind_state = &self.unwind_state.?;
|
||||
const module = try unwind_state.debug_info.getModuleForAddress(unwind_state.dwarf_context.pc);
|
||||
switch (native_os) {
|
||||
.macos, .ios, .watchos, .tvos => {
|
||||
.macos, .ios, .watchos, .tvos, .visionos => {
|
||||
// __unwind_info is a requirement for unwinding on Darwin. It may fall back to DWARF, but unwinding
|
||||
// via DWARF before attempting to use the compact unwind info will produce incorrect results.
|
||||
if (module.unwind_info) |unwind_info| {
|
||||
@ -2129,7 +2129,7 @@ pub const DebugInfo = struct {
|
||||
};
|
||||
|
||||
pub const ModuleDebugInfo = switch (native_os) {
|
||||
.macos, .ios, .watchos, .tvos => struct {
|
||||
.macos, .ios, .watchos, .tvos, .visionos => struct {
|
||||
base_address: usize,
|
||||
vmaddr_slide: usize,
|
||||
mapped_memory: []align(mem.page_size) const u8,
|
||||
|
@ -16,7 +16,7 @@ pub const DynLib = struct {
|
||||
else
|
||||
DlDynLib,
|
||||
.windows => WindowsDynLib,
|
||||
.macos, .tvos, .watchos, .ios, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynLib,
|
||||
.macos, .tvos, .watchos, .ios, .visionos, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynLib,
|
||||
else => @compileError("unsupported platform"),
|
||||
};
|
||||
|
||||
@ -461,7 +461,7 @@ test "dynamic_library" {
|
||||
const libname = switch (native_os) {
|
||||
.linux, .freebsd, .openbsd, .solaris, .illumos => "invalid_so.so",
|
||||
.windows => "invalid_dll.dll",
|
||||
.macos, .tvos, .watchos, .ios => "invalid_dylib.dylib",
|
||||
.macos, .tvos, .watchos, .ios, .visionos => "invalid_dylib.dylib",
|
||||
else => return error.SkipZigTest,
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,7 @@ const native_endian = builtin.cpu.arch.endian();
|
||||
pub const page_size = switch (builtin.cpu.arch) {
|
||||
.wasm32, .wasm64 => 64 * 1024,
|
||||
.aarch64 => switch (builtin.os.tag) {
|
||||
.macos, .ios, .watchos, .tvos => 16 * 1024,
|
||||
.macos, .ios, .watchos, .tvos, .visionos => 16 * 1024,
|
||||
else => 4 * 1024,
|
||||
},
|
||||
.sparc64 => 8 * 1024,
|
||||
|
@ -76,6 +76,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {
|
||||
.ios,
|
||||
.watchos,
|
||||
.tvos,
|
||||
.visionos,
|
||||
.linux,
|
||||
.solaris,
|
||||
.illumos,
|
||||
@ -110,7 +111,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
|
||||
const end_index = std.unicode.wtf16LeToWtf8(out_buffer, wide_slice);
|
||||
return out_buffer[0..end_index];
|
||||
},
|
||||
.macos, .ios, .watchos, .tvos => {
|
||||
.macos, .ios, .watchos, .tvos, .visionos => {
|
||||
// On macOS, we can use F.GETPATH fcntl command to query the OS for
|
||||
// the path to the file descriptor.
|
||||
@memset(out_buffer[0..MAX_PATH_BYTES], 0);
|
||||
|
@ -604,7 +604,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
|
||||
}
|
||||
}
|
||||
switch (native_os) {
|
||||
.netbsd, .openbsd, .macos, .ios, .tvos, .watchos => {
|
||||
.netbsd, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => {
|
||||
system.arc4random_buf(buffer.ptr, buffer.len);
|
||||
return;
|
||||
},
|
||||
@ -823,7 +823,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
|
||||
// Prevents EINVAL.
|
||||
const max_count = switch (native_os) {
|
||||
.linux => 0x7ffff000,
|
||||
.macos, .ios, .watchos, .tvos => maxInt(i32),
|
||||
.macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
|
||||
else => maxInt(isize),
|
||||
};
|
||||
while (true) {
|
||||
@ -962,7 +962,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
|
||||
// Prevent EINVAL.
|
||||
const max_count = switch (native_os) {
|
||||
.linux => 0x7ffff000,
|
||||
.macos, .ios, .watchos, .tvos => maxInt(i32),
|
||||
.macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
|
||||
else => maxInt(isize),
|
||||
};
|
||||
|
||||
@ -1069,7 +1069,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
|
||||
/// On these systems, the read races with concurrent writes to the same file descriptor.
|
||||
pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
|
||||
const have_pread_but_not_preadv = switch (native_os) {
|
||||
.windows, .macos, .ios, .watchos, .tvos, .haiku => true,
|
||||
.windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
|
||||
else => false,
|
||||
};
|
||||
if (have_pread_but_not_preadv) {
|
||||
@ -1211,7 +1211,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
|
||||
|
||||
const max_count = switch (native_os) {
|
||||
.linux => 0x7ffff000,
|
||||
.macos, .ios, .watchos, .tvos => maxInt(i32),
|
||||
.macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
|
||||
else => maxInt(isize),
|
||||
};
|
||||
while (true) {
|
||||
@ -1370,7 +1370,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
|
||||
// Prevent EINVAL.
|
||||
const max_count = switch (native_os) {
|
||||
.linux => 0x7ffff000,
|
||||
.macos, .ios, .watchos, .tvos => maxInt(i32),
|
||||
.macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
|
||||
else => maxInt(isize),
|
||||
};
|
||||
|
||||
@ -1423,7 +1423,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
|
||||
/// If `iov.len` is larger than `IOV_MAX`, a partial write will occur.
|
||||
pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usize {
|
||||
const have_pwrite_but_not_pwritev = switch (native_os) {
|
||||
.windows, .macos, .ios, .watchos, .tvos, .haiku => true,
|
||||
.windows, .macos, .ios, .watchos, .tvos, .visionos, .haiku => true,
|
||||
else => false,
|
||||
};
|
||||
|
||||
@ -1838,7 +1838,7 @@ pub fn execveZ(
|
||||
.NOTDIR => return error.NotDir,
|
||||
.TXTBSY => return error.FileBusy,
|
||||
else => |err| switch (native_os) {
|
||||
.macos, .ios, .tvos, .watchos => switch (err) {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => switch (err) {
|
||||
.BADEXEC => return error.InvalidExe,
|
||||
.BADARCH => return error.InvalidExe,
|
||||
else => return unexpectedErrno(err),
|
||||
@ -6115,7 +6115,7 @@ pub fn sendfile(
|
||||
const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1);
|
||||
const max_count = switch (native_os) {
|
||||
.linux => 0x7ffff000,
|
||||
.macos, .ios, .watchos, .tvos => maxInt(i32),
|
||||
.macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
|
||||
else => maxInt(size_t),
|
||||
};
|
||||
|
||||
@ -6260,7 +6260,7 @@ pub fn sendfile(
|
||||
}
|
||||
}
|
||||
},
|
||||
.macos, .ios, .tvos, .watchos => sf: {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => sf: {
|
||||
var hdtr_data: std.c.sf_hdtr = undefined;
|
||||
var hdtr: ?*std.c.sf_hdtr = null;
|
||||
if (headers.len != 0 or trailers.len != 0) {
|
||||
@ -7236,7 +7236,7 @@ pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError!
|
||||
else => |err| return unexpectedErrno(err),
|
||||
},
|
||||
|
||||
.macos, .ios, .tvos, .watchos => switch (errno(std.c.ptrace(
|
||||
.macos, .ios, .tvos, .watchos, .visionos => switch (errno(std.c.ptrace(
|
||||
@intCast(request),
|
||||
pid,
|
||||
@ptrFromInt(addr),
|
||||
|
@ -1395,6 +1395,7 @@ pub fn getUserInfo(name: []const u8) !UserInfo {
|
||||
.watchos,
|
||||
.tvos,
|
||||
.ios,
|
||||
.visionos,
|
||||
.freebsd,
|
||||
.netbsd,
|
||||
.openbsd,
|
||||
@ -1536,7 +1537,7 @@ pub const can_execv = switch (native_os) {
|
||||
|
||||
/// Tells whether spawning child processes is supported (e.g. via ChildProcess)
|
||||
pub const can_spawn = switch (native_os) {
|
||||
.wasi, .watchos, .tvos => false,
|
||||
.wasi, .watchos, .tvos, .visionos => false,
|
||||
else => true,
|
||||
};
|
||||
|
||||
|
@ -576,6 +576,7 @@ fn maybeIgnoreSigpipe() void {
|
||||
.ios,
|
||||
.watchos,
|
||||
.tvos,
|
||||
.visionos,
|
||||
.dragonfly,
|
||||
.freebsd,
|
||||
=> true,
|
||||
|
@ -205,7 +205,7 @@ pub const Instant = struct {
|
||||
},
|
||||
// On darwin, use UPTIME_RAW instead of MONOTONIC as it ticks while
|
||||
// suspended.
|
||||
.macos, .ios, .tvos, .watchos => posix.CLOCK.UPTIME_RAW,
|
||||
.macos, .ios, .tvos, .watchos, .visionos => posix.CLOCK.UPTIME_RAW,
|
||||
// On freebsd derivatives, use MONOTONIC_FAST as currently there's
|
||||
// no precision tradeoff.
|
||||
.freebsd, .dragonfly => posix.CLOCK.MONOTONIC_FAST,
|
||||
|
@ -222,7 +222,7 @@ pub fn detectFromBuilding(
|
||||
fn libCGenericName(target: std.Target) [:0]const u8 {
|
||||
switch (target.os.tag) {
|
||||
.windows => return "mingw",
|
||||
.macos, .ios, .tvos, .watchos => return "darwin",
|
||||
.macos, .ios, .tvos, .watchos, .visionos => return "darwin",
|
||||
else => {},
|
||||
}
|
||||
switch (target.abi) {
|
||||
|
@ -45,6 +45,7 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 {
|
||||
},
|
||||
.watchos => if (is_simulator_abi) "watchsimulator" else "watchos",
|
||||
.tvos => if (is_simulator_abi) "appletvsimulator" else "appletvos",
|
||||
.visionos => if (is_simulator_abi) "xrsimulator" else "xros",
|
||||
else => return null,
|
||||
};
|
||||
const argv = &[_][]const u8{ "/usr/bin/xcrun", "--sdk", sdk, "--show-sdk-path" };
|
||||
|
@ -5325,6 +5325,12 @@ pub fn addCCArgs(
|
||||
}));
|
||||
},
|
||||
},
|
||||
.visionos => {
|
||||
const ver = target.os.version_range.semver.min;
|
||||
try argv.append(try std.fmt.allocPrint(arena, "-mxros-version-min={d}.{d}.{d}", .{
|
||||
ver.major, ver.minor, ver.patch,
|
||||
}));
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
|
@ -145,6 +145,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
|
||||
.ios => "ios",
|
||||
.tvos => "tvos",
|
||||
.watchos => "watchos",
|
||||
.visionos => "xros",
|
||||
.driverkit => "driverkit",
|
||||
.shadermodel => "shadermodel",
|
||||
.liteos => "liteos",
|
||||
@ -245,6 +246,9 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
|
||||
.elfiamcu => .ELFIAMCU,
|
||||
.tvos => .TvOS,
|
||||
.watchos => .WatchOS,
|
||||
// TODO: blocked by LLVM 18
|
||||
// .visionos => .XROS,
|
||||
.visionos => unreachable,
|
||||
.mesa3d => .Mesa3D,
|
||||
.contiki => .Contiki,
|
||||
.amdpal => .AMDPAL,
|
||||
|
@ -315,6 +315,8 @@ pub const OSType = enum(c_int) {
|
||||
TvOS,
|
||||
WatchOS,
|
||||
DriverKit,
|
||||
// TODO: blocked by LLVM 18
|
||||
// VisionOS,
|
||||
Mesa3D,
|
||||
Contiki,
|
||||
AMDPAL,
|
||||
|
@ -125,7 +125,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v
|
||||
}
|
||||
|
||||
const platform_tsan_sources = switch (target.os.tag) {
|
||||
.ios, .macos, .watchos, .tvos => &darwin_tsan_sources,
|
||||
.ios, .macos, .watchos, .tvos, .visionos => &darwin_tsan_sources,
|
||||
.windows => &windows_tsan_sources,
|
||||
else => &unix_tsan_sources,
|
||||
};
|
||||
|
@ -3674,9 +3674,15 @@ pub inline fn getPageSize(self: MachO) u16 {
|
||||
pub fn requiresCodeSig(self: MachO) bool {
|
||||
if (self.entitlements) |_| return true;
|
||||
// if (self.options.adhoc_codesign) |cs| return cs;
|
||||
return switch (self.getTarget().cpu.arch) {
|
||||
.aarch64 => true,
|
||||
else => false,
|
||||
const target = self.getTarget();
|
||||
return switch (target.cpu.arch) {
|
||||
.aarch64 => switch (target.os.tag) {
|
||||
.macos => true,
|
||||
.watchos, .tvos, .ios, .visionos => target.abi == .simulator,
|
||||
else => false,
|
||||
},
|
||||
.x86_64 => false,
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
|
||||
@ -4377,6 +4383,7 @@ pub const Platform = struct {
|
||||
.TVOS, .TVOSSIMULATOR => .tvos,
|
||||
.WATCHOS, .WATCHOSSIMULATOR => .watchos,
|
||||
.MACCATALYST => .ios,
|
||||
.VISIONOS, .VISIONOSSIMULATOR => .visionos,
|
||||
else => @panic("TODO"),
|
||||
},
|
||||
.abi = switch (cmd.platform) {
|
||||
@ -4384,6 +4391,7 @@ pub const Platform = struct {
|
||||
.IOSSIMULATOR,
|
||||
.TVOSSIMULATOR,
|
||||
.WATCHOSSIMULATOR,
|
||||
.VISIONOSSIMULATOR,
|
||||
=> .simulator,
|
||||
else => .none,
|
||||
},
|
||||
@ -4434,6 +4442,7 @@ pub const Platform = struct {
|
||||
},
|
||||
.tvos => if (plat.abi == .simulator) .TVOSSIMULATOR else .TVOS,
|
||||
.watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS,
|
||||
.visionos => if (plat.abi == .simulator) .VISIONOSSIMULATOR else .VISIONOS,
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
@ -4502,13 +4511,15 @@ const SupportedPlatforms = struct {
|
||||
// Source: https://github.com/apple-oss-distributions/ld64/blob/59a99ab60399c5e6c49e6945a9e1049c42b71135/src/ld/PlatformSupport.cpp#L52
|
||||
// zig fmt: off
|
||||
const supported_platforms = [_]SupportedPlatforms{
|
||||
.{ .macos, .none, 0xA0E00, 0xA0800 },
|
||||
.{ .ios, .none, 0xC0000, 0x70000 },
|
||||
.{ .tvos, .none, 0xC0000, 0x70000 },
|
||||
.{ .watchos, .none, 0x50000, 0x20000 },
|
||||
.{ .ios, .simulator, 0xD0000, 0x80000 },
|
||||
.{ .tvos, .simulator, 0xD0000, 0x80000 },
|
||||
.{ .watchos, .simulator, 0x60000, 0x20000 },
|
||||
.{ .macos, .none, 0xA0E00, 0xA0800 },
|
||||
.{ .ios, .none, 0xC0000, 0x70000 },
|
||||
.{ .tvos, .none, 0xC0000, 0x70000 },
|
||||
.{ .watchos, .none, 0x50000, 0x20000 },
|
||||
.{ .visionos, .none, 0x10000, 0x10000 },
|
||||
.{ .ios, .simulator, 0xD0000, 0x80000 },
|
||||
.{ .tvos, .simulator, 0xD0000, 0x80000 },
|
||||
.{ .watchos, .simulator, 0x60000, 0x20000 },
|
||||
.{ .visionos, .simulator, 0x10000, 0x10000 },
|
||||
};
|
||||
// zig fmt: on
|
||||
|
||||
|
@ -671,7 +671,7 @@ pub const TargetMatcher = struct {
|
||||
try self.target_strings.append(allocator, apple_string);
|
||||
|
||||
switch (platform) {
|
||||
.IOSSIMULATOR, .TVOSSIMULATOR, .WATCHOSSIMULATOR => {
|
||||
.IOSSIMULATOR, .TVOSSIMULATOR, .WATCHOSSIMULATOR, .VISIONOSSIMULATOR => {
|
||||
// For Apple simulator targets, linking gets tricky as we need to link against the simulator
|
||||
// hosts dylibs too.
|
||||
const host_target = try targetToAppleString(allocator, cpu_arch, .MACOS);
|
||||
@ -714,9 +714,11 @@ pub const TargetMatcher = struct {
|
||||
.IOS => "ios",
|
||||
.TVOS => "tvos",
|
||||
.WATCHOS => "watchos",
|
||||
.VISIONOS => "xros",
|
||||
.IOSSIMULATOR => "ios-simulator",
|
||||
.TVOSSIMULATOR => "tvos-simulator",
|
||||
.WATCHOSSIMULATOR => "watchos-simulator",
|
||||
.VISIONOSSIMULATOR => "xros-simulator",
|
||||
.BRIDGEOS => "bridgeos",
|
||||
.MACCATALYST => "maccatalyst",
|
||||
.DRIVERKIT => "driverkit",
|
||||
|
@ -4446,7 +4446,7 @@ fn runOrTestHotSwap(
|
||||
}
|
||||
|
||||
switch (builtin.target.os.tag) {
|
||||
.macos, .ios, .tvos, .watchos => {
|
||||
.macos, .ios, .tvos, .watchos, .visionos => {
|
||||
const PosixSpawn = @import("DarwinPosixSpawn.zig");
|
||||
|
||||
var attr = try PosixSpawn.Attr.init();
|
||||
|
@ -26,6 +26,7 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {
|
||||
.ios,
|
||||
.watchos,
|
||||
.tvos,
|
||||
.visionos,
|
||||
.freestanding,
|
||||
.wasi, // Wasm/WASI currently doesn't offer support for libunwind, so don't link it.
|
||||
=> false,
|
||||
|
@ -681,6 +681,8 @@ static_assert((Triple::OSType)ZigLLVM_PS4 == Triple::PS4, "");
|
||||
static_assert((Triple::OSType)ZigLLVM_ELFIAMCU == Triple::ELFIAMCU, "");
|
||||
static_assert((Triple::OSType)ZigLLVM_TvOS == Triple::TvOS, "");
|
||||
static_assert((Triple::OSType)ZigLLVM_WatchOS == Triple::WatchOS, "");
|
||||
// TODO: blocked by LLVM 18
|
||||
// static_assert((Triple::OSType)ZigLLVM_XROS == Triple::VisionOS, "");
|
||||
static_assert((Triple::OSType)ZigLLVM_Mesa3D == Triple::Mesa3D, "");
|
||||
static_assert((Triple::OSType)ZigLLVM_Contiki == Triple::Contiki, "");
|
||||
static_assert((Triple::OSType)ZigLLVM_AMDPAL == Triple::AMDPAL, "");
|
||||
|
@ -235,6 +235,8 @@ enum ZigLLVM_OSType {
|
||||
ZigLLVM_TvOS, // Apple tvOS
|
||||
ZigLLVM_WatchOS, // Apple watchOS
|
||||
ZigLLVM_DriverKit, // Apple DriverKit
|
||||
// TODO: blocked by LLVM 18
|
||||
// ZigLLVM_XROS, // Apple VisionOS
|
||||
ZigLLVM_Mesa3D,
|
||||
ZigLLVM_Contiki,
|
||||
ZigLLVM_AMDPAL, // AMD PAL Runtime
|
||||
|
Loading…
Reference in New Issue
Block a user