| ... | ... | @@ -22,12 +22,12 @@ pub const CompareOutputContext = @import("src/CompareOutput.zig"); |
| 22 | 22 | pub const StackTracesContext = @import("src/StackTrace.zig"); |
| 23 | 23 | |
| 24 | 24 | const TestTarget = struct { |
| 25 | | target: CrossTarget = @as(CrossTarget, .{}), |
| 25 | target: CrossTarget = .{}, |
| 26 | 26 | optimize_mode: std.builtin.OptimizeMode = .Debug, |
| 27 | | link_libc: bool = false, |
| 28 | | single_threaded: bool = false, |
| 29 | | disable_native: bool = false, |
| 30 | | backend: ?std.builtin.CompilerBackend = null, |
| 27 | link_libc: ?bool = null, |
| 28 | single_threaded: ?bool = null, |
| 29 | use_llvm: ?bool = null, |
| 30 | use_lld: ?bool = null, |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | 33 | const test_targets = blk: { |
| ... | ... | @@ -43,13 +43,47 @@ const test_targets = blk: { |
| 43 | 43 | .{ |
| 44 | 44 | .single_threaded = true, |
| 45 | 45 | }, |
| 46 | .{ |
| 47 | .optimize_mode = .ReleaseFast, |
| 48 | }, |
| 49 | .{ |
| 50 | .link_libc = true, |
| 51 | .optimize_mode = .ReleaseFast, |
| 52 | }, |
| 53 | .{ |
| 54 | .optimize_mode = .ReleaseFast, |
| 55 | .single_threaded = true, |
| 56 | }, |
| 57 | |
| 58 | .{ |
| 59 | .optimize_mode = .ReleaseSafe, |
| 60 | }, |
| 61 | .{ |
| 62 | .link_libc = true, |
| 63 | .optimize_mode = .ReleaseSafe, |
| 64 | }, |
| 65 | .{ |
| 66 | .optimize_mode = .ReleaseSafe, |
| 67 | .single_threaded = true, |
| 68 | }, |
| 69 | |
| 70 | .{ |
| 71 | .optimize_mode = .ReleaseSmall, |
| 72 | }, |
| 73 | .{ |
| 74 | .link_libc = true, |
| 75 | .optimize_mode = .ReleaseSmall, |
| 76 | }, |
| 77 | .{ |
| 78 | .optimize_mode = .ReleaseSmall, |
| 79 | .single_threaded = true, |
| 80 | }, |
| 46 | 81 | |
| 47 | 82 | .{ |
| 48 | 83 | .target = .{ |
| 49 | 84 | .ofmt = .c, |
| 50 | 85 | }, |
| 51 | 86 | .link_libc = true, |
| 52 | | .backend = .stage2_c, |
| 53 | 87 | }, |
| 54 | 88 | .{ |
| 55 | 89 | .target = .{ |
| ... | ... | @@ -57,22 +91,24 @@ const test_targets = blk: { |
| 57 | 91 | .os_tag = .linux, |
| 58 | 92 | .abi = .none, |
| 59 | 93 | }, |
| 60 | | .backend = .stage2_x86_64, |
| 94 | .use_llvm = false, |
| 95 | .use_lld = false, |
| 61 | 96 | }, |
| 62 | 97 | .{ |
| 63 | 98 | .target = .{ |
| 64 | 99 | .cpu_arch = .aarch64, |
| 65 | 100 | .os_tag = .linux, |
| 66 | 101 | }, |
| 67 | | .backend = .stage2_aarch64, |
| 102 | .use_llvm = false, |
| 103 | .use_lld = false, |
| 68 | 104 | }, |
| 69 | 105 | .{ |
| 70 | 106 | .target = .{ |
| 71 | 107 | .cpu_arch = .wasm32, |
| 72 | 108 | .os_tag = .wasi, |
| 73 | 109 | }, |
| 74 | | .single_threaded = true, |
| 75 | | .backend = .stage2_wasm, |
| 110 | .use_llvm = false, |
| 111 | .use_lld = false, |
| 76 | 112 | }, |
| 77 | 113 | // https://github.com/ziglang/zig/issues/13623 |
| 78 | 114 | //.{ |
| ... | ... | @@ -80,7 +116,8 @@ const test_targets = blk: { |
| 80 | 116 | // .cpu_arch = .arm, |
| 81 | 117 | // .os_tag = .linux, |
| 82 | 118 | // }, |
| 83 | | // .backend = .stage2_arm, |
| 119 | // .use_llvm = false, |
| 120 | // .use_lld = false, |
| 84 | 121 | //}, |
| 85 | 122 | // https://github.com/ziglang/zig/issues/13623 |
| 86 | 123 | //.{ |
| ... | ... | @@ -88,7 +125,8 @@ const test_targets = blk: { |
| 88 | 125 | // .arch_os_abi = "arm-linux-none", |
| 89 | 126 | // .cpu_features = "generic+v8a", |
| 90 | 127 | // }) catch unreachable, |
| 91 | | // .backend = .stage2_arm, |
| 128 | // .use_llvm = false, |
| 129 | // .use_lld = false, |
| 92 | 130 | //}, |
| 93 | 131 | .{ |
| 94 | 132 | .target = .{ |
| ... | ... | @@ -96,7 +134,8 @@ const test_targets = blk: { |
| 96 | 134 | .os_tag = .macos, |
| 97 | 135 | .abi = .none, |
| 98 | 136 | }, |
| 99 | | .backend = .stage2_aarch64, |
| 137 | .use_llvm = false, |
| 138 | .use_lld = false, |
| 100 | 139 | }, |
| 101 | 140 | .{ |
| 102 | 141 | .target = .{ |
| ... | ... | @@ -104,7 +143,8 @@ const test_targets = blk: { |
| 104 | 143 | .os_tag = .macos, |
| 105 | 144 | .abi = .none, |
| 106 | 145 | }, |
| 107 | | .backend = .stage2_x86_64, |
| 146 | .use_llvm = false, |
| 147 | .use_lld = false, |
| 108 | 148 | }, |
| 109 | 149 | .{ |
| 110 | 150 | .target = .{ |
| ... | ... | @@ -112,7 +152,8 @@ const test_targets = blk: { |
| 112 | 152 | .os_tag = .windows, |
| 113 | 153 | .abi = .gnu, |
| 114 | 154 | }, |
| 115 | | .backend = .stage2_x86_64, |
| 155 | .use_llvm = false, |
| 156 | .use_lld = false, |
| 116 | 157 | }, |
| 117 | 158 | |
| 118 | 159 | .{ |
| ... | ... | @@ -121,7 +162,6 @@ const test_targets = blk: { |
| 121 | 162 | .os_tag = .wasi, |
| 122 | 163 | }, |
| 123 | 164 | .link_libc = false, |
| 124 | | .single_threaded = true, |
| 125 | 165 | }, |
| 126 | 166 | .{ |
| 127 | 167 | .target = .{ |
| ... | ... | @@ -129,7 +169,6 @@ const test_targets = blk: { |
| 129 | 169 | .os_tag = .wasi, |
| 130 | 170 | }, |
| 131 | 171 | .link_libc = true, |
| 132 | | .single_threaded = true, |
| 133 | 172 | }, |
| 134 | 173 | |
| 135 | 174 | .{ |
| ... | ... | @@ -413,43 +452,6 @@ const test_targets = blk: { |
| 413 | 452 | }, |
| 414 | 453 | .link_libc = true, |
| 415 | 454 | }, |
| 416 | | |
| 417 | | // Do the release tests last because they take a long time |
| 418 | | .{ |
| 419 | | .optimize_mode = .ReleaseFast, |
| 420 | | }, |
| 421 | | .{ |
| 422 | | .link_libc = true, |
| 423 | | .optimize_mode = .ReleaseFast, |
| 424 | | }, |
| 425 | | .{ |
| 426 | | .optimize_mode = .ReleaseFast, |
| 427 | | .single_threaded = true, |
| 428 | | }, |
| 429 | | |
| 430 | | .{ |
| 431 | | .optimize_mode = .ReleaseSafe, |
| 432 | | }, |
| 433 | | .{ |
| 434 | | .link_libc = true, |
| 435 | | .optimize_mode = .ReleaseSafe, |
| 436 | | }, |
| 437 | | .{ |
| 438 | | .optimize_mode = .ReleaseSafe, |
| 439 | | .single_threaded = true, |
| 440 | | }, |
| 441 | | |
| 442 | | .{ |
| 443 | | .optimize_mode = .ReleaseSmall, |
| 444 | | }, |
| 445 | | .{ |
| 446 | | .link_libc = true, |
| 447 | | .optimize_mode = .ReleaseSmall, |
| 448 | | }, |
| 449 | | .{ |
| 450 | | .optimize_mode = .ReleaseSmall, |
| 451 | | .single_threaded = true, |
| 452 | | }, |
| 453 | 455 | }; |
| 454 | 456 | }; |
| 455 | 457 | |
| ... | ... | @@ -913,8 +915,6 @@ const ModuleTestOptions = struct { |
| 913 | 915 | skip_non_native: bool, |
| 914 | 916 | skip_cross_glibc: bool, |
| 915 | 917 | skip_libc: bool, |
| 916 | | skip_stage1: bool, |
| 917 | | skip_stage2: bool, |
| 918 | 918 | max_rss: usize = 0, |
| 919 | 919 | }; |
| 920 | 920 | |
| ... | ... | @@ -922,49 +922,41 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 922 | 922 | const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc); |
| 923 | 923 | |
| 924 | 924 | for (test_targets) |test_target| { |
| 925 | | if (options.skip_non_native and !test_target.target.isNative()) |
| 925 | const is_native = test_target.target.isNative() or |
| 926 | (test_target.target.getOsTag() == builtin.os.tag and |
| 927 | test_target.target.getCpuArch() == builtin.cpu.arch); |
| 928 | |
| 929 | if (options.skip_non_native and !is_native) |
| 926 | 930 | continue; |
| 927 | 931 | |
| 928 | | if (options.skip_cross_glibc and test_target.target.isGnuLibC() and test_target.link_libc) |
| 932 | if (options.skip_cross_glibc and test_target.target.isGnuLibC() and test_target.link_libc == true) |
| 929 | 933 | continue; |
| 930 | 934 | |
| 931 | | if (options.skip_libc and test_target.link_libc) |
| 935 | if (options.skip_libc and test_target.link_libc == true) |
| 932 | 936 | continue; |
| 933 | 937 | |
| 934 | | if (test_target.link_libc and test_target.target.getOs().requiresLibC()) { |
| 935 | | // This would be a redundant test. |
| 938 | if (options.skip_single_threaded and test_target.single_threaded == true) |
| 936 | 939 | continue; |
| 937 | | } |
| 938 | 940 | |
| 939 | | if (options.skip_single_threaded and test_target.single_threaded) |
| 941 | // TODO get compiler-rt tests passing for self-hosted backends. |
| 942 | if (test_target.use_llvm == false and mem.eql(u8, options.name, "compiler-rt")) |
| 940 | 943 | continue; |
| 941 | 944 | |
| 942 | | if (test_target.disable_native and |
| 943 | | test_target.target.getOsTag() == builtin.os.tag and |
| 944 | | test_target.target.getCpuArch() == builtin.cpu.arch) |
| 945 | | { |
| 945 | // TODO get universal-libc tests passing for self-hosted backends. |
| 946 | if (test_target.use_llvm == false and mem.eql(u8, options.name, "universal-libc")) |
| 946 | 947 | continue; |
| 947 | | } |
| 948 | 948 | |
| 949 | | if (test_target.backend) |backend| switch (backend) { |
| 950 | | .stage1 => if (options.skip_stage1) continue, |
| 951 | | .stage2_llvm => {}, |
| 952 | | else => if (options.skip_stage2) continue, |
| 953 | | }; |
| 949 | // TODO get std lib tests passing for self-hosted backends. |
| 950 | if (test_target.use_llvm == false and mem.eql(u8, options.name, "std")) |
| 951 | continue; |
| 954 | 952 | |
| 955 | 953 | const want_this_mode = for (options.optimize_modes) |m| { |
| 956 | 954 | if (m == test_target.optimize_mode) break true; |
| 957 | 955 | } else false; |
| 958 | 956 | if (!want_this_mode) continue; |
| 959 | 957 | |
| 960 | | const libc_prefix = if (test_target.target.getOs().requiresLibC()) |
| 961 | | "" |
| 962 | | else if (test_target.link_libc) |
| 963 | | "c" |
| 964 | | else |
| 965 | | "bare"; |
| 966 | | |
| 967 | | const triple_prefix = test_target.target.zigTriple(b.allocator) catch @panic("OOM"); |
| 958 | const libc_suffix = if (test_target.link_libc == true) "-libc" else ""; |
| 959 | const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM"); |
| 968 | 960 | |
| 969 | 961 | // wasm32-wasi builds need more RAM, idk why |
| 970 | 962 | const max_rss = if (test_target.target.getOs().tag == .wasi) |
| ... | ... | @@ -978,42 +970,33 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 978 | 970 | .target = test_target.target, |
| 979 | 971 | .max_rss = max_rss, |
| 980 | 972 | .filter = options.test_filter, |
| 973 | .link_libc = test_target.link_libc, |
| 974 | .single_threaded = test_target.single_threaded, |
| 975 | .use_llvm = test_target.use_llvm, |
| 976 | .use_lld = test_target.use_lld, |
| 981 | 977 | }); |
| 982 | | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; |
| 983 | | const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default"; |
| 984 | | these_tests.single_threaded = test_target.single_threaded; |
| 985 | | if (test_target.link_libc) { |
| 986 | | these_tests.linkSystemLibrary("c"); |
| 987 | | } |
| 978 | const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else ""; |
| 979 | const backend_suffix = if (test_target.use_llvm == true) |
| 980 | "-llvm" |
| 981 | else if (test_target.target.ofmt == std.Target.ObjectFormat.c) |
| 982 | "-cbe" |
| 983 | else if (test_target.use_llvm == false) |
| 984 | "-selfhosted" |
| 985 | else |
| 986 | ""; |
| 987 | |
| 988 | 988 | these_tests.overrideZigLibDir("lib"); |
| 989 | 989 | these_tests.addIncludePath("test"); |
| 990 | | if (test_target.backend) |backend| switch (backend) { |
| 991 | | .stage1 => { |
| 992 | | @panic("stage1 testing requested"); |
| 993 | | }, |
| 994 | | .stage2_llvm => { |
| 995 | | these_tests.use_llvm = true; |
| 996 | | }, |
| 997 | | .stage2_c => { |
| 998 | | these_tests.use_llvm = false; |
| 999 | | }, |
| 1000 | | else => { |
| 1001 | | these_tests.use_llvm = false; |
| 1002 | | // TODO: force self-hosted linkers to avoid LLD creeping in |
| 1003 | | // until the auto-select mechanism deems them worthy |
| 1004 | | these_tests.use_lld = false; |
| 1005 | | }, |
| 1006 | | }; |
| 1007 | 990 | |
| 1008 | 991 | const run = b.addRunArtifact(these_tests); |
| 1009 | 992 | run.skip_foreign_checks = true; |
| 1010 | | run.setName(b.fmt("run test {s}-{s}-{s}-{s}-{s}-{s}", .{ |
| 993 | run.setName(b.fmt("run test {s}-{s}-{s}{s}{s}{s}", .{ |
| 1011 | 994 | options.name, |
| 1012 | | triple_prefix, |
| 995 | triple_txt, |
| 1013 | 996 | @tagName(test_target.optimize_mode), |
| 1014 | | libc_prefix, |
| 1015 | | single_threaded_txt, |
| 1016 | | backend_txt, |
| 997 | libc_suffix, |
| 998 | single_threaded_suffix, |
| 999 | backend_suffix, |
| 1017 | 1000 | })); |
| 1018 | 1001 | |
| 1019 | 1002 | step.dependOn(&run.step); |