| author | |
| committer | |
| log | 23f729aec96cec68be15436db2a38e37d54fbe8f |
| tree | dfc1e929aa4cbad0336cfd9da703aa7e2417d37b |
| parent | df1f8b0ae6ee493262f4244e3af0fb604ccd0a0f |
| parent | 197ffff0b8d1c5257d66775d4cc46bcbfd570a90 |
| signature |
macos: add zippered support6 files changed, 39 insertions(+), 11 deletions(-)
lib/compiler/libc.zig+1-1| ... | @@ -113,7 +113,7 @@ pub fn main() !void { | ... | @@ -113,7 +113,7 @@ pub fn main() !void { |
| 113 | }; | 113 | }; |
| 114 | defer libc.deinit(gpa); | 114 | defer libc.deinit(gpa); |
| 115 | } else { | 115 | } else { |
| 116 | if (!target_query.isNative()) { | 116 | if (!target_query.canDetectLibC()) { |
| 117 | fatal("unable to detect libc for non-native target", .{}); | 117 | fatal("unable to detect libc for non-native target", .{}); |
| 118 | } | 118 | } |
| 119 | var libc = LibCInstallation.findNative(.{ | 119 | var libc = LibCInstallation.findNative(.{ |
lib/std/Target/Query.zig+9| ... | @@ -415,6 +415,15 @@ pub fn isNative(self: Query) bool { | ... | @@ -415,6 +415,15 @@ pub fn isNative(self: Query) bool { |
| 415 | return self.isNativeCpu() and self.isNativeOs() and self.isNativeAbi(); | 415 | return self.isNativeCpu() and self.isNativeOs() and self.isNativeAbi(); |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | pub fn canDetectLibC(self: Query) bool { | ||
| 419 | if (self.isNative()) return true; | ||
| 420 | if (self.os_tag) |os| { | ||
| 421 | if (builtin.os.tag == .macos and os.isDarwin()) return true; | ||
| 422 | if (os == .linux and self.abi == .android) return true; | ||
| 423 | } | ||
| 424 | return false; | ||
| 425 | } | ||
| 426 | |||
| 418 | /// Formats a version with the patch component omitted if it is zero, | 427 | /// Formats a version with the patch component omitted if it is zero, |
| 419 | /// unlike SemanticVersion.format which formats all its version components regardless. | 428 | /// unlike SemanticVersion.format which formats all its version components regardless. |
| 420 | fn formatVersion(version: SemanticVersion, writer: anytype) !void { | 429 | fn formatVersion(version: SemanticVersion, writer: anytype) !void { |
lib/std/zig/LibCInstallation.zig+7-4| ... | @@ -167,7 +167,7 @@ pub const FindNativeOptions = struct { | ... | @@ -167,7 +167,7 @@ pub const FindNativeOptions = struct { |
| 167 | pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation { | 167 | pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation { |
| 168 | var self: LibCInstallation = .{}; | 168 | var self: LibCInstallation = .{}; |
| 169 | 169 | ||
| 170 | if (is_darwin) { | 170 | if (is_darwin and args.target.isDarwin()) { |
| 171 | if (!std.zig.system.darwin.isSdkInstalled(args.allocator)) | 171 | if (!std.zig.system.darwin.isSdkInstalled(args.allocator)) |
| 172 | return error.DarwinSdkNotFound; | 172 | return error.DarwinSdkNotFound; |
| 173 | const sdk = std.zig.system.darwin.getSdk(args.allocator, args.target) orelse | 173 | const sdk = std.zig.system.darwin.getSdk(args.allocator, args.target) orelse |
| ... | @@ -196,7 +196,7 @@ pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation { | ... | @@ -196,7 +196,7 @@ pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation { |
| 196 | try self.findNativeCrtDirWindows(args, &sdk); | 196 | try self.findNativeCrtDirWindows(args, &sdk); |
| 197 | } else if (is_haiku) { | 197 | } else if (is_haiku) { |
| 198 | try self.findNativeIncludeDirPosix(args); | 198 | try self.findNativeIncludeDirPosix(args); |
| 199 | try self.findNativeCrtBeginDirHaiku(args); | 199 | try self.findNativeGccDirHaiku(args); |
| 200 | self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib"); | 200 | self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib"); |
| 201 | } else if (builtin.target.os.tag.isSolarish()) { | 201 | } else if (builtin.target.os.tag.isSolarish()) { |
| 202 | // There is only one libc, and its headers/libraries are always in the same spot. | 202 | // There is only one libc, and its headers/libraries are always in the same spot. |
| ... | @@ -443,13 +443,16 @@ fn findNativeCrtDirWindows( | ... | @@ -443,13 +443,16 @@ fn findNativeCrtDirWindows( |
| 443 | fn findNativeCrtDirPosix(self: *LibCInstallation, args: FindNativeOptions) FindError!void { | 443 | fn findNativeCrtDirPosix(self: *LibCInstallation, args: FindNativeOptions) FindError!void { |
| 444 | self.crt_dir = try ccPrintFileName(.{ | 444 | self.crt_dir = try ccPrintFileName(.{ |
| 445 | .allocator = args.allocator, | 445 | .allocator = args.allocator, |
| 446 | .search_basename = "crt1.o", | 446 | .search_basename = switch (args.target.os.tag) { |
| 447 | .linux => if (args.target.isAndroid()) "crtbegin_dynamic.o" else "crt1.o", | ||
| 448 | else => "crt1.o", | ||
| 449 | }, | ||
| 447 | .want_dirname = .only_dir, | 450 | .want_dirname = .only_dir, |
| 448 | .verbose = args.verbose, | 451 | .verbose = args.verbose, |
| 449 | }); | 452 | }); |
| 450 | } | 453 | } |
| 451 | 454 | ||
| 452 | fn findNativeCrtBeginDirHaiku(self: *LibCInstallation, args: FindNativeOptions) FindError!void { | 455 | fn findNativeGccDirHaiku(self: *LibCInstallation, args: FindNativeOptions) FindError!void { |
| 453 | self.gcc_dir = try ccPrintFileName(.{ | 456 | self.gcc_dir = try ccPrintFileName(.{ |
| 454 | .allocator = args.allocator, | 457 | .allocator = args.allocator, |
| 455 | .search_basename = "crtbeginS.o", | 458 | .search_basename = "crtbeginS.o", |
lib/std/zig/system/darwin.zig+5-1| ... | @@ -38,7 +38,11 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 { | ... | @@ -38,7 +38,11 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 { |
| 38 | const is_simulator_abi = target.abi == .simulator; | 38 | const is_simulator_abi = target.abi == .simulator; |
| 39 | const sdk = switch (target.os.tag) { | 39 | const sdk = switch (target.os.tag) { |
| 40 | .macos => "macosx", | 40 | .macos => "macosx", |
| 41 | .ios => if (is_simulator_abi) "iphonesimulator" else "iphoneos", | 41 | .ios => switch (target.abi) { |
| 42 | .simulator => "iphonesimulator", | ||
| 43 | .macabi => "macosx", | ||
| 44 | else => "iphoneos", | ||
| 45 | }, | ||
| 42 | .watchos => if (is_simulator_abi) "watchsimulator" else "watchos", | 46 | .watchos => if (is_simulator_abi) "watchsimulator" else "watchos", |
| 43 | .tvos => if (is_simulator_abi) "appletvsimulator" else "appletvos", | 47 | .tvos => if (is_simulator_abi) "appletvsimulator" else "appletvos", |
| 44 | else => return null, | 48 | else => return null, |
src/link/MachO.zig+7-1| ... | @@ -4376,9 +4376,11 @@ pub const Platform = struct { | ... | @@ -4376,9 +4376,11 @@ pub const Platform = struct { |
| 4376 | .IOS, .IOSSIMULATOR => .ios, | 4376 | .IOS, .IOSSIMULATOR => .ios, |
| 4377 | .TVOS, .TVOSSIMULATOR => .tvos, | 4377 | .TVOS, .TVOSSIMULATOR => .tvos, |
| 4378 | .WATCHOS, .WATCHOSSIMULATOR => .watchos, | 4378 | .WATCHOS, .WATCHOSSIMULATOR => .watchos, |
| 4379 | .MACCATALYST => .ios, | ||
| 4379 | else => @panic("TODO"), | 4380 | else => @panic("TODO"), |
| 4380 | }, | 4381 | }, |
| 4381 | .abi = switch (cmd.platform) { | 4382 | .abi = switch (cmd.platform) { |
| 4383 | .MACCATALYST => .macabi, | ||
| 4382 | .IOSSIMULATOR, | 4384 | .IOSSIMULATOR, |
| 4383 | .TVOSSIMULATOR, | 4385 | .TVOSSIMULATOR, |
| 4384 | .WATCHOSSIMULATOR, | 4386 | .WATCHOSSIMULATOR, |
| ... | @@ -4425,7 +4427,11 @@ pub const Platform = struct { | ... | @@ -4425,7 +4427,11 @@ pub const Platform = struct { |
| 4425 | pub fn toApplePlatform(plat: Platform) macho.PLATFORM { | 4427 | pub fn toApplePlatform(plat: Platform) macho.PLATFORM { |
| 4426 | return switch (plat.os_tag) { | 4428 | return switch (plat.os_tag) { |
| 4427 | .macos => .MACOS, | 4429 | .macos => .MACOS, |
| 4428 | .ios => if (plat.abi == .simulator) .IOSSIMULATOR else .IOS, | 4430 | .ios => switch (plat.abi) { |
| 4431 | .simulator => .IOSSIMULATOR, | ||
| 4432 | .macabi => .MACCATALYST, | ||
| 4433 | else => .IOS, | ||
| 4434 | }, | ||
| 4429 | .tvos => if (plat.abi == .simulator) .TVOSSIMULATOR else .TVOS, | 4435 | .tvos => if (plat.abi == .simulator) .TVOSSIMULATOR else .TVOS, |
| 4430 | .watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS, | 4436 | .watchos => if (plat.abi == .simulator) .WATCHOSSIMULATOR else .WATCHOS, |
| 4431 | else => unreachable, | 4437 | else => unreachable, |
src/link/MachO/Dylib.zig+10-4| ... | @@ -54,7 +54,7 @@ pub fn parse(self: *Dylib, macho_file: *MachO, file: std.fs.File, fat_arch: ?fat | ... | @@ -54,7 +54,7 @@ pub fn parse(self: *Dylib, macho_file: *MachO, file: std.fs.File, fat_arch: ?fat |
| 54 | const gpa = macho_file.base.comp.gpa; | 54 | const gpa = macho_file.base.comp.gpa; |
| 55 | const offset = if (fat_arch) |ar| ar.offset else 0; | 55 | const offset = if (fat_arch) |ar| ar.offset else 0; |
| 56 | 56 | ||
| 57 | log.debug("parsing dylib from binary", .{}); | 57 | log.debug("parsing dylib from binary: {s}", .{self.path}); |
| 58 | 58 | ||
| 59 | var header_buffer: [@sizeOf(macho.mach_header_64)]u8 = undefined; | 59 | var header_buffer: [@sizeOf(macho.mach_header_64)]u8 = undefined; |
| 60 | { | 60 | { |
| ... | @@ -266,7 +266,7 @@ pub fn parseTbd( | ... | @@ -266,7 +266,7 @@ pub fn parseTbd( |
| 266 | 266 | ||
| 267 | const gpa = macho_file.base.comp.gpa; | 267 | const gpa = macho_file.base.comp.gpa; |
| 268 | 268 | ||
| 269 | log.debug("parsing dylib from stub", .{}); | 269 | log.debug("parsing dylib from stub: {s}", .{self.path}); |
| 270 | 270 | ||
| 271 | const umbrella_lib = lib_stub.inner[0]; | 271 | const umbrella_lib = lib_stub.inner[0]; |
| 272 | 272 | ||
| ... | @@ -751,8 +751,14 @@ pub const TargetMatcher = struct { | ... | @@ -751,8 +751,14 @@ pub const TargetMatcher = struct { |
| 751 | .v3 => |v3| blk: { | 751 | .v3 => |v3| blk: { |
| 752 | var targets = std.ArrayList([]const u8).init(arena.allocator()); | 752 | var targets = std.ArrayList([]const u8).init(arena.allocator()); |
| 753 | for (v3.archs) |arch| { | 753 | for (v3.archs) |arch| { |
| 754 | const target = try std.fmt.allocPrint(arena.allocator(), "{s}-{s}", .{ arch, v3.platform }); | 754 | if (mem.eql(u8, v3.platform, "zippered")) { |
| 755 | try targets.append(target); | 755 | // From Xcode 10.3 → 11.3.1, macos SDK .tbd files specify platform as 'zippered' |
| 756 | // which should map to [ '<arch>-macos', '<arch>-maccatalyst' ] | ||
| 757 | try targets.append(try std.fmt.allocPrint(arena.allocator(), "{s}-macos", .{arch})); | ||
| 758 | try targets.append(try std.fmt.allocPrint(arena.allocator(), "{s}-maccatalyst", .{arch})); | ||
| 759 | } else { | ||
| 760 | try targets.append(try std.fmt.allocPrint(arena.allocator(), "{s}-{s}", .{ arch, v3.platform })); | ||
| 761 | } | ||
| 756 | } | 762 | } |
| 757 | break :blk targets.items; | 763 | break :blk targets.items; |
| 758 | }, | 764 | }, |