authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-25 03:43:21-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-28 14:51:54-05:00
log87b9e744dda465ecf7663e2463066ea26a44e63a
treee3c09dca4b8a06656029b1034da24ed9b7507299
parentd4f375c46be2e509ee9161b0577d8a25d6620b3e
signaturelock-open Commit is signed but in an unrecognized format.

update std lib to new Target API


29 files changed, 281 insertions(+), 261 deletions(-)

lib/std/build.zig+76-5
...@@ -971,7 +971,7 @@ pub const Builder = struct {...@@ -971,7 +971,7 @@ pub const Builder = struct {
971};971};
972972
973test "builder.findProgram compiles" {973test "builder.findProgram compiles" {
974 var buf: [1000]u8 = undefined;974 var buf: [50000]u8 = undefined;
975 var fba = std.heap.FixedBufferAllocator.init(&buf);975 var fba = std.heap.FixedBufferAllocator.init(&buf);
976 const builder = try Builder.create(&fba.allocator, "zig", "zig-cache", "zig-cache");976 const builder = try Builder.create(&fba.allocator, "zig", "zig-cache", "zig-cache");
977 defer builder.destroy();977 defer builder.destroy();
...@@ -1011,6 +1011,77 @@ pub const Target = union(enum) {...@@ -1011,6 +1011,77 @@ pub const Target = union(enum) {
1011 pub fn getArch(self: Target) std.Target.Cpu.Arch {1011 pub fn getArch(self: Target) std.Target.Cpu.Arch {
1012 return self.getCpu().arch;1012 return self.getCpu().arch;
1013 }1013 }
1014
1015 pub fn isFreeBSD(self: Target) bool {
1016 return self.getTarget().os.tag == .freebsd;
1017 }
1018
1019 pub fn isDarwin(self: Target) bool {
1020 return self.getTarget().os.tag.isDarwin();
1021 }
1022
1023 pub fn isNetBSD(self: Target) bool {
1024 return self.getTarget().os.tag == .netbsd;
1025 }
1026
1027 pub fn isUefi(self: Target) bool {
1028 return self.getTarget().os.tag == .uefi;
1029 }
1030
1031 pub fn isDragonFlyBSD(self: Target) bool {
1032 return self.getTarget().os.tag == .dragonfly;
1033 }
1034
1035 pub fn isLinux(self: Target) bool {
1036 return self.getTarget().os.tag == .linux;
1037 }
1038
1039 pub fn isWindows(self: Target) bool {
1040 return self.getTarget().os.tag == .windows;
1041 }
1042
1043 pub fn oFileExt(self: Target) []const u8 {
1044 return self.getTarget().oFileExt();
1045 }
1046
1047 pub fn exeFileExt(self: Target) []const u8 {
1048 return self.getTarget().exeFileExt();
1049 }
1050
1051 pub fn staticLibSuffix(self: Target) []const u8 {
1052 return self.getTarget().staticLibSuffix();
1053 }
1054
1055 pub fn libPrefix(self: Target) []const u8 {
1056 return self.getTarget().libPrefix();
1057 }
1058
1059 pub fn zigTriple(self: Target, allocator: *mem.Allocator) ![]u8 {
1060 return self.getTarget().zigTriple(allocator);
1061 }
1062
1063 pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 {
1064 return self.getTarget().linuxTriple(allocator);
1065 }
1066
1067 pub fn wantSharedLibSymLinks(self: Target) bool {
1068 return self.getTarget().wantSharedLibSymLinks();
1069 }
1070
1071 pub fn vcpkgTriplet(self: Target, allocator: *mem.Allocator, linkage: std.build.VcpkgLinkage) ![]const u8 {
1072 return self.getTarget().vcpkgTriplet(allocator, linkage);
1073 }
1074
1075 pub fn getExternalExecutor(self: Target) std.Target.Executor {
1076 switch (self) {
1077 .Native => return .native,
1078 .Cross => |t| return t.getExternalExecutor(),
1079 }
1080 }
1081
1082 pub fn isGnuLibC(self: Target) bool {
1083 return self.getTarget().isGnuLibC();
1084 }
1014};1085};
10151086
1016pub const Pkg = struct {1087pub const Pkg = struct {
...@@ -1718,7 +1789,7 @@ pub const LibExeObjStep = struct {...@@ -1718,7 +1789,7 @@ pub const LibExeObjStep = struct {
1718 .NotFound => return error.VcpkgNotFound,1789 .NotFound => return error.VcpkgNotFound,
1719 .Found => |root| {1790 .Found => |root| {
1720 const allocator = self.builder.allocator;1791 const allocator = self.builder.allocator;
1721 const triplet = try Target.vcpkgTriplet(allocator, self.target, linkage);1792 const triplet = try self.target.vcpkgTriplet(allocator, linkage);
1722 defer self.builder.allocator.free(triplet);1793 defer self.builder.allocator.free(triplet);
17231794
1724 const include_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "include" });1795 const include_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "include" });
...@@ -1944,7 +2015,7 @@ pub const LibExeObjStep = struct {...@@ -1944,7 +2015,7 @@ pub const LibExeObjStep = struct {
1944 if (populated_cpu_features.eql(cross.cpu.features)) {2015 if (populated_cpu_features.eql(cross.cpu.features)) {
1945 // The CPU name alone is sufficient.2016 // The CPU name alone is sufficient.
1946 // If it is the baseline CPU, no command line args are required.2017 // If it is the baseline CPU, no command line args are required.
1947 if (cross.cpu.model != Target.Cpu.baseline(self.target.getArch()).model) {2018 if (cross.cpu.model != std.Target.Cpu.baseline(self.target.getArch()).model) {
1948 try zig_args.append("-mcpu");2019 try zig_args.append("-mcpu");
1949 try zig_args.append(cross.cpu.model.name);2020 try zig_args.append(cross.cpu.model.name);
1950 }2021 }
...@@ -1953,7 +2024,7 @@ pub const LibExeObjStep = struct {...@@ -1953,7 +2024,7 @@ pub const LibExeObjStep = struct {
1953 try mcpu_buffer.append(cross.cpu.model.name);2024 try mcpu_buffer.append(cross.cpu.model.name);
19542025
1955 for (all_features) |feature, i_usize| {2026 for (all_features) |feature, i_usize| {
1956 const i = @intCast(Target.Cpu.Feature.Set.Index, i_usize);2027 const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize);
1957 const in_cpu_set = populated_cpu_features.isEnabled(i);2028 const in_cpu_set = populated_cpu_features.isEnabled(i);
1958 const in_actual_set = cross.cpu.features.isEnabled(i);2029 const in_actual_set = cross.cpu.features.isEnabled(i);
1959 if (in_cpu_set and !in_actual_set) {2030 if (in_cpu_set and !in_actual_set) {
...@@ -2001,7 +2072,7 @@ pub const LibExeObjStep = struct {...@@ -2001,7 +2072,7 @@ pub const LibExeObjStep = struct {
2001 } else switch (self.target.getExternalExecutor()) {2072 } else switch (self.target.getExternalExecutor()) {
2002 .native, .unavailable => {},2073 .native, .unavailable => {},
2003 .qemu => |bin_name| if (self.enable_qemu) qemu: {2074 .qemu => |bin_name| if (self.enable_qemu) qemu: {
2004 const need_cross_glibc = self.target.isGnu() and self.target.isLinux() and self.is_linking_libc;2075 const need_cross_glibc = self.target.isGnuLibC() and self.is_linking_libc;
2005 const glibc_dir_arg = if (need_cross_glibc)2076 const glibc_dir_arg = if (need_cross_glibc)
2006 self.glibc_multi_install_dir orelse break :qemu2077 self.glibc_multi_install_dir orelse break :qemu
2007 else2078 else
lib/std/build/translate_c.zig+2-2
...@@ -14,7 +14,7 @@ pub const TranslateCStep = struct {...@@ -14,7 +14,7 @@ pub const TranslateCStep = struct {
14 source: build.FileSource,14 source: build.FileSource,
15 output_dir: ?[]const u8,15 output_dir: ?[]const u8,
16 out_basename: []const u8,16 out_basename: []const u8,
17 target: std.Target = .Native,17 target: build.Target = .Native,
1818
19 pub fn create(builder: *Builder, source: build.FileSource) *TranslateCStep {19 pub fn create(builder: *Builder, source: build.FileSource) *TranslateCStep {
20 const self = builder.allocator.create(TranslateCStep) catch unreachable;20 const self = builder.allocator.create(TranslateCStep) catch unreachable;
...@@ -39,7 +39,7 @@ pub const TranslateCStep = struct {...@@ -39,7 +39,7 @@ pub const TranslateCStep = struct {
39 ) catch unreachable;39 ) catch unreachable;
40 }40 }
4141
42 pub fn setTarget(self: *TranslateCStep, target: std.Target) void {42 pub fn setTarget(self: *TranslateCStep, target: build.Target) void {
43 self.target = target;43 self.target = target;
44 }44 }
4545
lib/std/fmt/parse_float.zig+1-1
...@@ -382,7 +382,7 @@ pub fn parseFloat(comptime T: type, s: []const u8) !T {...@@ -382,7 +382,7 @@ pub fn parseFloat(comptime T: type, s: []const u8) !T {
382}382}
383383
384test "fmt.parseFloat" {384test "fmt.parseFloat" {
385 if (std.Target.current.isWindows()) {385 if (std.Target.current.os.tag == .windows) {
386 // TODO https://github.com/ziglang/zig/issues/508386 // TODO https://github.com/ziglang/zig/issues/508
387 return error.SkipZigTest;387 return error.SkipZigTest;
388 }388 }
lib/std/io/test.zig+1-1
...@@ -544,7 +544,7 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing:...@@ -544,7 +544,7 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing:
544}544}
545545
546test "Serializer/Deserializer generic" {546test "Serializer/Deserializer generic" {
547 if (std.Target.current.isWindows()) {547 if (std.Target.current.os.tag == .windows) {
548 // TODO https://github.com/ziglang/zig/issues/508548 // TODO https://github.com/ziglang/zig/issues/508
549 return error.SkipZigTest;549 return error.SkipZigTest;
550 }550 }
lib/std/math/fabs.zig+1-1
...@@ -95,7 +95,7 @@ test "math.fabs64.special" {...@@ -95,7 +95,7 @@ test "math.fabs64.special" {
95}95}
9696
97test "math.fabs128.special" {97test "math.fabs128.special" {
98 if (std.Target.current.isWindows()) {98 if (std.Target.current.os.tag == .windows) {
99 // TODO https://github.com/ziglang/zig/issues/50899 // TODO https://github.com/ziglang/zig/issues/508
100 return error.SkipZigTest;100 return error.SkipZigTest;
101 }101 }
lib/std/math/isinf.zig+3-3
...@@ -74,7 +74,7 @@ pub fn isNegativeInf(x: var) bool {...@@ -74,7 +74,7 @@ pub fn isNegativeInf(x: var) bool {
74}74}
7575
76test "math.isInf" {76test "math.isInf" {
77 if (std.Target.current.isWindows()) {77 if (std.Target.current.os.tag == .windows) {
78 // TODO https://github.com/ziglang/zig/issues/50878 // TODO https://github.com/ziglang/zig/issues/508
79 return error.SkipZigTest;79 return error.SkipZigTest;
80 }80 }
...@@ -97,7 +97,7 @@ test "math.isInf" {...@@ -97,7 +97,7 @@ test "math.isInf" {
97}97}
9898
99test "math.isPositiveInf" {99test "math.isPositiveInf" {
100 if (std.Target.current.isWindows()) {100 if (std.Target.current.os.tag == .windows) {
101 // TODO https://github.com/ziglang/zig/issues/508101 // TODO https://github.com/ziglang/zig/issues/508
102 return error.SkipZigTest;102 return error.SkipZigTest;
103 }103 }
...@@ -120,7 +120,7 @@ test "math.isPositiveInf" {...@@ -120,7 +120,7 @@ test "math.isPositiveInf" {
120}120}
121121
122test "math.isNegativeInf" {122test "math.isNegativeInf" {
123 if (std.Target.current.isWindows()) {123 if (std.Target.current.os.tag == .windows) {
124 // TODO https://github.com/ziglang/zig/issues/508124 // TODO https://github.com/ziglang/zig/issues/508
125 return error.SkipZigTest;125 return error.SkipZigTest;
126 }126 }
lib/std/math/isnan.zig+1-1
...@@ -16,7 +16,7 @@ pub fn isSignalNan(x: var) bool {...@@ -16,7 +16,7 @@ pub fn isSignalNan(x: var) bool {
16}16}
1717
18test "math.isNan" {18test "math.isNan" {
19 if (std.Target.current.isWindows()) {19 if (std.Target.current.os.tag == .windows) {
20 // TODO https://github.com/ziglang/zig/issues/50820 // TODO https://github.com/ziglang/zig/issues/508
21 return error.SkipZigTest;21 return error.SkipZigTest;
22 }22 }
lib/std/os.zig+2-2
...@@ -650,7 +650,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!void {...@@ -650,7 +650,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!void {
650/// On Windows, if the application has a global event loop enabled, I/O Completion Ports are650/// On Windows, if the application has a global event loop enabled, I/O Completion Ports are
651/// used to perform the I/O. `error.WouldBlock` is not possible on Windows.651/// used to perform the I/O. `error.WouldBlock` is not possible on Windows.
652pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) WriteError!void {652pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) WriteError!void {
653 if (comptime std.Target.current.isWindows()) {653 if (std.Target.current.os.tag == .windows) {
654 return windows.WriteFile(fd, bytes, offset);654 return windows.WriteFile(fd, bytes, offset);
655 }655 }
656656
...@@ -739,7 +739,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) WriteError!void...@@ -739,7 +739,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) WriteError!void
739 }739 }
740 }740 }
741741
742 if (comptime std.Target.current.isWindows()) {742 if (std.Target.current.os.tag == .windows) {
743 var off = offset;743 var off = offset;
744 for (iov) |item| {744 for (iov) |item| {
745 try pwrite(fd, item.iov_base[0..item.iov_len], off);745 try pwrite(fd, item.iov_base[0..item.iov_len], off);
lib/std/special/compiler_rt/addXf3_test.zig+2-2
...@@ -31,7 +31,7 @@ fn test__addtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) void {...@@ -31,7 +31,7 @@ fn test__addtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) void {
31}31}
3232
33test "addtf3" {33test "addtf3" {
34 if (@import("std").Target.current.isWindows()) {34 if (@import("std").Target.current.os.tag == .windows) {
35 // TODO https://github.com/ziglang/zig/issues/50835 // TODO https://github.com/ziglang/zig/issues/508
36 return error.SkipZigTest;36 return error.SkipZigTest;
37 }37 }
...@@ -75,7 +75,7 @@ fn test__subtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) void {...@@ -75,7 +75,7 @@ fn test__subtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) void {
75}75}
7676
77test "subtf3" {77test "subtf3" {
78 if (@import("std").Target.current.isWindows()) {78 if (@import("std").Target.current.os.tag == .windows) {
79 // TODO https://github.com/ziglang/zig/issues/50879 // TODO https://github.com/ziglang/zig/issues/508
80 return error.SkipZigTest;80 return error.SkipZigTest;
81 }81 }
lib/std/special/compiler_rt/fixtfdi_test.zig+1-1
...@@ -11,7 +11,7 @@ fn test__fixtfdi(a: f128, expected: i64) void {...@@ -11,7 +11,7 @@ fn test__fixtfdi(a: f128, expected: i64) void {
11}11}
1212
13test "fixtfdi" {13test "fixtfdi" {
14 if (@import("std").Target.current.isWindows()) {14 if (@import("std").Target.current.os.tag == .windows) {
15 // TODO https://github.com/ziglang/zig/issues/50815 // TODO https://github.com/ziglang/zig/issues/508
16 return error.SkipZigTest;16 return error.SkipZigTest;
17 }17 }
lib/std/special/compiler_rt/fixtfsi_test.zig+1-1
...@@ -11,7 +11,7 @@ fn test__fixtfsi(a: f128, expected: i32) void {...@@ -11,7 +11,7 @@ fn test__fixtfsi(a: f128, expected: i32) void {
11}11}
1212
13test "fixtfsi" {13test "fixtfsi" {
14 if (@import("std").Target.current.isWindows()) {14 if (@import("std").Target.current.os.tag == .windows) {
15 // TODO https://github.com/ziglang/zig/issues/50815 // TODO https://github.com/ziglang/zig/issues/508
16 return error.SkipZigTest;16 return error.SkipZigTest;
17 }17 }
lib/std/special/compiler_rt/fixtfti_test.zig+1-1
...@@ -11,7 +11,7 @@ fn test__fixtfti(a: f128, expected: i128) void {...@@ -11,7 +11,7 @@ fn test__fixtfti(a: f128, expected: i128) void {
11}11}
1212
13test "fixtfti" {13test "fixtfti" {
14 if (@import("std").Target.current.isWindows()) {14 if (@import("std").Target.current.os.tag == .windows) {
15 // TODO https://github.com/ziglang/zig/issues/50815 // TODO https://github.com/ziglang/zig/issues/508
16 return error.SkipZigTest;16 return error.SkipZigTest;
17 }17 }
lib/std/special/compiler_rt/fixunstfdi_test.zig+1-1
...@@ -7,7 +7,7 @@ fn test__fixunstfdi(a: f128, expected: u64) void {...@@ -7,7 +7,7 @@ fn test__fixunstfdi(a: f128, expected: u64) void {
7}7}
88
9test "fixunstfdi" {9test "fixunstfdi" {
10 if (@import("std").Target.current.isWindows()) {10 if (@import("std").Target.current.os.tag == .windows) {
11 // TODO https://github.com/ziglang/zig/issues/50811 // TODO https://github.com/ziglang/zig/issues/508
12 return error.SkipZigTest;12 return error.SkipZigTest;
13 }13 }
lib/std/special/compiler_rt/fixunstfsi_test.zig+1-1
...@@ -9,7 +9,7 @@ fn test__fixunstfsi(a: f128, expected: u32) void {...@@ -9,7 +9,7 @@ fn test__fixunstfsi(a: f128, expected: u32) void {
9const inf128 = @bitCast(f128, @as(u128, 0x7fff0000000000000000000000000000));9const inf128 = @bitCast(f128, @as(u128, 0x7fff0000000000000000000000000000));
1010
11test "fixunstfsi" {11test "fixunstfsi" {
12 if (@import("std").Target.current.isWindows()) {12 if (@import("std").Target.current.os.tag == .windows) {
13 // TODO https://github.com/ziglang/zig/issues/50813 // TODO https://github.com/ziglang/zig/issues/508
14 return error.SkipZigTest;14 return error.SkipZigTest;
15 }15 }
lib/std/special/compiler_rt/fixunstfti_test.zig+1-1
...@@ -9,7 +9,7 @@ fn test__fixunstfti(a: f128, expected: u128) void {...@@ -9,7 +9,7 @@ fn test__fixunstfti(a: f128, expected: u128) void {
9const inf128 = @bitCast(f128, @as(u128, 0x7fff0000000000000000000000000000));9const inf128 = @bitCast(f128, @as(u128, 0x7fff0000000000000000000000000000));
1010
11test "fixunstfti" {11test "fixunstfti" {
12 if (@import("std").Target.current.isWindows()) {12 if (@import("std").Target.current.os.tag == .windows) {
13 // TODO https://github.com/ziglang/zig/issues/50813 // TODO https://github.com/ziglang/zig/issues/508
14 return error.SkipZigTest;14 return error.SkipZigTest;
15 }15 }
lib/std/special/compiler_rt/floattitf_test.zig+1-1
...@@ -7,7 +7,7 @@ fn test__floattitf(a: i128, expected: f128) void {...@@ -7,7 +7,7 @@ fn test__floattitf(a: i128, expected: f128) void {
7}7}
88
9test "floattitf" {9test "floattitf" {
10 if (@import("std").Target.current.isWindows()) {10 if (@import("std").Target.current.os.tag == .windows) {
11 // TODO https://github.com/ziglang/zig/issues/50811 // TODO https://github.com/ziglang/zig/issues/508
12 return error.SkipZigTest;12 return error.SkipZigTest;
13 }13 }
lib/std/special/compiler_rt/floatuntitf_test.zig+1-1
...@@ -7,7 +7,7 @@ fn test__floatuntitf(a: u128, expected: f128) void {...@@ -7,7 +7,7 @@ fn test__floatuntitf(a: u128, expected: f128) void {
7}7}
88
9test "floatuntitf" {9test "floatuntitf" {
10 if (@import("std").Target.current.isWindows()) {10 if (@import("std").Target.current.os.tag == .windows) {
11 // TODO https://github.com/ziglang/zig/issues/50811 // TODO https://github.com/ziglang/zig/issues/508
12 return error.SkipZigTest;12 return error.SkipZigTest;
13 }13 }
lib/std/special/compiler_rt/mulXf3_test.zig+1-1
...@@ -44,7 +44,7 @@ fn makeNaN128(rand: u64) f128 {...@@ -44,7 +44,7 @@ fn makeNaN128(rand: u64) f128 {
44 return float_result;44 return float_result;
45}45}
46test "multf3" {46test "multf3" {
47 if (@import("std").Target.current.isWindows()) {47 if (@import("std").Target.current.os.tag == .windows) {
48 // TODO https://github.com/ziglang/zig/issues/50848 // TODO https://github.com/ziglang/zig/issues/508
49 return error.SkipZigTest;49 return error.SkipZigTest;
50 }50 }
lib/std/special/compiler_rt/truncXfYf2_test.zig+2-2
...@@ -151,7 +151,7 @@ fn test__trunctfsf2(a: f128, expected: u32) void {...@@ -151,7 +151,7 @@ fn test__trunctfsf2(a: f128, expected: u32) void {
151}151}
152152
153test "trunctfsf2" {153test "trunctfsf2" {
154 if (@import("std").Target.current.isWindows()) {154 if (@import("std").Target.current.os.tag == .windows) {
155 // TODO https://github.com/ziglang/zig/issues/508155 // TODO https://github.com/ziglang/zig/issues/508
156 return error.SkipZigTest;156 return error.SkipZigTest;
157 }157 }
...@@ -190,7 +190,7 @@ fn test__trunctfdf2(a: f128, expected: u64) void {...@@ -190,7 +190,7 @@ fn test__trunctfdf2(a: f128, expected: u64) void {
190}190}
191191
192test "trunctfdf2" {192test "trunctfdf2" {
193 if (@import("std").Target.current.isWindows()) {193 if (@import("std").Target.current.os.tag == .windows) {
194 // TODO https://github.com/ziglang/zig/issues/508194 // TODO https://github.com/ziglang/zig/issues/508
195 return error.SkipZigTest;195 return error.SkipZigTest;
196 }196 }
lib/std/target.zig+33-85
...@@ -53,6 +53,13 @@ pub const Target = struct {...@@ -53,6 +53,13 @@ pub const Target = struct {
53 emscripten,53 emscripten,
54 uefi,54 uefi,
55 other,55 other,
56
57 pub fn isDarwin(tag: Tag) bool {
58 return switch (tag) {
59 .ios, .macosx, .watchos, .tvos => true,
60 else => false,
61 };
62 }
56 };63 };
5764
58 /// Based on NTDDI version constants from65 /// Based on NTDDI version constants from
...@@ -921,7 +928,7 @@ pub const Target = struct {...@@ -921,7 +928,7 @@ pub const Target = struct {
921 }928 }
922929
923 /// Returned slice must be freed by the caller.930 /// Returned slice must be freed by the caller.
924 pub fn vcpkgTriplet(allocator: *mem.Allocator, target: Target, linkage: std.build.VcpkgLinkage) ![]const u8 {931 pub fn vcpkgTriplet(target: Target, allocator: *mem.Allocator, linkage: std.build.VcpkgLinkage) ![]const u8 {
925 const arch = switch (target.cpu.arch) {932 const arch = switch (target.cpu.arch) {
926 .i386 => "x86",933 .i386 => "x86",
927 .x86_64 => "x64",934 .x86_64 => "x64",
...@@ -960,14 +967,6 @@ pub const Target = struct {...@@ -960,14 +967,6 @@ pub const Target = struct {
960 return self.zigTriple(allocator);967 return self.zigTriple(allocator);
961 }968 }
962969
963 pub fn zigTripleNoSubArch(self: Target, allocator: *mem.Allocator) ![]u8 {
964 return std.fmt.allocPrint(allocator, "{}-{}-{}", .{
965 @tagName(self.cpu.arch),
966 @tagName(self.os.tag),
967 @tagName(self.abi),
968 });
969 }
970
971 pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 {970 pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 {
972 return std.fmt.allocPrint(allocator, "{}-{}-{}", .{971 return std.fmt.allocPrint(allocator, "{}-{}-{}", .{
973 @tagName(self.cpu.arch),972 @tagName(self.cpu.arch),
...@@ -1111,11 +1110,11 @@ pub const Target = struct {...@@ -1111,11 +1110,11 @@ pub const Target = struct {
1111 }1110 }
11121111
1113 pub fn exeFileExt(self: Target) []const u8 {1112 pub fn exeFileExt(self: Target) []const u8 {
1114 if (self.isWindows()) {1113 if (self.os.tag == .windows) {
1115 return ".exe";1114 return ".exe";
1116 } else if (self.isUefi()) {1115 } else if (self.os.tag == .uefi) {
1117 return ".efi";1116 return ".efi";
1118 } else if (self.isWasm()) {1117 } else if (self.cpu.arch.isWasm()) {
1119 return ".wasm";1118 return ".wasm";
1120 } else {1119 } else {
1121 return "";1120 return "";
...@@ -1123,7 +1122,7 @@ pub const Target = struct {...@@ -1123,7 +1122,7 @@ pub const Target = struct {
1123 }1122 }
11241123
1125 pub fn staticLibSuffix(self: Target) []const u8 {1124 pub fn staticLibSuffix(self: Target) []const u8 {
1126 if (self.isWasm()) {1125 if (self.cpu.arch.isWasm()) {
1127 return ".wasm";1126 return ".wasm";
1128 }1127 }
1129 switch (self.abi) {1128 switch (self.abi) {
...@@ -1143,7 +1142,7 @@ pub const Target = struct {...@@ -1143,7 +1142,7 @@ pub const Target = struct {
1143 }1142 }
11441143
1145 pub fn libPrefix(self: Target) []const u8 {1144 pub fn libPrefix(self: Target) []const u8 {
1146 if (self.isWasm()) {1145 if (self.cpu.arch.isWasm()) {
1147 return "";1146 return "";
1148 }1147 }
1149 switch (self.abi) {1148 switch (self.abi) {
...@@ -1153,19 +1152,19 @@ pub const Target = struct {...@@ -1153,19 +1152,19 @@ pub const Target = struct {
1153 }1152 }
11541153
1155 pub fn getObjectFormat(self: Target) ObjectFormat {1154 pub fn getObjectFormat(self: Target) ObjectFormat {
1156 if (self.isWindows() or self.isUefi()) {1155 if (self.os.tag == .windows or self.os.tag == .uefi) {
1157 return .coff;1156 return .coff;
1158 } else if (self.isDarwin()) {1157 } else if (self.isDarwin()) {
1159 return .macho;1158 return .macho;
1160 }1159 }
1161 if (self.isWasm()) {1160 if (self.cpu.arch.isWasm()) {
1162 return .wasm;1161 return .wasm;
1163 }1162 }
1164 return .elf;1163 return .elf;
1165 }1164 }
11661165
1167 pub fn isMinGW(self: Target) bool {1166 pub fn isMinGW(self: Target) bool {
1168 return self.isWindows() and self.isGnu();1167 return self.os.tag == .windows and self.isGnu();
1169 }1168 }
11701169
1171 pub fn isGnu(self: Target) bool {1170 pub fn isGnu(self: Target) bool {
...@@ -1176,27 +1175,6 @@ pub const Target = struct {...@@ -1176,27 +1175,6 @@ pub const Target = struct {
1176 return self.abi.isMusl();1175 return self.abi.isMusl();
1177 }1176 }
11781177
1179 pub fn isDarwin(self: Target) bool {
1180 return switch (self.os.tag) {
1181 .ios, .macosx, .watchos, .tvos => true,
1182 else => false,
1183 };
1184 }
1185
1186 pub fn isWindows(self: Target) bool {
1187 return switch (self.os.tag) {
1188 .windows => true,
1189 else => false,
1190 };
1191 }
1192
1193 pub fn isLinux(self: Target) bool {
1194 return switch (self.os.tag) {
1195 .linux => true,
1196 else => false,
1197 };
1198 }
1199
1200 pub fn isAndroid(self: Target) bool {1178 pub fn isAndroid(self: Target) bool {
1201 return switch (self.abi) {1179 return switch (self.abi) {
1202 .android => true,1180 .android => true,
...@@ -1204,36 +1182,12 @@ pub const Target = struct {...@@ -1204,36 +1182,12 @@ pub const Target = struct {
1204 };1182 };
1205 }1183 }
12061184
1207 pub fn isDragonFlyBSD(self: Target) bool {
1208 return switch (self.os.tag) {
1209 .dragonfly => true,
1210 else => false,
1211 };
1212 }
1213
1214 pub fn isUefi(self: Target) bool {
1215 return switch (self.os.tag) {
1216 .uefi => true,
1217 else => false,
1218 };
1219 }
1220
1221 pub fn isWasm(self: Target) bool {1185 pub fn isWasm(self: Target) bool {
1222 return self.cpu.arch.isWasm();1186 return self.cpu.arch.isWasm();
1223 }1187 }
12241188
1225 pub fn isFreeBSD(self: Target) bool {1189 pub fn isDarwin(self: Target) bool {
1226 return switch (self.os.tag) {1190 return self.os.tag.isDarwin();
1227 .freebsd => true,
1228 else => false,
1229 };
1230 }
1231
1232 pub fn isNetBSD(self: Target) bool {
1233 return switch (self.os.tag) {
1234 .netbsd => true,
1235 else => false,
1236 };
1237 }1191 }
12381192
1239 pub fn isGnuLibC(self: Target) bool {1193 pub fn isGnuLibC(self: Target) bool {
...@@ -1241,11 +1195,11 @@ pub const Target = struct {...@@ -1241,11 +1195,11 @@ pub const Target = struct {
1241 }1195 }
12421196
1243 pub fn wantSharedLibSymLinks(self: Target) bool {1197 pub fn wantSharedLibSymLinks(self: Target) bool {
1244 return !self.isWindows();1198 return self.os.tag != .windows;
1245 }1199 }
12461200
1247 pub fn osRequiresLibC(self: Target) bool {1201 pub fn osRequiresLibC(self: Target) bool {
1248 return self.isDarwin() or self.isFreeBSD() or self.isNetBSD();1202 return self.isDarwin() or self.os.tag == .freebsd or self.os.tag == .netbsd;
1249 }1203 }
12501204
1251 pub fn getArchPtrBitWidth(self: Target) u32 {1205 pub fn getArchPtrBitWidth(self: Target) u32 {
...@@ -1309,7 +1263,7 @@ pub const Target = struct {...@@ -1309,7 +1263,7 @@ pub const Target = struct {
1309 }1263 }
13101264
1311 pub fn supportsNewStackCall(self: Target) bool {1265 pub fn supportsNewStackCall(self: Target) bool {
1312 return !self.isWasm();1266 return !self.cpu.arch.isWasm();
1313 }1267 }
13141268
1315 pub const Executor = union(enum) {1269 pub const Executor = union(enum) {
...@@ -1321,8 +1275,6 @@ pub const Target = struct {...@@ -1321,8 +1275,6 @@ pub const Target = struct {
1321 };1275 };
13221276
1323 pub fn getExternalExecutor(self: Target) Executor {1277 pub fn getExternalExecutor(self: Target) Executor {
1324 if (@as(@TagType(Target), self) == .Native) return .native;
1325
1326 // If the target OS matches the host OS, we can use QEMU to emulate a foreign architecture.1278 // If the target OS matches the host OS, we can use QEMU to emulate a foreign architecture.
1327 if (self.os.tag == builtin.os.tag) {1279 if (self.os.tag == builtin.os.tag) {
1328 return switch (self.cpu.arch) {1280 return switch (self.cpu.arch) {
...@@ -1347,22 +1299,18 @@ pub const Target = struct {...@@ -1347,22 +1299,18 @@ pub const Target = struct {
1347 };1299 };
1348 }1300 }
13491301
1350 if (self.isWindows()) {1302 switch (self.os.tag) {
1351 switch (self.getArchPtrBitWidth()) {1303 .windows => switch (self.getArchPtrBitWidth()) {
1352 32 => return Executor{ .wine = "wine" },1304 32 => return Executor{ .wine = "wine" },
1353 64 => return Executor{ .wine = "wine64" },1305 64 => return Executor{ .wine = "wine64" },
1354 else => return .unavailable,1306 else => return .unavailable,
1355 }1307 },
1356 }1308 .wasi => switch (self.getArchPtrBitWidth()) {
1357
1358 if (self.os == .wasi) {
1359 switch (self.getArchPtrBitWidth()) {
1360 32 => return Executor{ .wasmtime = "wasmtime" },1309 32 => return Executor{ .wasmtime = "wasmtime" },
1361 else => return .unavailable,1310 else => return .unavailable,
1362 }1311 },
1312 else => return .unavailable,
1363 }1313 }
1364
1365 return .unavailable;
1366 }1314 }
13671315
1368 pub const FloatAbi = enum {1316 pub const FloatAbi = enum {
...@@ -1566,12 +1514,12 @@ test "Target.parse" {...@@ -1566,12 +1514,12 @@ test "Target.parse" {
15661514
1567 std.testing.expect(target.cpu.arch == .aarch64);1515 std.testing.expect(target.cpu.arch == .aarch64);
1568 std.testing.expect(target.os.tag == .linux);1516 std.testing.expect(target.os.tag == .linux);
1569 std.testing.expect(target.os.version_range.linux.min.major == 3);1517 std.testing.expect(target.os.version_range.linux.range.min.major == 3);
1570 std.testing.expect(target.os.version_range.linux.min.minor == 10);1518 std.testing.expect(target.os.version_range.linux.range.min.minor == 10);
1571 std.testing.expect(target.os.version_range.linux.min.patch == 0);1519 std.testing.expect(target.os.version_range.linux.range.min.patch == 0);
1572 std.testing.expect(target.os.version_range.linux.max.major == 4);1520 std.testing.expect(target.os.version_range.linux.range.max.major == 4);
1573 std.testing.expect(target.os.version_range.linux.max.minor == 4);1521 std.testing.expect(target.os.version_range.linux.range.max.minor == 4);
1574 std.testing.expect(target.os.version_range.linux.max.patch == 1);1522 std.testing.expect(target.os.version_range.linux.range.max.patch == 1);
1575 std.testing.expect(target.os.version_range.linux.glibc.major == 2);1523 std.testing.expect(target.os.version_range.linux.glibc.major == 2);
1576 std.testing.expect(target.os.version_range.linux.glibc.minor == 27);1524 std.testing.expect(target.os.version_range.linux.glibc.minor == 27);
1577 std.testing.expect(target.os.version_range.linux.glibc.patch == 0);1525 std.testing.expect(target.os.version_range.linux.glibc.patch == 0);
src-self-hosted/libc_installation.zig+5-9
...@@ -7,11 +7,7 @@ const Allocator = std.mem.Allocator;...@@ -7,11 +7,7 @@ const Allocator = std.mem.Allocator;
7const Batch = std.event.Batch;7const Batch = std.event.Batch;
88
9const is_darwin = Target.current.isDarwin();9const is_darwin = Target.current.isDarwin();
10const is_windows = Target.current.isWindows();10const is_windows = Target.current.os.tag == .windows;
11const is_freebsd = Target.current.isFreeBSD();
12const is_netbsd = Target.current.isNetBSD();
13const is_linux = Target.current.isLinux();
14const is_dragonfly = Target.current.isDragonFlyBSD();
15const is_gnu = Target.current.isGnu();11const is_gnu = Target.current.isGnu();
1612
17usingnamespace @import("windows_sdk.zig");13usingnamespace @import("windows_sdk.zig");
...@@ -216,10 +212,10 @@ pub const LibCInstallation = struct {...@@ -216,10 +212,10 @@ pub const LibCInstallation = struct {
216 var batch = Batch(FindError!void, 2, .auto_async).init();212 var batch = Batch(FindError!void, 2, .auto_async).init();
217 errdefer batch.wait() catch {};213 errdefer batch.wait() catch {};
218 batch.add(&async self.findNativeIncludeDirPosix(args));214 batch.add(&async self.findNativeIncludeDirPosix(args));
219 if (is_freebsd or is_netbsd) {215 switch (Target.current.os.tag) {
220 self.crt_dir = try std.mem.dupeZ(args.allocator, u8, "/usr/lib");216 .freebsd, .netbsd => self.crt_dir = try std.mem.dupeZ(args.allocator, u8, "/usr/lib"),
221 } else if (is_linux or is_dragonfly) {217 .linux, .dragonfly => batch.add(&async self.findNativeCrtDirPosix(args)),
222 batch.add(&async self.findNativeCrtDirPosix(args));218 else => {},
223 }219 }
224 break :blk batch.wait();220 break :blk batch.wait();
225 };221 };
test/assemble_and_link.zig+2-2
...@@ -1,8 +1,8 @@...@@ -1,8 +1,8 @@
1const builtin = @import("builtin");1const std = @import("std");
2const tests = @import("tests.zig");2const tests = @import("tests.zig");
33
4pub fn addCases(cases: *tests.CompareOutputContext) void {4pub fn addCases(cases: *tests.CompareOutputContext) void {
5 if (builtin.os == builtin.Os.linux and builtin.arch == builtin.Arch.x86_64) {5 if (std.Target.current.os.tag == .linux and std.Target.current.cpu.arch == .x86_64) {
6 cases.addAsm("hello world linux x86_64",6 cases.addAsm("hello world linux x86_64",
7 \\.text7 \\.text
8 \\.globl _start8 \\.globl _start
test/compile_errors.zig+5-6
...@@ -1,5 +1,4 @@...@@ -1,5 +1,4 @@
1const tests = @import("tests.zig");1const tests = @import("tests.zig");
2const builtin = @import("builtin");
3const Target = @import("std").Target;2const Target = @import("std").Target;
43
5pub fn addCases(cases: *tests.CompileErrorContext) void {4pub fn addCases(cases: *tests.CompileErrorContext) void {
...@@ -387,10 +386,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -387,10 +386,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
387 , &[_][]const u8{386 , &[_][]const u8{
388 "tmp.zig:3:5: error: target arch 'wasm32' does not support calling with a new stack",387 "tmp.zig:3:5: error: target arch 'wasm32' does not support calling with a new stack",
389 });388 });
390 tc.target = Target{389 tc.target = tests.Target{
391 .Cross = .{390 .Cross = .{
392 .cpu = Target.Cpu.baseline(.wasm32),391 .cpu = Target.Cpu.baseline(.wasm32),
393 .os = .wasi,392 .os = Target.Os.defaultVersionRange(.wasi),
394 .abi = .none,393 .abi = .none,
395 },394 },
396 };395 };
...@@ -788,10 +787,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -788,10 +787,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
788 , &[_][]const u8{787 , &[_][]const u8{
789 "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs",788 "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs",
790 });789 });
791 tc.target = Target{790 tc.target = tests.Target{
792 .Cross = .{791 .Cross = .{
793 .cpu = Target.Cpu.baseline(.x86_64),792 .cpu = Target.Cpu.baseline(.x86_64),
794 .os = .linux,793 .os = Target.Os.defaultVersionRange(.linux),
795 .abi = .gnu,794 .abi = .gnu,
796 },795 },
797 };796 };
...@@ -1453,7 +1452,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1453,7 +1452,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1453 "tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}'",1452 "tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}'",
1454 });1453 });
14551454
1456 if (builtin.os == builtin.Os.linux) {1455 if (Target.current.os.tag == .linux) {
1457 cases.addTest("implicit dependency on libc",1456 cases.addTest("implicit dependency on libc",
1458 \\extern "c" fn exit(u8) void;1457 \\extern "c" fn exit(u8) void;
1459 \\export fn entry() void {1458 \\export fn entry() void {
test/src/translate_c.zig+2-2
...@@ -19,7 +19,7 @@ pub const TranslateCContext = struct {...@@ -19,7 +19,7 @@ pub const TranslateCContext = struct {
19 sources: ArrayList(SourceFile),19 sources: ArrayList(SourceFile),
20 expected_lines: ArrayList([]const u8),20 expected_lines: ArrayList([]const u8),
21 allow_warnings: bool,21 allow_warnings: bool,
22 target: std.Target = .Native,22 target: build.Target = .Native,
2323
24 const SourceFile = struct {24 const SourceFile = struct {
25 filename: []const u8,25 filename: []const u8,
...@@ -75,7 +75,7 @@ pub const TranslateCContext = struct {...@@ -75,7 +75,7 @@ pub const TranslateCContext = struct {
75 pub fn addWithTarget(75 pub fn addWithTarget(
76 self: *TranslateCContext,76 self: *TranslateCContext,
77 name: []const u8,77 name: []const u8,
78 target: std.Target,78 target: build.Target,
79 source: []const u8,79 source: []const u8,
80 expected_lines: []const []const u8,80 expected_lines: []const []const u8,
81 ) void {81 ) void {
test/stack_traces.zig+38-39
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1const builtin = @import("builtin");
2const std = @import("std");1const std = @import("std");
3const os = std.os;2const os = std.os;
4const tests = @import("tests.zig");3const tests = @import("tests.zig");
...@@ -43,32 +42,32 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -43,32 +42,32 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
43 \\}42 \\}
44 ;43 ;
4544
46 switch (builtin.os) {45 switch (builtin.os.tag) {
47 .freebsd => {46 .freebsd => {
48 cases.addCase(47 cases.addCase(
49 "return",48 "return",
50 source_return,49 source_return,
51 [_][]const u8{50 [_][]const u8{
52 // debug51 // debug
53 \\error: TheSkyIsFalling52 \\error: TheSkyIsFalling
54 \\source.zig:4:5: [address] in main (test)53 \\source.zig:4:5: [address] in main (test)
55 \\ return error.TheSkyIsFalling;54 \\ return error.TheSkyIsFalling;
56 \\ ^55 \\ ^
57 \\56 \\
58 ,57 ,
59 // release-safe58 // release-safe
60 \\error: TheSkyIsFalling59 \\error: TheSkyIsFalling
61 \\source.zig:4:5: [address] in std.start.main (test)60 \\source.zig:4:5: [address] in std.start.main (test)
62 \\ return error.TheSkyIsFalling;61 \\ return error.TheSkyIsFalling;
63 \\ ^62 \\ ^
64 \\63 \\
65 ,64 ,
66 // release-fast65 // release-fast
67 \\error: TheSkyIsFalling66 \\error: TheSkyIsFalling
68 \\67 \\
69 ,68 ,
70 // release-small69 // release-small
71 \\error: TheSkyIsFalling70 \\error: TheSkyIsFalling
72 \\71 \\
73 },72 },
74 );73 );
...@@ -77,7 +76,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -77,7 +76,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
77 source_try_return,76 source_try_return,
78 [_][]const u8{77 [_][]const u8{
79 // debug78 // debug
80 \\error: TheSkyIsFalling79 \\error: TheSkyIsFalling
81 \\source.zig:4:5: [address] in foo (test)80 \\source.zig:4:5: [address] in foo (test)
82 \\ return error.TheSkyIsFalling;81 \\ return error.TheSkyIsFalling;
83 \\ ^82 \\ ^
...@@ -87,7 +86,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -87,7 +86,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
87 \\86 \\
88 ,87 ,
89 // release-safe88 // release-safe
90 \\error: TheSkyIsFalling89 \\error: TheSkyIsFalling
91 \\source.zig:4:5: [address] in std.start.main (test)90 \\source.zig:4:5: [address] in std.start.main (test)
92 \\ return error.TheSkyIsFalling;91 \\ return error.TheSkyIsFalling;
93 \\ ^92 \\ ^
...@@ -97,11 +96,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -97,11 +96,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
97 \\96 \\
98 ,97 ,
99 // release-fast98 // release-fast
100 \\error: TheSkyIsFalling99 \\error: TheSkyIsFalling
101 \\100 \\
102 ,101 ,
103 // release-small102 // release-small
104 \\error: TheSkyIsFalling103 \\error: TheSkyIsFalling
105 \\104 \\
106 },105 },
107 );106 );
...@@ -110,7 +109,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -110,7 +109,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
110 source_try_try_return_return,109 source_try_try_return_return,
111 [_][]const u8{110 [_][]const u8{
112 // debug111 // debug
113 \\error: TheSkyIsFalling112 \\error: TheSkyIsFalling
114 \\source.zig:12:5: [address] in make_error (test)113 \\source.zig:12:5: [address] in make_error (test)
115 \\ return error.TheSkyIsFalling;114 \\ return error.TheSkyIsFalling;
116 \\ ^115 \\ ^
...@@ -126,7 +125,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -126,7 +125,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
126 \\125 \\
127 ,126 ,
128 // release-safe127 // release-safe
129 \\error: TheSkyIsFalling128 \\error: TheSkyIsFalling
130 \\source.zig:12:5: [address] in std.start.main (test)129 \\source.zig:12:5: [address] in std.start.main (test)
131 \\ return error.TheSkyIsFalling;130 \\ return error.TheSkyIsFalling;
132 \\ ^131 \\ ^
...@@ -142,11 +141,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -142,11 +141,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
142 \\141 \\
143 ,142 ,
144 // release-fast143 // release-fast
145 \\error: TheSkyIsFalling144 \\error: TheSkyIsFalling
146 \\145 \\
147 ,146 ,
148 // release-small147 // release-small
149 \\error: TheSkyIsFalling148 \\error: TheSkyIsFalling
150 \\149 \\
151 },150 },
152 );151 );
...@@ -157,25 +156,25 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -157,25 +156,25 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
157 source_return,156 source_return,
158 [_][]const u8{157 [_][]const u8{
159 // debug158 // debug
160 \\error: TheSkyIsFalling159 \\error: TheSkyIsFalling
161 \\source.zig:4:5: [address] in main (test)160 \\source.zig:4:5: [address] in main (test)
162 \\ return error.TheSkyIsFalling;161 \\ return error.TheSkyIsFalling;
163 \\ ^162 \\ ^
164 \\163 \\
165 ,164 ,
166 // release-safe165 // release-safe
167 \\error: TheSkyIsFalling166 \\error: TheSkyIsFalling
168 \\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test)167 \\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test)
169 \\ return error.TheSkyIsFalling;168 \\ return error.TheSkyIsFalling;
170 \\ ^169 \\ ^
171 \\170 \\
172 ,171 ,
173 // release-fast172 // release-fast
174 \\error: TheSkyIsFalling173 \\error: TheSkyIsFalling
175 \\174 \\
176 ,175 ,
177 // release-small176 // release-small
178 \\error: TheSkyIsFalling177 \\error: TheSkyIsFalling
179 \\178 \\
180 },179 },
181 );180 );
...@@ -184,7 +183,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -184,7 +183,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
184 source_try_return,183 source_try_return,
185 [_][]const u8{184 [_][]const u8{
186 // debug185 // debug
187 \\error: TheSkyIsFalling186 \\error: TheSkyIsFalling
188 \\source.zig:4:5: [address] in foo (test)187 \\source.zig:4:5: [address] in foo (test)
189 \\ return error.TheSkyIsFalling;188 \\ return error.TheSkyIsFalling;
190 \\ ^189 \\ ^
...@@ -194,7 +193,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -194,7 +193,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
194 \\193 \\
195 ,194 ,
196 // release-safe195 // release-safe
197 \\error: TheSkyIsFalling196 \\error: TheSkyIsFalling
198 \\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test)197 \\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test)
199 \\ return error.TheSkyIsFalling;198 \\ return error.TheSkyIsFalling;
200 \\ ^199 \\ ^
...@@ -204,11 +203,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -204,11 +203,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
204 \\203 \\
205 ,204 ,
206 // release-fast205 // release-fast
207 \\error: TheSkyIsFalling206 \\error: TheSkyIsFalling
208 \\207 \\
209 ,208 ,
210 // release-small209 // release-small
211 \\error: TheSkyIsFalling210 \\error: TheSkyIsFalling
212 \\211 \\
213 },212 },
214 );213 );
...@@ -217,7 +216,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -217,7 +216,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
217 source_try_try_return_return,216 source_try_try_return_return,
218 [_][]const u8{217 [_][]const u8{
219 // debug218 // debug
220 \\error: TheSkyIsFalling219 \\error: TheSkyIsFalling
221 \\source.zig:12:5: [address] in make_error (test)220 \\source.zig:12:5: [address] in make_error (test)
222 \\ return error.TheSkyIsFalling;221 \\ return error.TheSkyIsFalling;
223 \\ ^222 \\ ^
...@@ -233,7 +232,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -233,7 +232,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
233 \\232 \\
234 ,233 ,
235 // release-safe234 // release-safe
236 \\error: TheSkyIsFalling235 \\error: TheSkyIsFalling
237 \\source.zig:12:5: [address] in std.start.posixCallMainAndExit (test)236 \\source.zig:12:5: [address] in std.start.posixCallMainAndExit (test)
238 \\ return error.TheSkyIsFalling;237 \\ return error.TheSkyIsFalling;
239 \\ ^238 \\ ^
...@@ -249,11 +248,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -249,11 +248,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
249 \\248 \\
250 ,249 ,
251 // release-fast250 // release-fast
252 \\error: TheSkyIsFalling251 \\error: TheSkyIsFalling
253 \\252 \\
254 ,253 ,
255 // release-small254 // release-small
256 \\error: TheSkyIsFalling255 \\error: TheSkyIsFalling
257 \\256 \\
258 },257 },
259 );258 );
...@@ -278,11 +277,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -278,11 +277,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
278 \\277 \\
279 ,278 ,
280 // release-fast279 // release-fast
281 \\error: TheSkyIsFalling280 \\error: TheSkyIsFalling
282 \\281 \\
283 ,282 ,
284 // release-small283 // release-small
285 \\error: TheSkyIsFalling284 \\error: TheSkyIsFalling
286 \\285 \\
287 },286 },
288 );287 );
...@@ -311,11 +310,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -311,11 +310,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
311 \\310 \\
312 ,311 ,
313 // release-fast312 // release-fast
314 \\error: TheSkyIsFalling313 \\error: TheSkyIsFalling
315 \\314 \\
316 ,315 ,
317 // release-small316 // release-small
318 \\error: TheSkyIsFalling317 \\error: TheSkyIsFalling
319 \\318 \\
320 },319 },
321 );320 );
...@@ -356,11 +355,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -356,11 +355,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
356 \\355 \\
357 ,356 ,
358 // release-fast357 // release-fast
359 \\error: TheSkyIsFalling358 \\error: TheSkyIsFalling
360 \\359 \\
361 ,360 ,
362 // release-small361 // release-small
363 \\error: TheSkyIsFalling362 \\error: TheSkyIsFalling
364 \\363 \\
365 },364 },
366 );365 );
...@@ -371,7 +370,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -371,7 +370,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
371 source_return,370 source_return,
372 [_][]const u8{371 [_][]const u8{
373 // debug372 // debug
374 \\error: TheSkyIsFalling373 \\error: TheSkyIsFalling
375 \\source.zig:4:5: [address] in main (test.obj)374 \\source.zig:4:5: [address] in main (test.obj)
376 \\ return error.TheSkyIsFalling;375 \\ return error.TheSkyIsFalling;
377 \\ ^376 \\ ^
...@@ -381,11 +380,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -381,11 +380,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
381 // --disabled-- results in segmenetation fault380 // --disabled-- results in segmenetation fault
382 "",381 "",
383 // release-fast382 // release-fast
384 \\error: TheSkyIsFalling383 \\error: TheSkyIsFalling
385 \\384 \\
386 ,385 ,
387 // release-small386 // release-small
388 \\error: TheSkyIsFalling387 \\error: TheSkyIsFalling
389 \\388 \\
390 },389 },
391 );390 );
...@@ -407,11 +406,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -407,11 +406,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
407 // --disabled-- results in segmenetation fault406 // --disabled-- results in segmenetation fault
408 "",407 "",
409 // release-fast408 // release-fast
410 \\error: TheSkyIsFalling409 \\error: TheSkyIsFalling
411 \\410 \\
412 ,411 ,
413 // release-small412 // release-small
414 \\error: TheSkyIsFalling413 \\error: TheSkyIsFalling
415 \\414 \\
416 },415 },
417 );416 );
...@@ -439,11 +438,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {...@@ -439,11 +438,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
439 // --disabled-- results in segmenetation fault438 // --disabled-- results in segmenetation fault
440 "",439 "",
441 // release-fast440 // release-fast
442 \\error: TheSkyIsFalling441 \\error: TheSkyIsFalling
443 \\442 \\
444 ,443 ,
445 // release-small444 // release-small
446 \\error: TheSkyIsFalling445 \\error: TheSkyIsFalling
447 \\446 \\
448 },447 },
449 );448 );
test/stage1/behavior/math.zig+10-10
...@@ -529,7 +529,7 @@ test "comptime_int xor" {...@@ -529,7 +529,7 @@ test "comptime_int xor" {
529}529}
530530
531test "f128" {531test "f128" {
532 if (std.Target.current.isWindows()) {532 if (std.Target.current.os.tag == .windows) {
533 // TODO https://github.com/ziglang/zig/issues/508533 // TODO https://github.com/ziglang/zig/issues/508
534 return error.SkipZigTest;534 return error.SkipZigTest;
535 }535 }
...@@ -631,7 +631,7 @@ test "NaN comparison" {...@@ -631,7 +631,7 @@ test "NaN comparison" {
631 // TODO: https://github.com/ziglang/zig/issues/3338631 // TODO: https://github.com/ziglang/zig/issues/3338
632 return error.SkipZigTest;632 return error.SkipZigTest;
633 }633 }
634 if (std.Target.current.isWindows()) {634 if (std.Target.current.os.tag == .windows) {
635 // TODO https://github.com/ziglang/zig/issues/508635 // TODO https://github.com/ziglang/zig/issues/508
636 return error.SkipZigTest;636 return error.SkipZigTest;
637 }637 }
...@@ -666,14 +666,14 @@ test "128-bit multiplication" {...@@ -666,14 +666,14 @@ test "128-bit multiplication" {
666test "vector comparison" {666test "vector comparison" {
667 const S = struct {667 const S = struct {
668 fn doTheTest() void {668 fn doTheTest() void {
669 var a: @Vector(6, i32) = [_]i32{1, 3, -1, 5, 7, 9};669 var a: @Vector(6, i32) = [_]i32{ 1, 3, -1, 5, 7, 9 };
670 var b: @Vector(6, i32) = [_]i32{-1, 3, 0, 6, 10, -10};670 var b: @Vector(6, i32) = [_]i32{ -1, 3, 0, 6, 10, -10 };
671 expect(mem.eql(bool, &@as([6]bool, a < b), &[_]bool{false, false, true, true, true, false}));671 expect(mem.eql(bool, &@as([6]bool, a < b), &[_]bool{ false, false, true, true, true, false }));
672 expect(mem.eql(bool, &@as([6]bool, a <= b), &[_]bool{false, true, true, true, true, false}));672 expect(mem.eql(bool, &@as([6]bool, a <= b), &[_]bool{ false, true, true, true, true, false }));
673 expect(mem.eql(bool, &@as([6]bool, a == b), &[_]bool{false, true, false, false, false, false}));673 expect(mem.eql(bool, &@as([6]bool, a == b), &[_]bool{ false, true, false, false, false, false }));
674 expect(mem.eql(bool, &@as([6]bool, a != b), &[_]bool{true, false, true, true, true, true}));674 expect(mem.eql(bool, &@as([6]bool, a != b), &[_]bool{ true, false, true, true, true, true }));
675 expect(mem.eql(bool, &@as([6]bool, a > b), &[_]bool{true, false, false, false, false, true}));675 expect(mem.eql(bool, &@as([6]bool, a > b), &[_]bool{ true, false, false, false, false, true }));
676 expect(mem.eql(bool, &@as([6]bool, a >= b), &[_]bool{true, true, false, false, false, true}));676 expect(mem.eql(bool, &@as([6]bool, a >= b), &[_]bool{ true, true, false, false, false, true }));
677 }677 }
678 };678 };
679 S.doTheTest();679 S.doTheTest();
test/standalone.zig+2-2
...@@ -18,10 +18,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void {...@@ -18,10 +18,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
18 cases.addBuildFile("test/standalone/use_alias/build.zig");18 cases.addBuildFile("test/standalone/use_alias/build.zig");
19 cases.addBuildFile("test/standalone/brace_expansion/build.zig");19 cases.addBuildFile("test/standalone/brace_expansion/build.zig");
20 cases.addBuildFile("test/standalone/empty_env/build.zig");20 cases.addBuildFile("test/standalone/empty_env/build.zig");
21 if (std.Target.current.getOs() != .wasi) {21 if (std.Target.current.os.tag != .wasi) {
22 cases.addBuildFile("test/standalone/load_dynamic_library/build.zig");22 cases.addBuildFile("test/standalone/load_dynamic_library/build.zig");
23 }23 }
24 if (std.Target.current.getArch() == .x86_64) { // TODO add C ABI support for other architectures24 if (std.Target.current.cpu.arch == .x86_64) { // TODO add C ABI support for other architectures
25 cases.addBuildFile("test/stage1/c_abi/build.zig");25 cases.addBuildFile("test/stage1/c_abi/build.zig");
26 }26 }
27}27}
test/tests.zig+65-62
...@@ -1,16 +1,15 @@...@@ -1,16 +1,15 @@
1const std = @import("std");1const std = @import("std");
2const builtin = std.builtin;
2const debug = std.debug;3const debug = std.debug;
3const warn = debug.warn;4const warn = debug.warn;
4const build = std.build;5const build = std.build;
5pub const Target = build.Target;6pub const Target = build.Target;
6pub const CrossTarget = build.CrossTarget;
7const Buffer = std.Buffer;7const Buffer = std.Buffer;
8const io = std.io;8const io = std.io;
9const fs = std.fs;9const fs = std.fs;
10const mem = std.mem;10const mem = std.mem;
11const fmt = std.fmt;11const fmt = std.fmt;
12const ArrayList = std.ArrayList;12const ArrayList = std.ArrayList;
13const builtin = @import("builtin");
14const Mode = builtin.Mode;13const Mode = builtin.Mode;
15const LibExeObjStep = build.LibExeObjStep;14const LibExeObjStep = build.LibExeObjStep;
1615
...@@ -54,18 +53,18 @@ const test_targets = blk: {...@@ -54,18 +53,18 @@ const test_targets = blk: {
5453
55 TestTarget{54 TestTarget{
56 .target = Target{55 .target = Target{
57 .Cross = CrossTarget{56 .Cross = .{
58 .cpu = Target.Cpu.baseline(.x86_64),57 .cpu = std.Target.Cpu.baseline(.x86_64),
59 .os = Target.Os.defaultVersionRange(.linux),58 .os = std.Target.Os.defaultVersionRange(.linux),
60 .abi = .none,59 .abi = .none,
61 },60 },
62 },61 },
63 },62 },
64 TestTarget{63 TestTarget{
65 .target = Target{64 .target = Target{
66 .Cross = CrossTarget{65 .Cross = .{
67 .cpu = Target.Cpu.baseline(.x86_64),66 .cpu = std.Target.Cpu.baseline(.x86_64),
68 .os = Target.Os.defaultVersionRange(.linux),67 .os = std.Target.Os.defaultVersionRange(.linux),
69 .abi = .gnu,68 .abi = .gnu,
70 },69 },
71 },70 },
...@@ -73,9 +72,9 @@ const test_targets = blk: {...@@ -73,9 +72,9 @@ const test_targets = blk: {
73 },72 },
74 TestTarget{73 TestTarget{
75 .target = Target{74 .target = Target{
76 .Cross = CrossTarget{75 .Cross = .{
77 .cpu = Target.Cpu.baseline(.x86_64),76 .cpu = std.Target.Cpu.baseline(.x86_64),
78 .os = Target.Os.defaultVersionRange(.linux),77 .os = std.Target.Os.defaultVersionRange(.linux),
79 .abi = .musl,78 .abi = .musl,
80 },79 },
81 },80 },
...@@ -84,18 +83,18 @@ const test_targets = blk: {...@@ -84,18 +83,18 @@ const test_targets = blk: {
8483
85 TestTarget{84 TestTarget{
86 .target = Target{85 .target = Target{
87 .Cross = CrossTarget{86 .Cross = .{
88 .cpu = Target.Cpu.baseline(.i386),87 .cpu = std.Target.Cpu.baseline(.i386),
89 .os = Target.Os.defaultVersionRange(.linux),88 .os = std.Target.Os.defaultVersionRange(.linux),
90 .abi = .none,89 .abi = .none,
91 },90 },
92 },91 },
93 },92 },
94 TestTarget{93 TestTarget{
95 .target = Target{94 .target = Target{
96 .Cross = CrossTarget{95 .Cross = .{
97 .cpu = Target.Cpu.baseline(.i386),96 .cpu = std.Target.Cpu.baseline(.i386),
98 .os = Target.Os.defaultVersionRange(.linux),97 .os = std.Target.Os.defaultVersionRange(.linux),
99 .abi = .musl,98 .abi = .musl,
100 },99 },
101 },100 },
...@@ -104,18 +103,18 @@ const test_targets = blk: {...@@ -104,18 +103,18 @@ const test_targets = blk: {
104103
105 TestTarget{104 TestTarget{
106 .target = Target{105 .target = Target{
107 .Cross = CrossTarget{106 .Cross = .{
108 .cpu = Target.Cpu.baseline(.aarch64),107 .cpu = std.Target.Cpu.baseline(.aarch64),
109 .os = Target.Os.defaultVersionRange(.linux),108 .os = std.Target.Os.defaultVersionRange(.linux),
110 .abi = .none,109 .abi = .none,
111 },110 },
112 },111 },
113 },112 },
114 TestTarget{113 TestTarget{
115 .target = Target{114 .target = Target{
116 .Cross = CrossTarget{115 .Cross = .{
117 .cpu = Target.Cpu.baseline(.aarch64),116 .cpu = std.Target.Cpu.baseline(.aarch64),
118 .os = Target.Os.defaultVersionRange(.linux),117 .os = std.Target.Os.defaultVersionRange(.linux),
119 .abi = .musl,118 .abi = .musl,
120 },119 },
121 },120 },
...@@ -123,9 +122,9 @@ const test_targets = blk: {...@@ -123,9 +122,9 @@ const test_targets = blk: {
123 },122 },
124 TestTarget{123 TestTarget{
125 .target = Target{124 .target = Target{
126 .Cross = CrossTarget{125 .Cross = .{
127 .cpu = Target.Cpu.baseline(.aarch64),126 .cpu = std.Target.Cpu.baseline(.aarch64),
128 .os = Target.Os.defaultVersionRange(.linux),127 .os = std.Target.Os.defaultVersionRange(.linux),
129 .abi = .gnu,128 .abi = .gnu,
130 },129 },
131 },130 },
...@@ -133,21 +132,25 @@ const test_targets = blk: {...@@ -133,21 +132,25 @@ const test_targets = blk: {
133 },132 },
134133
135 TestTarget{134 TestTarget{
136 .target = Target.parse(.{135 .target = .{
137 .arch_os_abi = "arm-linux-none",136 .Cross = std.Target.parse(.{
138 .cpu_features = "generic+v8a",137 .arch_os_abi = "arm-linux-none",
139 }) catch unreachable,138 .cpu_features = "generic+v8a",
139 }) catch unreachable,
140 },
140 },141 },
141 TestTarget{142 TestTarget{
142 .target = Target.parse(.{143 .target = .{
143 .arch_os_abi = "arm-linux-musleabihf",144 .Cross = std.Target.parse(.{
144 .cpu_features = "generic+v8a",145 .arch_os_abi = "arm-linux-musleabihf",
145 }) catch unreachable,146 .cpu_features = "generic+v8a",
147 }) catch unreachable,
148 },
146 .link_libc = true,149 .link_libc = true,
147 },150 },
148 // TODO https://github.com/ziglang/zig/issues/3287151 // TODO https://github.com/ziglang/zig/issues/3287
149 //TestTarget{152 //TestTarget{
150 // .target = Target.parse(.{153 // .target = std.Target.parse(.{
151 // .arch_os_abi = "arm-linux-gnueabihf",154 // .arch_os_abi = "arm-linux-gnueabihf",
152 // .cpu_features = "generic+v8a",155 // .cpu_features = "generic+v8a",
153 // }) catch unreachable,156 // }) catch unreachable,
...@@ -156,18 +159,18 @@ const test_targets = blk: {...@@ -156,18 +159,18 @@ const test_targets = blk: {
156159
157 TestTarget{160 TestTarget{
158 .target = Target{161 .target = Target{
159 .Cross = CrossTarget{162 .Cross = .{
160 .cpu = Target.Cpu.baseline(.mipsel),163 .cpu = std.Target.Cpu.baseline(.mipsel),
161 .os = Target.Os.defaultVersionRange(.linux),164 .os = std.Target.Os.defaultVersionRange(.linux),
162 .abi = .none,165 .abi = .none,
163 },166 },
164 },167 },
165 },168 },
166 TestTarget{169 TestTarget{
167 .target = Target{170 .target = Target{
168 .Cross = CrossTarget{171 .Cross = .{
169 .cpu = Target.Cpu.baseline(.mipsel),172 .cpu = std.Target.Cpu.baseline(.mipsel),
170 .os = Target.Os.defaultVersionRange(.linux),173 .os = std.Target.Os.defaultVersionRange(.linux),
171 .abi = .musl,174 .abi = .musl,
172 },175 },
173 },176 },
...@@ -176,9 +179,9 @@ const test_targets = blk: {...@@ -176,9 +179,9 @@ const test_targets = blk: {
176179
177 TestTarget{180 TestTarget{
178 .target = Target{181 .target = Target{
179 .Cross = CrossTarget{182 .Cross = .{
180 .cpu = Target.Cpu.baseline(.x86_64),183 .cpu = std.Target.Cpu.baseline(.x86_64),
181 .os = Target.Os.defaultVersionRange(.macosx),184 .os = std.Target.Os.defaultVersionRange(.macosx),
182 .abi = .gnu,185 .abi = .gnu,
183 },186 },
184 },187 },
...@@ -188,9 +191,9 @@ const test_targets = blk: {...@@ -188,9 +191,9 @@ const test_targets = blk: {
188191
189 TestTarget{192 TestTarget{
190 .target = Target{193 .target = Target{
191 .Cross = CrossTarget{194 .Cross = .{
192 .cpu = Target.Cpu.baseline(.i386),195 .cpu = std.Target.Cpu.baseline(.i386),
193 .os = Target.Os.defaultVersionRange(.windows),196 .os = std.Target.Os.defaultVersionRange(.windows),
194 .abi = .msvc,197 .abi = .msvc,
195 },198 },
196 },199 },
...@@ -198,9 +201,9 @@ const test_targets = blk: {...@@ -198,9 +201,9 @@ const test_targets = blk: {
198201
199 TestTarget{202 TestTarget{
200 .target = Target{203 .target = Target{
201 .Cross = CrossTarget{204 .Cross = .{
202 .cpu = Target.Cpu.baseline(.x86_64),205 .cpu = std.Target.Cpu.baseline(.x86_64),
203 .os = Target.Os.defaultVersionRange(.windows),206 .os = std.Target.Os.defaultVersionRange(.windows),
204 .abi = .msvc,207 .abi = .msvc,
205 },208 },
206 },209 },
...@@ -208,9 +211,9 @@ const test_targets = blk: {...@@ -208,9 +211,9 @@ const test_targets = blk: {
208211
209 TestTarget{212 TestTarget{
210 .target = Target{213 .target = Target{
211 .Cross = CrossTarget{214 .Cross = .{
212 .cpu = Target.Cpu.baseline(.i386),215 .cpu = std.Target.Cpu.baseline(.i386),
213 .os = Target.Os.defaultVersionRange(.windows),216 .os = std.Target.Os.defaultVersionRange(.windows),
214 .abi = .gnu,217 .abi = .gnu,
215 },218 },
216 },219 },
...@@ -219,9 +222,9 @@ const test_targets = blk: {...@@ -219,9 +222,9 @@ const test_targets = blk: {
219222
220 TestTarget{223 TestTarget{
221 .target = Target{224 .target = Target{
222 .Cross = CrossTarget{225 .Cross = .{
223 .cpu = Target.Cpu.baseline(.x86_64),226 .cpu = std.Target.Cpu.baseline(.x86_64),
224 .os = Target.Os.defaultVersionRange(.windows),227 .os = std.Target.Os.defaultVersionRange(.windows),
225 .abi = .gnu,228 .abi = .gnu,
226 },229 },
227 },230 },
...@@ -438,7 +441,7 @@ pub fn addPkgTests(...@@ -438,7 +441,7 @@ pub fn addPkgTests(
438 if (skip_libc and test_target.link_libc)441 if (skip_libc and test_target.link_libc)
439 continue;442 continue;
440443
441 if (test_target.link_libc and test_target.target.osRequiresLibC()) {444 if (test_target.link_libc and test_target.target.getTarget().osRequiresLibC()) {
442 // This would be a redundant test.445 // This would be a redundant test.
443 continue;446 continue;
444 }447 }
...@@ -448,8 +451,8 @@ pub fn addPkgTests(...@@ -448,8 +451,8 @@ pub fn addPkgTests(
448451
449 const ArchTag = @TagType(builtin.Arch);452 const ArchTag = @TagType(builtin.Arch);
450 if (test_target.disable_native and453 if (test_target.disable_native and
451 test_target.target.getOs() == builtin.os and454 test_target.target.getOs() == std.Target.current.os.tag and
452 test_target.target.getArch() == builtin.arch)455 test_target.target.getArch() == std.Target.current.cpu.arch)
453 {456 {
454 continue;457 continue;
455 }458 }
...@@ -459,7 +462,7 @@ pub fn addPkgTests(...@@ -459,7 +462,7 @@ pub fn addPkgTests(
459 } else false;462 } else false;
460 if (!want_this_mode) continue;463 if (!want_this_mode) continue;
461464
462 const libc_prefix = if (test_target.target.osRequiresLibC())465 const libc_prefix = if (test_target.target.getTarget().osRequiresLibC())
463 ""466 ""
464 else if (test_target.link_libc)467 else if (test_target.link_libc)
465 "c"468 "c"
...@@ -469,7 +472,7 @@ pub fn addPkgTests(...@@ -469,7 +472,7 @@ pub fn addPkgTests(
469 const triple_prefix = if (test_target.target == .Native)472 const triple_prefix = if (test_target.target == .Native)
470 @as([]const u8, "native")473 @as([]const u8, "native")
471 else474 else
472 test_target.target.zigTripleNoSubArch(b.allocator) catch unreachable;475 test_target.target.zigTriple(b.allocator) catch unreachable;
473476
474 const these_tests = b.addTest(root_src);477 const these_tests = b.addTest(root_src);
475 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";478 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
...@@ -660,7 +663,7 @@ pub const StackTracesContext = struct {...@@ -660,7 +663,7 @@ pub const StackTracesContext = struct {
660 const delims = [_][]const u8{ ":", ":", ":", " in " };663 const delims = [_][]const u8{ ":", ":", ":", " in " };
661 var marks = [_]usize{0} ** 4;664 var marks = [_]usize{0} ** 4;
662 // offset search past `[drive]:` on windows665 // offset search past `[drive]:` on windows
663 var pos: usize = if (builtin.os == .windows) 2 else 0;666 var pos: usize = if (std.Target.current.os.tag == .windows) 2 else 0;
664 for (delims) |delim, i| {667 for (delims) |delim, i| {
665 marks[i] = mem.indexOfPos(u8, line, pos, delim) orelse {668 marks[i] = mem.indexOfPos(u8, line, pos, delim) orelse {
666 try buf.append(line);669 try buf.append(line);
test/translate_c.zig+19-15
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const tests = @import("tests.zig");1const tests = @import("tests.zig");
2const builtin = @import("builtin");2const std = @import("std");
3const Target = @import("std").Target;3const Target = std.Target;
44
5pub fn addCases(cases: *tests.TranslateCContext) void {5pub fn addCases(cases: *tests.TranslateCContext) void {
6 cases.add("macro line continuation",6 cases.add("macro line continuation",
...@@ -665,7 +665,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -665,7 +665,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
665 \\}665 \\}
666 });666 });
667667
668 if (builtin.os != builtin.Os.windows) {668 if (Target.current.os.tag != .windows) {
669 // Windows treats this as an enum with type c_int669 // Windows treats this as an enum with type c_int
670 cases.add("big negative enum init values when C ABI supports long long enums",670 cases.add("big negative enum init values when C ABI supports long long enums",
671 \\enum EnumWithInits {671 \\enum EnumWithInits {
...@@ -1064,7 +1064,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1064,7 +1064,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1064 \\}1064 \\}
1065 });1065 });
10661066
1067 if (builtin.os != builtin.Os.windows) {1067 if (Target.current.os.tag != .windows) {
1068 // sysv_abi not currently supported on windows1068 // sysv_abi not currently supported on windows
1069 cases.add("Macro qualified functions",1069 cases.add("Macro qualified functions",
1070 \\void __attribute__((sysv_abi)) foo(void);1070 \\void __attribute__((sysv_abi)) foo(void);
...@@ -1093,10 +1093,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1093,10 +1093,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1093 \\pub const fn1 = ?fn (u8) callconv(.C) void;1093 \\pub const fn1 = ?fn (u8) callconv(.C) void;
1094 });1094 });
10951095
1096 cases.addWithTarget("Calling convention", tests.Target{1096 cases.addWithTarget("Calling convention", .{
1097 .Cross = .{1097 .Cross = .{
1098 .cpu = Target.Cpu.baseline(.i386),1098 .cpu = Target.Cpu.baseline(.i386),
1099 .os = .linux,1099 .os = Target.Os.defaultVersionRange(.linux),
1100 .abi = .none,1100 .abi = .none,
1101 },1101 },
1102 },1102 },
...@@ -1113,10 +1113,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1113,10 +1113,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1113 \\pub fn foo5(a: [*c]f32) callconv(.Thiscall) void;1113 \\pub fn foo5(a: [*c]f32) callconv(.Thiscall) void;
1114 });1114 });
11151115
1116 cases.addWithTarget("Calling convention", Target.parse(.{1116 cases.addWithTarget("Calling convention", .{
1117 .arch_os_abi = "arm-linux-none",1117 .Cross = Target.parse(.{
1118 .cpu_features = "generic+v8_5a",1118 .arch_os_abi = "arm-linux-none",
1119 }) catch unreachable,1119 .cpu_features = "generic+v8_5a",
1120 }) catch unreachable,
1121 },
1120 \\void __attribute__((pcs("aapcs"))) foo1(float *a);1122 \\void __attribute__((pcs("aapcs"))) foo1(float *a);
1121 \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a);1123 \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a);
1122 , &[_][]const u8{1124 , &[_][]const u8{
...@@ -1124,10 +1126,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1124,10 +1126,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1124 \\pub fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void;1126 \\pub fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void;
1125 });1127 });
11261128
1127 cases.addWithTarget("Calling convention", Target.parse(.{1129 cases.addWithTarget("Calling convention", .{
1128 .arch_os_abi = "aarch64-linux-none",1130 .Cross = Target.parse(.{
1129 .cpu_features = "generic+v8_5a",1131 .arch_os_abi = "aarch64-linux-none",
1130 }) catch unreachable,1132 .cpu_features = "generic+v8_5a",
1133 }) catch unreachable,
1134 },
1131 \\void __attribute__((aarch64_vector_pcs)) foo1(float *a);1135 \\void __attribute__((aarch64_vector_pcs)) foo1(float *a);
1132 , &[_][]const u8{1136 , &[_][]const u8{
1133 \\pub fn foo1(a: [*c]f32) callconv(.Vectorcall) void;1137 \\pub fn foo1(a: [*c]f32) callconv(.Vectorcall) void;
...@@ -1596,7 +1600,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1596,7 +1600,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1596 \\}1600 \\}
1597 });1601 });
15981602
1599 if (builtin.os != .windows) {1603 if (Target.current.os.tag != .windows) {
1600 // When clang uses the <arch>-windows-none triple it behaves as MSVC and1604 // When clang uses the <arch>-windows-none triple it behaves as MSVC and
1601 // interprets the inner `struct Bar` as an anonymous structure1605 // interprets the inner `struct Bar` as an anonymous structure
1602 cases.add("type referenced struct",1606 cases.add("type referenced struct",