| author | |
| committer | |
| log | 22fd1851bd56dae5b61e5f170671f3af5ef54330 |
| tree | 631a1e010de32051879bab6898e5a4b7bede339b |
| parent | 11bc3fb1906e10ed38fb913559a6c36d4c027e22 |
| signature |
On macos, allow targets supported by the SDK. This then spawns `xcrun`
and correct paths are emitted for:
- x86_64-macos
- x86_64-ios
- x86_64-tvos
- x86_64-watchos
- x86_64-ios-macbi
- aarch64-macos
- aarch64-ios
- aarch64-tvos
- aarch64-watchos
- aarch64-ios-macbi
On platforms with android NDK, allow android targets. Example usage:
```
CC=/NDK/.../bin/aarch64-linux-android34-clang zig libc -target aarch64-linux-android
```4 files changed, 22 insertions(+), 6 deletions(-)
lib/compiler/libc.zig+1-1| ... | ... | @@ -113,7 +113,7 @@ pub fn main() !void { |
| 113 | 113 | }; |
| 114 | 114 | defer libc.deinit(gpa); |
| 115 | 115 | } else { |
| 116 | if (!target_query.isNative()) { | |
| 116 | if (!target_query.canDetectLibC()) { | |
| 117 | 117 | fatal("unable to detect libc for non-native target", .{}); |
| 118 | 118 | } |
| 119 | 119 | var libc = LibCInstallation.findNative(.{ |
lib/std/Target/Query.zig+9| ... | ... | @@ -415,6 +415,15 @@ pub fn isNative(self: Query) bool { |
| 415 | 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 | 427 | /// Formats a version with the patch component omitted if it is zero, |
| 419 | 428 | /// unlike SemanticVersion.format which formats all its version components regardless. |
| 420 | 429 | fn formatVersion(version: SemanticVersion, writer: anytype) !void { |
lib/std/zig/LibCInstallation.zig+7-4| ... | ... | @@ -167,7 +167,7 @@ pub const FindNativeOptions = struct { |
| 167 | 167 | pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation { |
| 168 | 168 | var self: LibCInstallation = .{}; |
| 169 | 169 | |
| 170 | if (is_darwin) { | |
| 170 | if (is_darwin and args.target.isDarwin()) { | |
| 171 | 171 | if (!std.zig.system.darwin.isSdkInstalled(args.allocator)) |
| 172 | 172 | return error.DarwinSdkNotFound; |
| 173 | 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 | 196 | try self.findNativeCrtDirWindows(args, &sdk); |
| 197 | 197 | } else if (is_haiku) { |
| 198 | 198 | try self.findNativeIncludeDirPosix(args); |
| 199 | try self.findNativeCrtBeginDirHaiku(args); | |
| 199 | try self.findNativeGccDirHaiku(args); | |
| 200 | 200 | self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib"); |
| 201 | 201 | } else if (builtin.target.os.tag.isSolarish()) { |
| 202 | 202 | // There is only one libc, and its headers/libraries are always in the same spot. |
| ... | ... | @@ -443,13 +443,16 @@ fn findNativeCrtDirWindows( |
| 443 | 443 | fn findNativeCrtDirPosix(self: *LibCInstallation, args: FindNativeOptions) FindError!void { |
| 444 | 444 | self.crt_dir = try ccPrintFileName(.{ |
| 445 | 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 | 450 | .want_dirname = .only_dir, |
| 448 | 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 | 456 | self.gcc_dir = try ccPrintFileName(.{ |
| 454 | 457 | .allocator = args.allocator, |
| 455 | 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 | 38 | const is_simulator_abi = target.abi == .simulator; |
| 39 | 39 | const sdk = switch (target.os.tag) { |
| 40 | 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 | 46 | .watchos => if (is_simulator_abi) "watchsimulator" else "watchos", |
| 43 | 47 | .tvos => if (is_simulator_abi) "appletvsimulator" else "appletvos", |
| 44 | 48 | else => return null, |