authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-01 02:06:24+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-03 00:57:36+02:00
log710a3b37e2f51010dcb37e4d39ba9ac77eddbd82
tree3d6a793baa3e130d26ed6ac06607555f211d55bd
parent125c043abc208842cd7e1deb188136600eb5c3ea
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

link.MachO: Add exhaustive handling for all Apple target triples.


1 files changed, 27 insertions(+), 20 deletions(-)

src/link/MachO.zig+27-20
......@@ -3542,8 +3542,8 @@ pub fn requiresCodeSig(self: MachO) bool {
35423542 const target = self.getTarget();
35433543 return switch (target.cpu.arch) {
35443544 .aarch64 => switch (target.os.tag) {
3545 .macos => true,
3546 .watchos, .tvos, .ios, .visionos => target.abi == .simulator,
3545 .bridgeos, .driverkit, .macos => true,
3546 .ios, .tvos, .visionos, .watchos => target.abi == .simulator,
35473547 else => false,
35483548 },
35493549 .x86_64 => false,
......@@ -4172,36 +4172,38 @@ pub const Platform = struct {
41724172 const cmd = lc.cast(macho.build_version_command).?;
41734173 return .{
41744174 .os_tag = switch (cmd.platform) {
4175 .MACOS => .macos,
4175 .BRIDGEOS => .bridgeos,
4176 .DRIVERKIT => .driverkit,
41764177 .IOS, .IOSSIMULATOR => .ios,
4177 .TVOS, .TVOSSIMULATOR => .tvos,
4178 .WATCHOS, .WATCHOSSIMULATOR => .watchos,
41794178 .MACCATALYST => .ios,
4179 .MACOS => .macos,
4180 .TVOS, .TVOSSIMULATOR => .tvos,
41804181 .VISIONOS, .VISIONOSSIMULATOR => .visionos,
4182 .WATCHOS, .WATCHOSSIMULATOR => .watchos,
41814183 else => @panic("TODO"),
41824184 },
41834185 .abi = switch (cmd.platform) {
41844186 .MACCATALYST => .macabi,
41854187 .IOSSIMULATOR,
41864188 .TVOSSIMULATOR,
4187 .WATCHOSSIMULATOR,
41884189 .VISIONOSSIMULATOR,
4190 .WATCHOSSIMULATOR,
41894191 => .simulator,
41904192 else => .none,
41914193 },
41924194 .version = appleVersionToSemanticVersion(cmd.minos),
41934195 };
41944196 },
4195 .VERSION_MIN_MACOSX,
41964197 .VERSION_MIN_IPHONEOS,
4198 .VERSION_MIN_MACOSX,
41974199 .VERSION_MIN_TVOS,
41984200 .VERSION_MIN_WATCHOS,
41994201 => {
42004202 const cmd = lc.cast(macho.version_min_command).?;
42014203 return .{
42024204 .os_tag = switch (lc.cmd()) {
4203 .VERSION_MIN_MACOSX => .macos,
42044205 .VERSION_MIN_IPHONEOS => .ios,
4206 .VERSION_MIN_MACOSX => .macos,
42054207 .VERSION_MIN_TVOS => .tvos,
42064208 .VERSION_MIN_WATCHOS => .watchos,
42074209 else => unreachable,
......@@ -4228,15 +4230,17 @@ pub const Platform = struct {
42284230
42294231 pub fn toApplePlatform(plat: Platform) macho.PLATFORM {
42304232 return switch (plat.os_tag) {
4231 .macos => .MACOS,
4233 .bridgeos => .BRIDGEOS,
4234 .driverkit => .DRIVERKIT,
42324235 .ios => switch (plat.abi) {
4233 .simulator => .IOSSIMULATOR,
42344236 .macabi => .MACCATALYST,
4237 .simulator => .IOSSIMULATOR,
42354238 else => .IOS,
42364239 },
4240 .macos => .MACOS,
42374241 .tvos => if (plat.abi == .simulator) .TVOSSIMULATOR else .TVOS,
4238 .watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS,
42394242 .visionos => if (plat.abi == .simulator) .VISIONOSSIMULATOR else .VISIONOS,
4243 .watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS,
42404244 else => unreachable,
42414245 };
42424246 }
......@@ -4305,15 +4309,18 @@ const SupportedPlatforms = struct {
43054309// Source: https://github.com/apple-oss-distributions/ld64/blob/59a99ab60399c5e6c49e6945a9e1049c42b71135/src/ld/PlatformSupport.cpp#L52
43064310// zig fmt: off
43074311const supported_platforms = [_]SupportedPlatforms{
4308 .{ .macos, .none, 0xA0E00, 0xA0800 },
4309 .{ .ios, .none, 0xC0000, 0x70000 },
4310 .{ .tvos, .none, 0xC0000, 0x70000 },
4311 .{ .watchos, .none, 0x50000, 0x20000 },
4312 .{ .visionos, .none, 0x10000, 0x10000 },
4313 .{ .ios, .simulator, 0xD0000, 0x80000 },
4314 .{ .tvos, .simulator, 0xD0000, 0x80000 },
4315 .{ .watchos, .simulator, 0x60000, 0x20000 },
4316 .{ .visionos, .simulator, 0x10000, 0x10000 },
4312 .{ .bridgeos, .none, 0x010000, 0x010000 },
4313 .{ .driverkit, .none, 0x130000, 0x130000 },
4314 .{ .ios, .none, 0x0C0000, 0x070000 },
4315 .{ .ios, .macabi, 0x0D0000, 0x0D0000 },
4316 .{ .ios, .simulator, 0x0D0000, 0x080000 },
4317 .{ .macos, .none, 0x0A0E00, 0x0A0800 },
4318 .{ .tvos, .none, 0x0C0000, 0x070000 },
4319 .{ .tvos, .simulator, 0x0D0000, 0x080000 },
4320 .{ .visionos, .none, 0x010000, 0x010000 },
4321 .{ .visionos, .simulator, 0x010000, 0x010000 },
4322 .{ .watchos, .none, 0x050000, 0x020000 },
4323 .{ .watchos, .simulator, 0x060000, 0x020000 },
43174324};
43184325// zig fmt: on
43194326