| author | |
| committer | |
| log | 87b9e744dda465ecf7663e2463066ea26a44e63a |
| tree | e3c09dca4b8a06656029b1034da24ed9b7507299 |
| parent | d4f375c46be2e509ee9161b0577d8a25d6620b3e |
| signature |
29 files changed, 281 insertions(+), 261 deletions(-)
lib/std/build.zig+76-5| ... | ... | @@ -971,7 +971,7 @@ pub const Builder = struct { |
| 971 | 971 | }; |
| 972 | 972 | |
| 973 | 973 | test "builder.findProgram compiles" { |
| 974 | var buf: [1000]u8 = undefined; | |
| 974 | var buf: [50000]u8 = undefined; | |
| 975 | 975 | var fba = std.heap.FixedBufferAllocator.init(&buf); |
| 976 | 976 | const builder = try Builder.create(&fba.allocator, "zig", "zig-cache", "zig-cache"); |
| 977 | 977 | defer builder.destroy(); |
| ... | ... | @@ -1011,6 +1011,77 @@ pub const Target = union(enum) { |
| 1011 | 1011 | pub fn getArch(self: Target) std.Target.Cpu.Arch { |
| 1012 | 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 | }; |
| 1015 | 1086 | |
| 1016 | 1087 | pub const Pkg = struct { |
| ... | ... | @@ -1718,7 +1789,7 @@ pub const LibExeObjStep = struct { |
| 1718 | 1789 | .NotFound => return error.VcpkgNotFound, |
| 1719 | 1790 | .Found => |root| { |
| 1720 | 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 | 1793 | defer self.builder.allocator.free(triplet); |
| 1723 | 1794 | |
| 1724 | 1795 | const include_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "include" }); |
| ... | ... | @@ -1944,7 +2015,7 @@ pub const LibExeObjStep = struct { |
| 1944 | 2015 | if (populated_cpu_features.eql(cross.cpu.features)) { |
| 1945 | 2016 | // The CPU name alone is sufficient. |
| 1946 | 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 | 2019 | try zig_args.append("-mcpu"); |
| 1949 | 2020 | try zig_args.append(cross.cpu.model.name); |
| 1950 | 2021 | } |
| ... | ... | @@ -1953,7 +2024,7 @@ pub const LibExeObjStep = struct { |
| 1953 | 2024 | try mcpu_buffer.append(cross.cpu.model.name); |
| 1954 | 2025 | |
| 1955 | 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 | 2028 | const in_cpu_set = populated_cpu_features.isEnabled(i); |
| 1958 | 2029 | const in_actual_set = cross.cpu.features.isEnabled(i); |
| 1959 | 2030 | if (in_cpu_set and !in_actual_set) { |
| ... | ... | @@ -2001,7 +2072,7 @@ pub const LibExeObjStep = struct { |
| 2001 | 2072 | } else switch (self.target.getExternalExecutor()) { |
| 2002 | 2073 | .native, .unavailable => {}, |
| 2003 | 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 | 2076 | const glibc_dir_arg = if (need_cross_glibc) |
| 2006 | 2077 | self.glibc_multi_install_dir orelse break :qemu |
| 2007 | 2078 | else |
lib/std/build/translate_c.zig+2-2| ... | ... | @@ -14,7 +14,7 @@ pub const TranslateCStep = struct { |
| 14 | 14 | source: build.FileSource, |
| 15 | 15 | output_dir: ?[]const u8, |
| 16 | 16 | out_basename: []const u8, |
| 17 | target: std.Target = .Native, | |
| 17 | target: build.Target = .Native, | |
| 18 | 18 | |
| 19 | 19 | pub fn create(builder: *Builder, source: build.FileSource) *TranslateCStep { |
| 20 | 20 | const self = builder.allocator.create(TranslateCStep) catch unreachable; |
| ... | ... | @@ -39,7 +39,7 @@ pub const TranslateCStep = struct { |
| 39 | 39 | ) catch unreachable; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | pub fn setTarget(self: *TranslateCStep, target: std.Target) void { | |
| 42 | pub fn setTarget(self: *TranslateCStep, target: build.Target) void { | |
| 43 | 43 | self.target = target; |
| 44 | 44 | } |
| 45 | 45 |
lib/std/fmt/parse_float.zig+1-1| ... | ... | @@ -382,7 +382,7 @@ pub fn parseFloat(comptime T: type, s: []const u8) !T { |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | test "fmt.parseFloat" { |
| 385 | if (std.Target.current.isWindows()) { | |
| 385 | if (std.Target.current.os.tag == .windows) { | |
| 386 | 386 | // TODO https://github.com/ziglang/zig/issues/508 |
| 387 | 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 | 544 | } |
| 545 | 545 | |
| 546 | 546 | test "Serializer/Deserializer generic" { |
| 547 | if (std.Target.current.isWindows()) { | |
| 547 | if (std.Target.current.os.tag == .windows) { | |
| 548 | 548 | // TODO https://github.com/ziglang/zig/issues/508 |
| 549 | 549 | return error.SkipZigTest; |
| 550 | 550 | } |
lib/std/math/fabs.zig+1-1| ... | ... | @@ -95,7 +95,7 @@ test "math.fabs64.special" { |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | test "math.fabs128.special" { |
| 98 | if (std.Target.current.isWindows()) { | |
| 98 | if (std.Target.current.os.tag == .windows) { | |
| 99 | 99 | // TODO https://github.com/ziglang/zig/issues/508 |
| 100 | 100 | return error.SkipZigTest; |
| 101 | 101 | } |
lib/std/math/isinf.zig+3-3| ... | ... | @@ -74,7 +74,7 @@ pub fn isNegativeInf(x: var) bool { |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | test "math.isInf" { |
| 77 | if (std.Target.current.isWindows()) { | |
| 77 | if (std.Target.current.os.tag == .windows) { | |
| 78 | 78 | // TODO https://github.com/ziglang/zig/issues/508 |
| 79 | 79 | return error.SkipZigTest; |
| 80 | 80 | } |
| ... | ... | @@ -97,7 +97,7 @@ test "math.isInf" { |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | test "math.isPositiveInf" { |
| 100 | if (std.Target.current.isWindows()) { | |
| 100 | if (std.Target.current.os.tag == .windows) { | |
| 101 | 101 | // TODO https://github.com/ziglang/zig/issues/508 |
| 102 | 102 | return error.SkipZigTest; |
| 103 | 103 | } |
| ... | ... | @@ -120,7 +120,7 @@ test "math.isPositiveInf" { |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | test "math.isNegativeInf" { |
| 123 | if (std.Target.current.isWindows()) { | |
| 123 | if (std.Target.current.os.tag == .windows) { | |
| 124 | 124 | // TODO https://github.com/ziglang/zig/issues/508 |
| 125 | 125 | return error.SkipZigTest; |
| 126 | 126 | } |
lib/std/math/isnan.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ pub fn isSignalNan(x: var) bool { |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | test "math.isNan" { |
| 19 | if (std.Target.current.isWindows()) { | |
| 19 | if (std.Target.current.os.tag == .windows) { | |
| 20 | 20 | // TODO https://github.com/ziglang/zig/issues/508 |
| 21 | 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 | 650 | /// On Windows, if the application has a global event loop enabled, I/O Completion Ports are |
| 651 | 651 | /// used to perform the I/O. `error.WouldBlock` is not possible on Windows. |
| 652 | 652 | pub 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 | 654 | return windows.WriteFile(fd, bytes, offset); |
| 655 | 655 | } |
| 656 | 656 | |
| ... | ... | @@ -739,7 +739,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) WriteError!void |
| 739 | 739 | } |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | if (comptime std.Target.current.isWindows()) { | |
| 742 | if (std.Target.current.os.tag == .windows) { | |
| 743 | 743 | var off = offset; |
| 744 | 744 | for (iov) |item| { |
| 745 | 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 | 31 | } |
| 32 | 32 | |
| 33 | 33 | test "addtf3" { |
| 34 | if (@import("std").Target.current.isWindows()) { | |
| 34 | if (@import("std").Target.current.os.tag == .windows) { | |
| 35 | 35 | // TODO https://github.com/ziglang/zig/issues/508 |
| 36 | 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 | 75 | } |
| 76 | 76 | |
| 77 | 77 | test "subtf3" { |
| 78 | if (@import("std").Target.current.isWindows()) { | |
| 78 | if (@import("std").Target.current.os.tag == .windows) { | |
| 79 | 79 | // TODO https://github.com/ziglang/zig/issues/508 |
| 80 | 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 | 11 | } |
| 12 | 12 | |
| 13 | 13 | test "fixtfdi" { |
| 14 | if (@import("std").Target.current.isWindows()) { | |
| 14 | if (@import("std").Target.current.os.tag == .windows) { | |
| 15 | 15 | // TODO https://github.com/ziglang/zig/issues/508 |
| 16 | 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 | 11 | } |
| 12 | 12 | |
| 13 | 13 | test "fixtfsi" { |
| 14 | if (@import("std").Target.current.isWindows()) { | |
| 14 | if (@import("std").Target.current.os.tag == .windows) { | |
| 15 | 15 | // TODO https://github.com/ziglang/zig/issues/508 |
| 16 | 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 | 11 | } |
| 12 | 12 | |
| 13 | 13 | test "fixtfti" { |
| 14 | if (@import("std").Target.current.isWindows()) { | |
| 14 | if (@import("std").Target.current.os.tag == .windows) { | |
| 15 | 15 | // TODO https://github.com/ziglang/zig/issues/508 |
| 16 | 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 | } |
| 8 | 8 | |
| 9 | 9 | test "fixunstfdi" { |
| 10 | if (@import("std").Target.current.isWindows()) { | |
| 10 | if (@import("std").Target.current.os.tag == .windows) { | |
| 11 | 11 | // TODO https://github.com/ziglang/zig/issues/508 |
| 12 | 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 | 9 | const inf128 = @bitCast(f128, @as(u128, 0x7fff0000000000000000000000000000)); |
| 10 | 10 | |
| 11 | 11 | test "fixunstfsi" { |
| 12 | if (@import("std").Target.current.isWindows()) { | |
| 12 | if (@import("std").Target.current.os.tag == .windows) { | |
| 13 | 13 | // TODO https://github.com/ziglang/zig/issues/508 |
| 14 | 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 | 9 | const inf128 = @bitCast(f128, @as(u128, 0x7fff0000000000000000000000000000)); |
| 10 | 10 | |
| 11 | 11 | test "fixunstfti" { |
| 12 | if (@import("std").Target.current.isWindows()) { | |
| 12 | if (@import("std").Target.current.os.tag == .windows) { | |
| 13 | 13 | // TODO https://github.com/ziglang/zig/issues/508 |
| 14 | 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 | } |
| 8 | 8 | |
| 9 | 9 | test "floattitf" { |
| 10 | if (@import("std").Target.current.isWindows()) { | |
| 10 | if (@import("std").Target.current.os.tag == .windows) { | |
| 11 | 11 | // TODO https://github.com/ziglang/zig/issues/508 |
| 12 | 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 | } |
| 8 | 8 | |
| 9 | 9 | test "floatuntitf" { |
| 10 | if (@import("std").Target.current.isWindows()) { | |
| 10 | if (@import("std").Target.current.os.tag == .windows) { | |
| 11 | 11 | // TODO https://github.com/ziglang/zig/issues/508 |
| 12 | 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 | 44 | return float_result; |
| 45 | 45 | } |
| 46 | 46 | test "multf3" { |
| 47 | if (@import("std").Target.current.isWindows()) { | |
| 47 | if (@import("std").Target.current.os.tag == .windows) { | |
| 48 | 48 | // TODO https://github.com/ziglang/zig/issues/508 |
| 49 | 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 | 151 | } |
| 152 | 152 | |
| 153 | 153 | test "trunctfsf2" { |
| 154 | if (@import("std").Target.current.isWindows()) { | |
| 154 | if (@import("std").Target.current.os.tag == .windows) { | |
| 155 | 155 | // TODO https://github.com/ziglang/zig/issues/508 |
| 156 | 156 | return error.SkipZigTest; |
| 157 | 157 | } |
| ... | ... | @@ -190,7 +190,7 @@ fn test__trunctfdf2(a: f128, expected: u64) void { |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | test "trunctfdf2" { |
| 193 | if (@import("std").Target.current.isWindows()) { | |
| 193 | if (@import("std").Target.current.os.tag == .windows) { | |
| 194 | 194 | // TODO https://github.com/ziglang/zig/issues/508 |
| 195 | 195 | return error.SkipZigTest; |
| 196 | 196 | } |
lib/std/target.zig+33-85| ... | ... | @@ -53,6 +53,13 @@ pub const Target = struct { |
| 53 | 53 | emscripten, |
| 54 | 54 | uefi, |
| 55 | 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 | }; |
| 57 | 64 | |
| 58 | 65 | /// Based on NTDDI version constants from |
| ... | ... | @@ -921,7 +928,7 @@ pub const Target = struct { |
| 921 | 928 | } |
| 922 | 929 | |
| 923 | 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 | 932 | const arch = switch (target.cpu.arch) { |
| 926 | 933 | .i386 => "x86", |
| 927 | 934 | .x86_64 => "x64", |
| ... | ... | @@ -960,14 +967,6 @@ pub const Target = struct { |
| 960 | 967 | return self.zigTriple(allocator); |
| 961 | 968 | } |
| 962 | 969 | |
| 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 | 970 | pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 { |
| 972 | 971 | return std.fmt.allocPrint(allocator, "{}-{}-{}", .{ |
| 973 | 972 | @tagName(self.cpu.arch), |
| ... | ... | @@ -1111,11 +1110,11 @@ pub const Target = struct { |
| 1111 | 1110 | } |
| 1112 | 1111 | |
| 1113 | 1112 | pub fn exeFileExt(self: Target) []const u8 { |
| 1114 | if (self.isWindows()) { | |
| 1113 | if (self.os.tag == .windows) { | |
| 1115 | 1114 | return ".exe"; |
| 1116 | } else if (self.isUefi()) { | |
| 1115 | } else if (self.os.tag == .uefi) { | |
| 1117 | 1116 | return ".efi"; |
| 1118 | } else if (self.isWasm()) { | |
| 1117 | } else if (self.cpu.arch.isWasm()) { | |
| 1119 | 1118 | return ".wasm"; |
| 1120 | 1119 | } else { |
| 1121 | 1120 | return ""; |
| ... | ... | @@ -1123,7 +1122,7 @@ pub const Target = struct { |
| 1123 | 1122 | } |
| 1124 | 1123 | |
| 1125 | 1124 | pub fn staticLibSuffix(self: Target) []const u8 { |
| 1126 | if (self.isWasm()) { | |
| 1125 | if (self.cpu.arch.isWasm()) { | |
| 1127 | 1126 | return ".wasm"; |
| 1128 | 1127 | } |
| 1129 | 1128 | switch (self.abi) { |
| ... | ... | @@ -1143,7 +1142,7 @@ pub const Target = struct { |
| 1143 | 1142 | } |
| 1144 | 1143 | |
| 1145 | 1144 | pub fn libPrefix(self: Target) []const u8 { |
| 1146 | if (self.isWasm()) { | |
| 1145 | if (self.cpu.arch.isWasm()) { | |
| 1147 | 1146 | return ""; |
| 1148 | 1147 | } |
| 1149 | 1148 | switch (self.abi) { |
| ... | ... | @@ -1153,19 +1152,19 @@ pub const Target = struct { |
| 1153 | 1152 | } |
| 1154 | 1153 | |
| 1155 | 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 | 1156 | return .coff; |
| 1158 | 1157 | } else if (self.isDarwin()) { |
| 1159 | 1158 | return .macho; |
| 1160 | 1159 | } |
| 1161 | if (self.isWasm()) { | |
| 1160 | if (self.cpu.arch.isWasm()) { | |
| 1162 | 1161 | return .wasm; |
| 1163 | 1162 | } |
| 1164 | 1163 | return .elf; |
| 1165 | 1164 | } |
| 1166 | 1165 | |
| 1167 | 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 | } |
| 1170 | 1169 | |
| 1171 | 1170 | pub fn isGnu(self: Target) bool { |
| ... | ... | @@ -1176,27 +1175,6 @@ pub const Target = struct { |
| 1176 | 1175 | return self.abi.isMusl(); |
| 1177 | 1176 | } |
| 1178 | 1177 | |
| 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 | 1178 | pub fn isAndroid(self: Target) bool { |
| 1201 | 1179 | return switch (self.abi) { |
| 1202 | 1180 | .android => true, |
| ... | ... | @@ -1204,36 +1182,12 @@ pub const Target = struct { |
| 1204 | 1182 | }; |
| 1205 | 1183 | } |
| 1206 | 1184 | |
| 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 | 1185 | pub fn isWasm(self: Target) bool { |
| 1222 | 1186 | return self.cpu.arch.isWasm(); |
| 1223 | 1187 | } |
| 1224 | 1188 | |
| 1225 | pub fn isFreeBSD(self: Target) bool { | |
| 1226 | return switch (self.os.tag) { | |
| 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 | }; | |
| 1189 | pub fn isDarwin(self: Target) bool { | |
| 1190 | return self.os.tag.isDarwin(); | |
| 1237 | 1191 | } |
| 1238 | 1192 | |
| 1239 | 1193 | pub fn isGnuLibC(self: Target) bool { |
| ... | ... | @@ -1241,11 +1195,11 @@ pub const Target = struct { |
| 1241 | 1195 | } |
| 1242 | 1196 | |
| 1243 | 1197 | pub fn wantSharedLibSymLinks(self: Target) bool { |
| 1244 | return !self.isWindows(); | |
| 1198 | return self.os.tag != .windows; | |
| 1245 | 1199 | } |
| 1246 | 1200 | |
| 1247 | 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 | } |
| 1250 | 1204 | |
| 1251 | 1205 | pub fn getArchPtrBitWidth(self: Target) u32 { |
| ... | ... | @@ -1309,7 +1263,7 @@ pub const Target = struct { |
| 1309 | 1263 | } |
| 1310 | 1264 | |
| 1311 | 1265 | pub fn supportsNewStackCall(self: Target) bool { |
| 1312 | return !self.isWasm(); | |
| 1266 | return !self.cpu.arch.isWasm(); | |
| 1313 | 1267 | } |
| 1314 | 1268 | |
| 1315 | 1269 | pub const Executor = union(enum) { |
| ... | ... | @@ -1321,8 +1275,6 @@ pub const Target = struct { |
| 1321 | 1275 | }; |
| 1322 | 1276 | |
| 1323 | 1277 | pub fn getExternalExecutor(self: Target) Executor { |
| 1324 | if (@as(@TagType(Target), self) == .Native) return .native; | |
| 1325 | ||
| 1326 | 1278 | // If the target OS matches the host OS, we can use QEMU to emulate a foreign architecture. |
| 1327 | 1279 | if (self.os.tag == builtin.os.tag) { |
| 1328 | 1280 | return switch (self.cpu.arch) { |
| ... | ... | @@ -1347,22 +1299,18 @@ pub const Target = struct { |
| 1347 | 1299 | }; |
| 1348 | 1300 | } |
| 1349 | 1301 | |
| 1350 | if (self.isWindows()) { | |
| 1351 | switch (self.getArchPtrBitWidth()) { | |
| 1302 | switch (self.os.tag) { | |
| 1303 | .windows => switch (self.getArchPtrBitWidth()) { | |
| 1352 | 1304 | 32 => return Executor{ .wine = "wine" }, |
| 1353 | 1305 | 64 => return Executor{ .wine = "wine64" }, |
| 1354 | 1306 | else => return .unavailable, |
| 1355 | } | |
| 1356 | } | |
| 1357 | ||
| 1358 | if (self.os == .wasi) { | |
| 1359 | switch (self.getArchPtrBitWidth()) { | |
| 1307 | }, | |
| 1308 | .wasi => switch (self.getArchPtrBitWidth()) { | |
| 1360 | 1309 | 32 => return Executor{ .wasmtime = "wasmtime" }, |
| 1361 | 1310 | else => return .unavailable, |
| 1362 | } | |
| 1311 | }, | |
| 1312 | else => return .unavailable, | |
| 1363 | 1313 | } |
| 1364 | ||
| 1365 | return .unavailable; | |
| 1366 | 1314 | } |
| 1367 | 1315 | |
| 1368 | 1316 | pub const FloatAbi = enum { |
| ... | ... | @@ -1566,12 +1514,12 @@ test "Target.parse" { |
| 1566 | 1514 | |
| 1567 | 1515 | std.testing.expect(target.cpu.arch == .aarch64); |
| 1568 | 1516 | std.testing.expect(target.os.tag == .linux); |
| 1569 | std.testing.expect(target.os.version_range.linux.min.major == 3); | |
| 1570 | std.testing.expect(target.os.version_range.linux.min.minor == 10); | |
| 1571 | std.testing.expect(target.os.version_range.linux.min.patch == 0); | |
| 1572 | std.testing.expect(target.os.version_range.linux.max.major == 4); | |
| 1573 | std.testing.expect(target.os.version_range.linux.max.minor == 4); | |
| 1574 | std.testing.expect(target.os.version_range.linux.max.patch == 1); | |
| 1517 | std.testing.expect(target.os.version_range.linux.range.min.major == 3); | |
| 1518 | std.testing.expect(target.os.version_range.linux.range.min.minor == 10); | |
| 1519 | std.testing.expect(target.os.version_range.linux.range.min.patch == 0); | |
| 1520 | std.testing.expect(target.os.version_range.linux.range.max.major == 4); | |
| 1521 | std.testing.expect(target.os.version_range.linux.range.max.minor == 4); | |
| 1522 | std.testing.expect(target.os.version_range.linux.range.max.patch == 1); | |
| 1575 | 1523 | std.testing.expect(target.os.version_range.linux.glibc.major == 2); |
| 1576 | 1524 | std.testing.expect(target.os.version_range.linux.glibc.minor == 27); |
| 1577 | 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 | 7 | const Batch = std.event.Batch; |
| 8 | 8 | |
| 9 | 9 | const is_darwin = Target.current.isDarwin(); |
| 10 | const is_windows = Target.current.isWindows(); | |
| 11 | const is_freebsd = Target.current.isFreeBSD(); | |
| 12 | const is_netbsd = Target.current.isNetBSD(); | |
| 13 | const is_linux = Target.current.isLinux(); | |
| 14 | const is_dragonfly = Target.current.isDragonFlyBSD(); | |
| 10 | const is_windows = Target.current.os.tag == .windows; | |
| 15 | 11 | const is_gnu = Target.current.isGnu(); |
| 16 | 12 | |
| 17 | 13 | usingnamespace @import("windows_sdk.zig"); |
| ... | ... | @@ -216,10 +212,10 @@ pub const LibCInstallation = struct { |
| 216 | 212 | var batch = Batch(FindError!void, 2, .auto_async).init(); |
| 217 | 213 | errdefer batch.wait() catch {}; |
| 218 | 214 | batch.add(&async self.findNativeIncludeDirPosix(args)); |
| 219 | if (is_freebsd or is_netbsd) { | |
| 220 | self.crt_dir = try std.mem.dupeZ(args.allocator, u8, "/usr/lib"); | |
| 221 | } else if (is_linux or is_dragonfly) { | |
| 222 | batch.add(&async self.findNativeCrtDirPosix(args)); | |
| 215 | switch (Target.current.os.tag) { | |
| 216 | .freebsd, .netbsd => self.crt_dir = try std.mem.dupeZ(args.allocator, u8, "/usr/lib"), | |
| 217 | .linux, .dragonfly => batch.add(&async self.findNativeCrtDirPosix(args)), | |
| 218 | else => {}, | |
| 223 | 219 | } |
| 224 | 220 | break :blk batch.wait(); |
| 225 | 221 | }; |
test/assemble_and_link.zig+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | const builtin = @import("builtin"); | |
| 1 | const std = @import("std"); | |
| 2 | 2 | const tests = @import("tests.zig"); |
| 3 | 3 | |
| 4 | 4 | pub 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 | 6 | cases.addAsm("hello world linux x86_64", |
| 7 | 7 | \\.text |
| 8 | 8 | \\.globl _start |
test/compile_errors.zig+5-6| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 3 | 2 | const Target = @import("std").Target; |
| 4 | 3 | |
| 5 | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| ... | ... | @@ -387,10 +386,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 387 | 386 | , &[_][]const u8{ |
| 388 | 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 | 390 | .Cross = .{ |
| 392 | 391 | .cpu = Target.Cpu.baseline(.wasm32), |
| 393 | .os = .wasi, | |
| 392 | .os = Target.Os.defaultVersionRange(.wasi), | |
| 394 | 393 | .abi = .none, |
| 395 | 394 | }, |
| 396 | 395 | }; |
| ... | ... | @@ -788,10 +787,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 788 | 787 | , &[_][]const u8{ |
| 789 | 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 | 791 | .Cross = .{ |
| 793 | 792 | .cpu = Target.Cpu.baseline(.x86_64), |
| 794 | .os = .linux, | |
| 793 | .os = Target.Os.defaultVersionRange(.linux), | |
| 795 | 794 | .abi = .gnu, |
| 796 | 795 | }, |
| 797 | 796 | }; |
| ... | ... | @@ -1453,7 +1452,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1453 | 1452 | "tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}'", |
| 1454 | 1453 | }); |
| 1455 | 1454 | |
| 1456 | if (builtin.os == builtin.Os.linux) { | |
| 1455 | if (Target.current.os.tag == .linux) { | |
| 1457 | 1456 | cases.addTest("implicit dependency on libc", |
| 1458 | 1457 | \\extern "c" fn exit(u8) void; |
| 1459 | 1458 | \\export fn entry() void { |
test/src/translate_c.zig+2-2| ... | ... | @@ -19,7 +19,7 @@ pub const TranslateCContext = struct { |
| 19 | 19 | sources: ArrayList(SourceFile), |
| 20 | 20 | expected_lines: ArrayList([]const u8), |
| 21 | 21 | allow_warnings: bool, |
| 22 | target: std.Target = .Native, | |
| 22 | target: build.Target = .Native, | |
| 23 | 23 | |
| 24 | 24 | const SourceFile = struct { |
| 25 | 25 | filename: []const u8, |
| ... | ... | @@ -75,7 +75,7 @@ pub const TranslateCContext = struct { |
| 75 | 75 | pub fn addWithTarget( |
| 76 | 76 | self: *TranslateCContext, |
| 77 | 77 | name: []const u8, |
| 78 | target: std.Target, | |
| 78 | target: build.Target, | |
| 79 | 79 | source: []const u8, |
| 80 | 80 | expected_lines: []const []const u8, |
| 81 | 81 | ) void { |
test/stack_traces.zig+38-39| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | 1 | const std = @import("std"); |
| 3 | 2 | const os = std.os; |
| 4 | 3 | const tests = @import("tests.zig"); |
| ... | ... | @@ -43,32 +42,32 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 43 | 42 | \\} |
| 44 | 43 | ; |
| 45 | 44 | |
| 46 | switch (builtin.os) { | |
| 45 | switch (builtin.os.tag) { | |
| 47 | 46 | .freebsd => { |
| 48 | 47 | cases.addCase( |
| 49 | 48 | "return", |
| 50 | 49 | source_return, |
| 51 | 50 | [_][]const u8{ |
| 52 | 51 | // debug |
| 53 | \\error: TheSkyIsFalling | |
| 52 | \\error: TheSkyIsFalling | |
| 54 | 53 | \\source.zig:4:5: [address] in main (test) |
| 55 | 54 | \\ return error.TheSkyIsFalling; |
| 56 | 55 | \\ ^ |
| 57 | 56 | \\ |
| 58 | 57 | , |
| 59 | 58 | // release-safe |
| 60 | \\error: TheSkyIsFalling | |
| 59 | \\error: TheSkyIsFalling | |
| 61 | 60 | \\source.zig:4:5: [address] in std.start.main (test) |
| 62 | 61 | \\ return error.TheSkyIsFalling; |
| 63 | 62 | \\ ^ |
| 64 | 63 | \\ |
| 65 | 64 | , |
| 66 | 65 | // release-fast |
| 67 | \\error: TheSkyIsFalling | |
| 66 | \\error: TheSkyIsFalling | |
| 68 | 67 | \\ |
| 69 | 68 | , |
| 70 | 69 | // release-small |
| 71 | \\error: TheSkyIsFalling | |
| 70 | \\error: TheSkyIsFalling | |
| 72 | 71 | \\ |
| 73 | 72 | }, |
| 74 | 73 | ); |
| ... | ... | @@ -77,7 +76,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 77 | 76 | source_try_return, |
| 78 | 77 | [_][]const u8{ |
| 79 | 78 | // debug |
| 80 | \\error: TheSkyIsFalling | |
| 79 | \\error: TheSkyIsFalling | |
| 81 | 80 | \\source.zig:4:5: [address] in foo (test) |
| 82 | 81 | \\ return error.TheSkyIsFalling; |
| 83 | 82 | \\ ^ |
| ... | ... | @@ -87,7 +86,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 87 | 86 | \\ |
| 88 | 87 | , |
| 89 | 88 | // release-safe |
| 90 | \\error: TheSkyIsFalling | |
| 89 | \\error: TheSkyIsFalling | |
| 91 | 90 | \\source.zig:4:5: [address] in std.start.main (test) |
| 92 | 91 | \\ return error.TheSkyIsFalling; |
| 93 | 92 | \\ ^ |
| ... | ... | @@ -97,11 +96,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 97 | 96 | \\ |
| 98 | 97 | , |
| 99 | 98 | // release-fast |
| 100 | \\error: TheSkyIsFalling | |
| 99 | \\error: TheSkyIsFalling | |
| 101 | 100 | \\ |
| 102 | 101 | , |
| 103 | 102 | // release-small |
| 104 | \\error: TheSkyIsFalling | |
| 103 | \\error: TheSkyIsFalling | |
| 105 | 104 | \\ |
| 106 | 105 | }, |
| 107 | 106 | ); |
| ... | ... | @@ -110,7 +109,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 110 | 109 | source_try_try_return_return, |
| 111 | 110 | [_][]const u8{ |
| 112 | 111 | // debug |
| 113 | \\error: TheSkyIsFalling | |
| 112 | \\error: TheSkyIsFalling | |
| 114 | 113 | \\source.zig:12:5: [address] in make_error (test) |
| 115 | 114 | \\ return error.TheSkyIsFalling; |
| 116 | 115 | \\ ^ |
| ... | ... | @@ -126,7 +125,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 126 | 125 | \\ |
| 127 | 126 | , |
| 128 | 127 | // release-safe |
| 129 | \\error: TheSkyIsFalling | |
| 128 | \\error: TheSkyIsFalling | |
| 130 | 129 | \\source.zig:12:5: [address] in std.start.main (test) |
| 131 | 130 | \\ return error.TheSkyIsFalling; |
| 132 | 131 | \\ ^ |
| ... | ... | @@ -142,11 +141,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 142 | 141 | \\ |
| 143 | 142 | , |
| 144 | 143 | // release-fast |
| 145 | \\error: TheSkyIsFalling | |
| 144 | \\error: TheSkyIsFalling | |
| 146 | 145 | \\ |
| 147 | 146 | , |
| 148 | 147 | // release-small |
| 149 | \\error: TheSkyIsFalling | |
| 148 | \\error: TheSkyIsFalling | |
| 150 | 149 | \\ |
| 151 | 150 | }, |
| 152 | 151 | ); |
| ... | ... | @@ -157,25 +156,25 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 157 | 156 | source_return, |
| 158 | 157 | [_][]const u8{ |
| 159 | 158 | // debug |
| 160 | \\error: TheSkyIsFalling | |
| 159 | \\error: TheSkyIsFalling | |
| 161 | 160 | \\source.zig:4:5: [address] in main (test) |
| 162 | 161 | \\ return error.TheSkyIsFalling; |
| 163 | 162 | \\ ^ |
| 164 | 163 | \\ |
| 165 | 164 | , |
| 166 | 165 | // release-safe |
| 167 | \\error: TheSkyIsFalling | |
| 166 | \\error: TheSkyIsFalling | |
| 168 | 167 | \\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test) |
| 169 | 168 | \\ return error.TheSkyIsFalling; |
| 170 | 169 | \\ ^ |
| 171 | 170 | \\ |
| 172 | 171 | , |
| 173 | 172 | // release-fast |
| 174 | \\error: TheSkyIsFalling | |
| 173 | \\error: TheSkyIsFalling | |
| 175 | 174 | \\ |
| 176 | 175 | , |
| 177 | 176 | // release-small |
| 178 | \\error: TheSkyIsFalling | |
| 177 | \\error: TheSkyIsFalling | |
| 179 | 178 | \\ |
| 180 | 179 | }, |
| 181 | 180 | ); |
| ... | ... | @@ -184,7 +183,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 184 | 183 | source_try_return, |
| 185 | 184 | [_][]const u8{ |
| 186 | 185 | // debug |
| 187 | \\error: TheSkyIsFalling | |
| 186 | \\error: TheSkyIsFalling | |
| 188 | 187 | \\source.zig:4:5: [address] in foo (test) |
| 189 | 188 | \\ return error.TheSkyIsFalling; |
| 190 | 189 | \\ ^ |
| ... | ... | @@ -194,7 +193,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 194 | 193 | \\ |
| 195 | 194 | , |
| 196 | 195 | // release-safe |
| 197 | \\error: TheSkyIsFalling | |
| 196 | \\error: TheSkyIsFalling | |
| 198 | 197 | \\source.zig:4:5: [address] in std.start.posixCallMainAndExit (test) |
| 199 | 198 | \\ return error.TheSkyIsFalling; |
| 200 | 199 | \\ ^ |
| ... | ... | @@ -204,11 +203,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 204 | 203 | \\ |
| 205 | 204 | , |
| 206 | 205 | // release-fast |
| 207 | \\error: TheSkyIsFalling | |
| 206 | \\error: TheSkyIsFalling | |
| 208 | 207 | \\ |
| 209 | 208 | , |
| 210 | 209 | // release-small |
| 211 | \\error: TheSkyIsFalling | |
| 210 | \\error: TheSkyIsFalling | |
| 212 | 211 | \\ |
| 213 | 212 | }, |
| 214 | 213 | ); |
| ... | ... | @@ -217,7 +216,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 217 | 216 | source_try_try_return_return, |
| 218 | 217 | [_][]const u8{ |
| 219 | 218 | // debug |
| 220 | \\error: TheSkyIsFalling | |
| 219 | \\error: TheSkyIsFalling | |
| 221 | 220 | \\source.zig:12:5: [address] in make_error (test) |
| 222 | 221 | \\ return error.TheSkyIsFalling; |
| 223 | 222 | \\ ^ |
| ... | ... | @@ -233,7 +232,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 233 | 232 | \\ |
| 234 | 233 | , |
| 235 | 234 | // release-safe |
| 236 | \\error: TheSkyIsFalling | |
| 235 | \\error: TheSkyIsFalling | |
| 237 | 236 | \\source.zig:12:5: [address] in std.start.posixCallMainAndExit (test) |
| 238 | 237 | \\ return error.TheSkyIsFalling; |
| 239 | 238 | \\ ^ |
| ... | ... | @@ -249,11 +248,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 249 | 248 | \\ |
| 250 | 249 | , |
| 251 | 250 | // release-fast |
| 252 | \\error: TheSkyIsFalling | |
| 251 | \\error: TheSkyIsFalling | |
| 253 | 252 | \\ |
| 254 | 253 | , |
| 255 | 254 | // release-small |
| 256 | \\error: TheSkyIsFalling | |
| 255 | \\error: TheSkyIsFalling | |
| 257 | 256 | \\ |
| 258 | 257 | }, |
| 259 | 258 | ); |
| ... | ... | @@ -278,11 +277,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 278 | 277 | \\ |
| 279 | 278 | , |
| 280 | 279 | // release-fast |
| 281 | \\error: TheSkyIsFalling | |
| 280 | \\error: TheSkyIsFalling | |
| 282 | 281 | \\ |
| 283 | 282 | , |
| 284 | 283 | // release-small |
| 285 | \\error: TheSkyIsFalling | |
| 284 | \\error: TheSkyIsFalling | |
| 286 | 285 | \\ |
| 287 | 286 | }, |
| 288 | 287 | ); |
| ... | ... | @@ -311,11 +310,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 311 | 310 | \\ |
| 312 | 311 | , |
| 313 | 312 | // release-fast |
| 314 | \\error: TheSkyIsFalling | |
| 313 | \\error: TheSkyIsFalling | |
| 315 | 314 | \\ |
| 316 | 315 | , |
| 317 | 316 | // release-small |
| 318 | \\error: TheSkyIsFalling | |
| 317 | \\error: TheSkyIsFalling | |
| 319 | 318 | \\ |
| 320 | 319 | }, |
| 321 | 320 | ); |
| ... | ... | @@ -356,11 +355,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 356 | 355 | \\ |
| 357 | 356 | , |
| 358 | 357 | // release-fast |
| 359 | \\error: TheSkyIsFalling | |
| 358 | \\error: TheSkyIsFalling | |
| 360 | 359 | \\ |
| 361 | 360 | , |
| 362 | 361 | // release-small |
| 363 | \\error: TheSkyIsFalling | |
| 362 | \\error: TheSkyIsFalling | |
| 364 | 363 | \\ |
| 365 | 364 | }, |
| 366 | 365 | ); |
| ... | ... | @@ -371,7 +370,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 371 | 370 | source_return, |
| 372 | 371 | [_][]const u8{ |
| 373 | 372 | // debug |
| 374 | \\error: TheSkyIsFalling | |
| 373 | \\error: TheSkyIsFalling | |
| 375 | 374 | \\source.zig:4:5: [address] in main (test.obj) |
| 376 | 375 | \\ return error.TheSkyIsFalling; |
| 377 | 376 | \\ ^ |
| ... | ... | @@ -381,11 +380,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 381 | 380 | // --disabled-- results in segmenetation fault |
| 382 | 381 | "", |
| 383 | 382 | // release-fast |
| 384 | \\error: TheSkyIsFalling | |
| 383 | \\error: TheSkyIsFalling | |
| 385 | 384 | \\ |
| 386 | 385 | , |
| 387 | 386 | // release-small |
| 388 | \\error: TheSkyIsFalling | |
| 387 | \\error: TheSkyIsFalling | |
| 389 | 388 | \\ |
| 390 | 389 | }, |
| 391 | 390 | ); |
| ... | ... | @@ -407,11 +406,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 407 | 406 | // --disabled-- results in segmenetation fault |
| 408 | 407 | "", |
| 409 | 408 | // release-fast |
| 410 | \\error: TheSkyIsFalling | |
| 409 | \\error: TheSkyIsFalling | |
| 411 | 410 | \\ |
| 412 | 411 | , |
| 413 | 412 | // release-small |
| 414 | \\error: TheSkyIsFalling | |
| 413 | \\error: TheSkyIsFalling | |
| 415 | 414 | \\ |
| 416 | 415 | }, |
| 417 | 416 | ); |
| ... | ... | @@ -439,11 +438,11 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 439 | 438 | // --disabled-- results in segmenetation fault |
| 440 | 439 | "", |
| 441 | 440 | // release-fast |
| 442 | \\error: TheSkyIsFalling | |
| 441 | \\error: TheSkyIsFalling | |
| 443 | 442 | \\ |
| 444 | 443 | , |
| 445 | 444 | // release-small |
| 446 | \\error: TheSkyIsFalling | |
| 445 | \\error: TheSkyIsFalling | |
| 447 | 446 | \\ |
| 448 | 447 | }, |
| 449 | 448 | ); |
test/stage1/behavior/math.zig+10-10| ... | ... | @@ -529,7 +529,7 @@ test "comptime_int xor" { |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | test "f128" { |
| 532 | if (std.Target.current.isWindows()) { | |
| 532 | if (std.Target.current.os.tag == .windows) { | |
| 533 | 533 | // TODO https://github.com/ziglang/zig/issues/508 |
| 534 | 534 | return error.SkipZigTest; |
| 535 | 535 | } |
| ... | ... | @@ -631,7 +631,7 @@ test "NaN comparison" { |
| 631 | 631 | // TODO: https://github.com/ziglang/zig/issues/3338 |
| 632 | 632 | return error.SkipZigTest; |
| 633 | 633 | } |
| 634 | if (std.Target.current.isWindows()) { | |
| 634 | if (std.Target.current.os.tag == .windows) { | |
| 635 | 635 | // TODO https://github.com/ziglang/zig/issues/508 |
| 636 | 636 | return error.SkipZigTest; |
| 637 | 637 | } |
| ... | ... | @@ -666,14 +666,14 @@ test "128-bit multiplication" { |
| 666 | 666 | test "vector comparison" { |
| 667 | 667 | const S = struct { |
| 668 | 668 | fn doTheTest() void { |
| 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}; | |
| 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})); | |
| 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})); | |
| 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})); | |
| 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 }; | |
| 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 })); | |
| 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 })); | |
| 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 })); | |
| 677 | 677 | } |
| 678 | 678 | }; |
| 679 | 679 | S.doTheTest(); |
test/standalone.zig+2-2| ... | ... | @@ -18,10 +18,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void { |
| 18 | 18 | cases.addBuildFile("test/standalone/use_alias/build.zig"); |
| 19 | 19 | cases.addBuildFile("test/standalone/brace_expansion/build.zig"); |
| 20 | 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 | 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 architectures | |
| 24 | if (std.Target.current.cpu.arch == .x86_64) { // TODO add C ABI support for other architectures | |
| 25 | 25 | cases.addBuildFile("test/stage1/c_abi/build.zig"); |
| 26 | 26 | } |
| 27 | 27 | } |
test/tests.zig+65-62| ... | ... | @@ -1,16 +1,15 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 2 | 3 | const debug = std.debug; |
| 3 | 4 | const warn = debug.warn; |
| 4 | 5 | const build = std.build; |
| 5 | 6 | pub const Target = build.Target; |
| 6 | pub const CrossTarget = build.CrossTarget; | |
| 7 | 7 | const Buffer = std.Buffer; |
| 8 | 8 | const io = std.io; |
| 9 | 9 | const fs = std.fs; |
| 10 | 10 | const mem = std.mem; |
| 11 | 11 | const fmt = std.fmt; |
| 12 | 12 | const ArrayList = std.ArrayList; |
| 13 | const builtin = @import("builtin"); | |
| 14 | 13 | const Mode = builtin.Mode; |
| 15 | 14 | const LibExeObjStep = build.LibExeObjStep; |
| 16 | 15 | |
| ... | ... | @@ -54,18 +53,18 @@ const test_targets = blk: { |
| 54 | 53 | |
| 55 | 54 | TestTarget{ |
| 56 | 55 | .target = Target{ |
| 57 | .Cross = CrossTarget{ | |
| 58 | .cpu = Target.Cpu.baseline(.x86_64), | |
| 59 | .os = Target.Os.defaultVersionRange(.linux), | |
| 56 | .Cross = .{ | |
| 57 | .cpu = std.Target.Cpu.baseline(.x86_64), | |
| 58 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 60 | 59 | .abi = .none, |
| 61 | 60 | }, |
| 62 | 61 | }, |
| 63 | 62 | }, |
| 64 | 63 | TestTarget{ |
| 65 | 64 | .target = Target{ |
| 66 | .Cross = CrossTarget{ | |
| 67 | .cpu = Target.Cpu.baseline(.x86_64), | |
| 68 | .os = Target.Os.defaultVersionRange(.linux), | |
| 65 | .Cross = .{ | |
| 66 | .cpu = std.Target.Cpu.baseline(.x86_64), | |
| 67 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 69 | 68 | .abi = .gnu, |
| 70 | 69 | }, |
| 71 | 70 | }, |
| ... | ... | @@ -73,9 +72,9 @@ const test_targets = blk: { |
| 73 | 72 | }, |
| 74 | 73 | TestTarget{ |
| 75 | 74 | .target = Target{ |
| 76 | .Cross = CrossTarget{ | |
| 77 | .cpu = Target.Cpu.baseline(.x86_64), | |
| 78 | .os = Target.Os.defaultVersionRange(.linux), | |
| 75 | .Cross = .{ | |
| 76 | .cpu = std.Target.Cpu.baseline(.x86_64), | |
| 77 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 79 | 78 | .abi = .musl, |
| 80 | 79 | }, |
| 81 | 80 | }, |
| ... | ... | @@ -84,18 +83,18 @@ const test_targets = blk: { |
| 84 | 83 | |
| 85 | 84 | TestTarget{ |
| 86 | 85 | .target = Target{ |
| 87 | .Cross = CrossTarget{ | |
| 88 | .cpu = Target.Cpu.baseline(.i386), | |
| 89 | .os = Target.Os.defaultVersionRange(.linux), | |
| 86 | .Cross = .{ | |
| 87 | .cpu = std.Target.Cpu.baseline(.i386), | |
| 88 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 90 | 89 | .abi = .none, |
| 91 | 90 | }, |
| 92 | 91 | }, |
| 93 | 92 | }, |
| 94 | 93 | TestTarget{ |
| 95 | 94 | .target = Target{ |
| 96 | .Cross = CrossTarget{ | |
| 97 | .cpu = Target.Cpu.baseline(.i386), | |
| 98 | .os = Target.Os.defaultVersionRange(.linux), | |
| 95 | .Cross = .{ | |
| 96 | .cpu = std.Target.Cpu.baseline(.i386), | |
| 97 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 99 | 98 | .abi = .musl, |
| 100 | 99 | }, |
| 101 | 100 | }, |
| ... | ... | @@ -104,18 +103,18 @@ const test_targets = blk: { |
| 104 | 103 | |
| 105 | 104 | TestTarget{ |
| 106 | 105 | .target = Target{ |
| 107 | .Cross = CrossTarget{ | |
| 108 | .cpu = Target.Cpu.baseline(.aarch64), | |
| 109 | .os = Target.Os.defaultVersionRange(.linux), | |
| 106 | .Cross = .{ | |
| 107 | .cpu = std.Target.Cpu.baseline(.aarch64), | |
| 108 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 110 | 109 | .abi = .none, |
| 111 | 110 | }, |
| 112 | 111 | }, |
| 113 | 112 | }, |
| 114 | 113 | TestTarget{ |
| 115 | 114 | .target = Target{ |
| 116 | .Cross = CrossTarget{ | |
| 117 | .cpu = Target.Cpu.baseline(.aarch64), | |
| 118 | .os = Target.Os.defaultVersionRange(.linux), | |
| 115 | .Cross = .{ | |
| 116 | .cpu = std.Target.Cpu.baseline(.aarch64), | |
| 117 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 119 | 118 | .abi = .musl, |
| 120 | 119 | }, |
| 121 | 120 | }, |
| ... | ... | @@ -123,9 +122,9 @@ const test_targets = blk: { |
| 123 | 122 | }, |
| 124 | 123 | TestTarget{ |
| 125 | 124 | .target = Target{ |
| 126 | .Cross = CrossTarget{ | |
| 127 | .cpu = Target.Cpu.baseline(.aarch64), | |
| 128 | .os = Target.Os.defaultVersionRange(.linux), | |
| 125 | .Cross = .{ | |
| 126 | .cpu = std.Target.Cpu.baseline(.aarch64), | |
| 127 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 129 | 128 | .abi = .gnu, |
| 130 | 129 | }, |
| 131 | 130 | }, |
| ... | ... | @@ -133,21 +132,25 @@ const test_targets = blk: { |
| 133 | 132 | }, |
| 134 | 133 | |
| 135 | 134 | TestTarget{ |
| 136 | .target = Target.parse(.{ | |
| 137 | .arch_os_abi = "arm-linux-none", | |
| 138 | .cpu_features = "generic+v8a", | |
| 139 | }) catch unreachable, | |
| 135 | .target = .{ | |
| 136 | .Cross = std.Target.parse(.{ | |
| 137 | .arch_os_abi = "arm-linux-none", | |
| 138 | .cpu_features = "generic+v8a", | |
| 139 | }) catch unreachable, | |
| 140 | }, | |
| 140 | 141 | }, |
| 141 | 142 | TestTarget{ |
| 142 | .target = Target.parse(.{ | |
| 143 | .arch_os_abi = "arm-linux-musleabihf", | |
| 144 | .cpu_features = "generic+v8a", | |
| 145 | }) catch unreachable, | |
| 143 | .target = .{ | |
| 144 | .Cross = std.Target.parse(.{ | |
| 145 | .arch_os_abi = "arm-linux-musleabihf", | |
| 146 | .cpu_features = "generic+v8a", | |
| 147 | }) catch unreachable, | |
| 148 | }, | |
| 146 | 149 | .link_libc = true, |
| 147 | 150 | }, |
| 148 | 151 | // TODO https://github.com/ziglang/zig/issues/3287 |
| 149 | 152 | //TestTarget{ |
| 150 | // .target = Target.parse(.{ | |
| 153 | // .target = std.Target.parse(.{ | |
| 151 | 154 | // .arch_os_abi = "arm-linux-gnueabihf", |
| 152 | 155 | // .cpu_features = "generic+v8a", |
| 153 | 156 | // }) catch unreachable, |
| ... | ... | @@ -156,18 +159,18 @@ const test_targets = blk: { |
| 156 | 159 | |
| 157 | 160 | TestTarget{ |
| 158 | 161 | .target = Target{ |
| 159 | .Cross = CrossTarget{ | |
| 160 | .cpu = Target.Cpu.baseline(.mipsel), | |
| 161 | .os = Target.Os.defaultVersionRange(.linux), | |
| 162 | .Cross = .{ | |
| 163 | .cpu = std.Target.Cpu.baseline(.mipsel), | |
| 164 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 162 | 165 | .abi = .none, |
| 163 | 166 | }, |
| 164 | 167 | }, |
| 165 | 168 | }, |
| 166 | 169 | TestTarget{ |
| 167 | 170 | .target = Target{ |
| 168 | .Cross = CrossTarget{ | |
| 169 | .cpu = Target.Cpu.baseline(.mipsel), | |
| 170 | .os = Target.Os.defaultVersionRange(.linux), | |
| 171 | .Cross = .{ | |
| 172 | .cpu = std.Target.Cpu.baseline(.mipsel), | |
| 173 | .os = std.Target.Os.defaultVersionRange(.linux), | |
| 171 | 174 | .abi = .musl, |
| 172 | 175 | }, |
| 173 | 176 | }, |
| ... | ... | @@ -176,9 +179,9 @@ const test_targets = blk: { |
| 176 | 179 | |
| 177 | 180 | TestTarget{ |
| 178 | 181 | .target = Target{ |
| 179 | .Cross = CrossTarget{ | |
| 180 | .cpu = Target.Cpu.baseline(.x86_64), | |
| 181 | .os = Target.Os.defaultVersionRange(.macosx), | |
| 182 | .Cross = .{ | |
| 183 | .cpu = std.Target.Cpu.baseline(.x86_64), | |
| 184 | .os = std.Target.Os.defaultVersionRange(.macosx), | |
| 182 | 185 | .abi = .gnu, |
| 183 | 186 | }, |
| 184 | 187 | }, |
| ... | ... | @@ -188,9 +191,9 @@ const test_targets = blk: { |
| 188 | 191 | |
| 189 | 192 | TestTarget{ |
| 190 | 193 | .target = Target{ |
| 191 | .Cross = CrossTarget{ | |
| 192 | .cpu = Target.Cpu.baseline(.i386), | |
| 193 | .os = Target.Os.defaultVersionRange(.windows), | |
| 194 | .Cross = .{ | |
| 195 | .cpu = std.Target.Cpu.baseline(.i386), | |
| 196 | .os = std.Target.Os.defaultVersionRange(.windows), | |
| 194 | 197 | .abi = .msvc, |
| 195 | 198 | }, |
| 196 | 199 | }, |
| ... | ... | @@ -198,9 +201,9 @@ const test_targets = blk: { |
| 198 | 201 | |
| 199 | 202 | TestTarget{ |
| 200 | 203 | .target = Target{ |
| 201 | .Cross = CrossTarget{ | |
| 202 | .cpu = Target.Cpu.baseline(.x86_64), | |
| 203 | .os = Target.Os.defaultVersionRange(.windows), | |
| 204 | .Cross = .{ | |
| 205 | .cpu = std.Target.Cpu.baseline(.x86_64), | |
| 206 | .os = std.Target.Os.defaultVersionRange(.windows), | |
| 204 | 207 | .abi = .msvc, |
| 205 | 208 | }, |
| 206 | 209 | }, |
| ... | ... | @@ -208,9 +211,9 @@ const test_targets = blk: { |
| 208 | 211 | |
| 209 | 212 | TestTarget{ |
| 210 | 213 | .target = Target{ |
| 211 | .Cross = CrossTarget{ | |
| 212 | .cpu = Target.Cpu.baseline(.i386), | |
| 213 | .os = Target.Os.defaultVersionRange(.windows), | |
| 214 | .Cross = .{ | |
| 215 | .cpu = std.Target.Cpu.baseline(.i386), | |
| 216 | .os = std.Target.Os.defaultVersionRange(.windows), | |
| 214 | 217 | .abi = .gnu, |
| 215 | 218 | }, |
| 216 | 219 | }, |
| ... | ... | @@ -219,9 +222,9 @@ const test_targets = blk: { |
| 219 | 222 | |
| 220 | 223 | TestTarget{ |
| 221 | 224 | .target = Target{ |
| 222 | .Cross = CrossTarget{ | |
| 223 | .cpu = Target.Cpu.baseline(.x86_64), | |
| 224 | .os = Target.Os.defaultVersionRange(.windows), | |
| 225 | .Cross = .{ | |
| 226 | .cpu = std.Target.Cpu.baseline(.x86_64), | |
| 227 | .os = std.Target.Os.defaultVersionRange(.windows), | |
| 225 | 228 | .abi = .gnu, |
| 226 | 229 | }, |
| 227 | 230 | }, |
| ... | ... | @@ -438,7 +441,7 @@ pub fn addPkgTests( |
| 438 | 441 | if (skip_libc and test_target.link_libc) |
| 439 | 442 | continue; |
| 440 | 443 | |
| 441 | if (test_target.link_libc and test_target.target.osRequiresLibC()) { | |
| 444 | if (test_target.link_libc and test_target.target.getTarget().osRequiresLibC()) { | |
| 442 | 445 | // This would be a redundant test. |
| 443 | 446 | continue; |
| 444 | 447 | } |
| ... | ... | @@ -448,8 +451,8 @@ pub fn addPkgTests( |
| 448 | 451 | |
| 449 | 452 | const ArchTag = @TagType(builtin.Arch); |
| 450 | 453 | if (test_target.disable_native and |
| 451 | test_target.target.getOs() == builtin.os and | |
| 452 | test_target.target.getArch() == builtin.arch) | |
| 454 | test_target.target.getOs() == std.Target.current.os.tag and | |
| 455 | test_target.target.getArch() == std.Target.current.cpu.arch) | |
| 453 | 456 | { |
| 454 | 457 | continue; |
| 455 | 458 | } |
| ... | ... | @@ -459,7 +462,7 @@ pub fn addPkgTests( |
| 459 | 462 | } else false; |
| 460 | 463 | if (!want_this_mode) continue; |
| 461 | 464 | |
| 462 | const libc_prefix = if (test_target.target.osRequiresLibC()) | |
| 465 | const libc_prefix = if (test_target.target.getTarget().osRequiresLibC()) | |
| 463 | 466 | "" |
| 464 | 467 | else if (test_target.link_libc) |
| 465 | 468 | "c" |
| ... | ... | @@ -469,7 +472,7 @@ pub fn addPkgTests( |
| 469 | 472 | const triple_prefix = if (test_target.target == .Native) |
| 470 | 473 | @as([]const u8, "native") |
| 471 | 474 | else |
| 472 | test_target.target.zigTripleNoSubArch(b.allocator) catch unreachable; | |
| 475 | test_target.target.zigTriple(b.allocator) catch unreachable; | |
| 473 | 476 | |
| 474 | 477 | const these_tests = b.addTest(root_src); |
| 475 | 478 | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; |
| ... | ... | @@ -660,7 +663,7 @@ pub const StackTracesContext = struct { |
| 660 | 663 | const delims = [_][]const u8{ ":", ":", ":", " in " }; |
| 661 | 664 | var marks = [_]usize{0} ** 4; |
| 662 | 665 | // 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 | 667 | for (delims) |delim, i| { |
| 665 | 668 | marks[i] = mem.indexOfPos(u8, line, pos, delim) orelse { |
| 666 | 669 | try buf.append(line); |
test/translate_c.zig+19-15| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 3 | const Target = @import("std").Target; | |
| 2 | const std = @import("std"); | |
| 3 | const Target = std.Target; | |
| 4 | 4 | |
| 5 | 5 | pub fn addCases(cases: *tests.TranslateCContext) void { |
| 6 | 6 | cases.add("macro line continuation", |
| ... | ... | @@ -665,7 +665,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 665 | 665 | \\} |
| 666 | 666 | }); |
| 667 | 667 | |
| 668 | if (builtin.os != builtin.Os.windows) { | |
| 668 | if (Target.current.os.tag != .windows) { | |
| 669 | 669 | // Windows treats this as an enum with type c_int |
| 670 | 670 | cases.add("big negative enum init values when C ABI supports long long enums", |
| 671 | 671 | \\enum EnumWithInits { |
| ... | ... | @@ -1064,7 +1064,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1064 | 1064 | \\} |
| 1065 | 1065 | }); |
| 1066 | 1066 | |
| 1067 | if (builtin.os != builtin.Os.windows) { | |
| 1067 | if (Target.current.os.tag != .windows) { | |
| 1068 | 1068 | // sysv_abi not currently supported on windows |
| 1069 | 1069 | cases.add("Macro qualified functions", |
| 1070 | 1070 | \\void __attribute__((sysv_abi)) foo(void); |
| ... | ... | @@ -1093,10 +1093,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1093 | 1093 | \\pub const fn1 = ?fn (u8) callconv(.C) void; |
| 1094 | 1094 | }); |
| 1095 | 1095 | |
| 1096 | cases.addWithTarget("Calling convention", tests.Target{ | |
| 1096 | cases.addWithTarget("Calling convention", .{ | |
| 1097 | 1097 | .Cross = .{ |
| 1098 | 1098 | .cpu = Target.Cpu.baseline(.i386), |
| 1099 | .os = .linux, | |
| 1099 | .os = Target.Os.defaultVersionRange(.linux), | |
| 1100 | 1100 | .abi = .none, |
| 1101 | 1101 | }, |
| 1102 | 1102 | }, |
| ... | ... | @@ -1113,10 +1113,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1113 | 1113 | \\pub fn foo5(a: [*c]f32) callconv(.Thiscall) void; |
| 1114 | 1114 | }); |
| 1115 | 1115 | |
| 1116 | cases.addWithTarget("Calling convention", Target.parse(.{ | |
| 1117 | .arch_os_abi = "arm-linux-none", | |
| 1118 | .cpu_features = "generic+v8_5a", | |
| 1119 | }) catch unreachable, | |
| 1116 | cases.addWithTarget("Calling convention", .{ | |
| 1117 | .Cross = Target.parse(.{ | |
| 1118 | .arch_os_abi = "arm-linux-none", | |
| 1119 | .cpu_features = "generic+v8_5a", | |
| 1120 | }) catch unreachable, | |
| 1121 | }, | |
| 1120 | 1122 | \\void __attribute__((pcs("aapcs"))) foo1(float *a); |
| 1121 | 1123 | \\void __attribute__((pcs("aapcs-vfp"))) foo2(float *a); |
| 1122 | 1124 | , &[_][]const u8{ |
| ... | ... | @@ -1124,10 +1126,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1124 | 1126 | \\pub fn foo2(a: [*c]f32) callconv(.AAPCSVFP) void; |
| 1125 | 1127 | }); |
| 1126 | 1128 | |
| 1127 | cases.addWithTarget("Calling convention", Target.parse(.{ | |
| 1128 | .arch_os_abi = "aarch64-linux-none", | |
| 1129 | .cpu_features = "generic+v8_5a", | |
| 1130 | }) catch unreachable, | |
| 1129 | cases.addWithTarget("Calling convention", .{ | |
| 1130 | .Cross = Target.parse(.{ | |
| 1131 | .arch_os_abi = "aarch64-linux-none", | |
| 1132 | .cpu_features = "generic+v8_5a", | |
| 1133 | }) catch unreachable, | |
| 1134 | }, | |
| 1131 | 1135 | \\void __attribute__((aarch64_vector_pcs)) foo1(float *a); |
| 1132 | 1136 | , &[_][]const u8{ |
| 1133 | 1137 | \\pub fn foo1(a: [*c]f32) callconv(.Vectorcall) void; |
| ... | ... | @@ -1596,7 +1600,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1596 | 1600 | \\} |
| 1597 | 1601 | }); |
| 1598 | 1602 | |
| 1599 | if (builtin.os != .windows) { | |
| 1603 | if (Target.current.os.tag != .windows) { | |
| 1600 | 1604 | // When clang uses the <arch>-windows-none triple it behaves as MSVC and |
| 1601 | 1605 | // interprets the inner `struct Bar` as an anonymous structure |
| 1602 | 1606 | cases.add("type referenced struct", |