authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-09 14:09:31+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-09 14:09:31+02:00
log8f202ba7c7c446da9dff4b9ca2bbfb5b21c0aa18
treeded686a53e8e1bc8d69d640d2f4508de09d99455
parentbcb534c295d5cc6fd63caa570cc08e6b148a507c

link/macho: add support for VisionOS


2 files changed, 25 insertions(+), 12 deletions(-)

src/link/MachO.zig+22-11
......@@ -3676,10 +3676,16 @@ pub inline fn getPageSize(self: MachO) u16 {
36763676
36773677pub fn requiresCodeSig(self: MachO) bool {
36783678 if (self.entitlements) |_| return true;
3679 // if (self.options.adhoc_codesign) |cs| return cs;
3680 return switch (self.getTarget().cpu.arch) {
3681 .aarch64 => true,
3682 else => false,
3679 if (self.options.adhoc_codesign) |cs| return cs;
3680 const target = self.getTarget();
3681 return switch (target.cpu.arch) {
3682 .aarch64 => switch (target.os.tag) {
3683 .macos => true,
3684 .watchos, .tvos, .ios, .visionos => target.abi == .simulator,
3685 else => false,
3686 },
3687 .x86_64 => false,
3688 else => unreachable,
36833689 };
36843690}
36853691
......@@ -4424,6 +4430,7 @@ pub const Platform = struct {
44244430 .TVOS, .TVOSSIMULATOR => .tvos,
44254431 .WATCHOS, .WATCHOSSIMULATOR => .watchos,
44264432 .MACCATALYST => .ios,
4433 .VISIONOS, .VISIONOSSIMULATOR => .visionos,
44274434 else => @panic("TODO"),
44284435 },
44294436 .abi = switch (cmd.platform) {
......@@ -4431,6 +4438,7 @@ pub const Platform = struct {
44314438 .IOSSIMULATOR,
44324439 .TVOSSIMULATOR,
44334440 .WATCHOSSIMULATOR,
4441 .VISIONOSSIMULATOR,
44344442 => .simulator,
44354443 else => .none,
44364444 },
......@@ -4481,6 +4489,7 @@ pub const Platform = struct {
44814489 },
44824490 .tvos => if (plat.abi == .simulator) .TVOSSIMULATOR else .TVOS,
44834491 .watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS,
4492 .visionos => if (plat.abi == .simulator) .VISIONOSSIMULATOR else .VISIONOS,
44844493 else => unreachable,
44854494 };
44864495 }
......@@ -4549,13 +4558,15 @@ const SupportedPlatforms = struct {
45494558// Source: https://github.com/apple-oss-distributions/ld64/blob/59a99ab60399c5e6c49e6945a9e1049c42b71135/src/ld/PlatformSupport.cpp#L52
45504559// zig fmt: off
45514560const 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 },
4561 .{ .macos, .none, 0xA0E00, 0xA0800 },
4562 .{ .ios, .none, 0xC0000, 0x70000 },
4563 .{ .tvos, .none, 0xC0000, 0x70000 },
4564 .{ .watchos, .none, 0x50000, 0x20000 },
4565 .{ .visionos, .none, 0x10000, 0x10000 },
4566 .{ .ios, .simulator, 0xD0000, 0x80000 },
4567 .{ .tvos, .simulator, 0xD0000, 0x80000 },
4568 .{ .watchos, .simulator, 0x60000, 0x20000 },
4569 .{ .visionos, .simulator, 0x10000, 0x10000 },
45594570};
45604571// zig fmt: on
45614572
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",