authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-16 12:43:35-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-04-16 12:43:35-07:00
logb0186f31002760c9940d8c06c2ac7baa9d52f404
tree25bb2c86739f6ee3d9cd8a9e5f77d046c4b12487
parent397649fb0934b75122e795bfb234d46693425d98
parent9e6647582da0d7cbf8a441cefea0bb9fae18bb5c
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #15277 from ziglang/tests

add CI test coverage for more target combinations

15 files changed, 359 insertions(+), 144 deletions(-)

build.zig+4-17
...@@ -85,9 +85,7 @@ pub fn build(b: *std.Build) !void {...@@ -85,9 +85,7 @@ pub fn build(b: *std.Build) !void {
85 const skip_cross_glibc = b.option(bool, "skip-cross-glibc", "Main test suite skips builds that require cross glibc") orelse false;85 const skip_cross_glibc = b.option(bool, "skip-cross-glibc", "Main test suite skips builds that require cross glibc") orelse false;
86 const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;86 const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
87 const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false;87 const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false;
88 const skip_stage1 = b.option(bool, "skip-stage1", "Main test suite skips stage1 compile error tests") orelse false;
89 const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse false;88 const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse false;
90 const skip_stage2_tests = b.option(bool, "skip-stage2-tests", "Main test suite skips self-hosted compiler tests") orelse false;
9189
92 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;90 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
9391
...@@ -187,9 +185,7 @@ pub fn build(b: *std.Build) !void {...@@ -187,9 +185,7 @@ pub fn build(b: *std.Build) !void {
187 const compile_step = b.step("compile", "Build the self-hosted compiler");185 const compile_step = b.step("compile", "Build the self-hosted compiler");
188 compile_step.dependOn(&exe.step);186 compile_step.dependOn(&exe.step);
189187
190 if (!skip_stage2_tests) {188 test_step.dependOn(&exe.step);
191 test_step.dependOn(&exe.step);
192 }
193189
194 exe.single_threaded = single_threaded;190 exe.single_threaded = single_threaded;
195191
...@@ -360,7 +356,6 @@ pub fn build(b: *std.Build) !void {...@@ -360,7 +356,6 @@ pub fn build(b: *std.Build) !void {
360 test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);356 test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
361 test_cases_options.addOption(bool, "skip_non_native", skip_non_native);357 test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
362 test_cases_options.addOption(bool, "skip_cross_glibc", skip_cross_glibc);358 test_cases_options.addOption(bool, "skip_cross_glibc", skip_cross_glibc);
363 test_cases_options.addOption(bool, "skip_stage1", skip_stage1);
364 test_cases_options.addOption(bool, "have_llvm", enable_llvm);359 test_cases_options.addOption(bool, "have_llvm", enable_llvm);
365 test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);360 test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
366 test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);361 test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
...@@ -416,7 +411,7 @@ pub fn build(b: *std.Build) !void {...@@ -416,7 +411,7 @@ pub fn build(b: *std.Build) !void {
416411
417 const test_cases_step = b.step("test-cases", "Run the main compiler test cases");412 const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
418 try tests.addCases(b, test_cases_step, test_filter, check_case_exe);413 try tests.addCases(b, test_cases_step, test_filter, check_case_exe);
419 if (!skip_stage2_tests) test_step.dependOn(test_cases_step);414 test_step.dependOn(test_cases_step);
420415
421 test_step.dependOn(tests.addModuleTests(b, .{416 test_step.dependOn(tests.addModuleTests(b, .{
422 .test_filter = test_filter,417 .test_filter = test_filter,
...@@ -428,8 +423,6 @@ pub fn build(b: *std.Build) !void {...@@ -428,8 +423,6 @@ pub fn build(b: *std.Build) !void {
428 .skip_non_native = skip_non_native,423 .skip_non_native = skip_non_native,
429 .skip_cross_glibc = skip_cross_glibc,424 .skip_cross_glibc = skip_cross_glibc,
430 .skip_libc = skip_libc,425 .skip_libc = skip_libc,
431 .skip_stage1 = skip_stage1,
432 .skip_stage2 = skip_stage2_tests,
433 .max_rss = 1 * 1024 * 1024 * 1024,426 .max_rss = 1 * 1024 * 1024 * 1024,
434 }));427 }));
435428
...@@ -443,8 +436,6 @@ pub fn build(b: *std.Build) !void {...@@ -443,8 +436,6 @@ pub fn build(b: *std.Build) !void {
443 .skip_non_native = skip_non_native,436 .skip_non_native = skip_non_native,
444 .skip_cross_glibc = skip_cross_glibc,437 .skip_cross_glibc = skip_cross_glibc,
445 .skip_libc = true,438 .skip_libc = true,
446 .skip_stage1 = skip_stage1,
447 .skip_stage2 = true, // TODO get all these passing
448 }));439 }));
449440
450 test_step.dependOn(tests.addModuleTests(b, .{441 test_step.dependOn(tests.addModuleTests(b, .{
...@@ -457,8 +448,6 @@ pub fn build(b: *std.Build) !void {...@@ -457,8 +448,6 @@ pub fn build(b: *std.Build) !void {
457 .skip_non_native = skip_non_native,448 .skip_non_native = skip_non_native,
458 .skip_cross_glibc = skip_cross_glibc,449 .skip_cross_glibc = skip_cross_glibc,
459 .skip_libc = true,450 .skip_libc = true,
460 .skip_stage1 = skip_stage1,
461 .skip_stage2 = true, // TODO get all these passing
462 }));451 }));
463452
464 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));453 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));
...@@ -466,11 +455,11 @@ pub fn build(b: *std.Build) !void {...@@ -466,11 +455,11 @@ pub fn build(b: *std.Build) !void {
466 b,455 b,
467 optimization_modes,456 optimization_modes,
468 enable_macos_sdk,457 enable_macos_sdk,
469 skip_stage2_tests,458 false,
470 enable_symlinks_windows,459 enable_symlinks_windows,
471 ));460 ));
472 test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));461 test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
473 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));462 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, false, enable_symlinks_windows));
474 test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes));463 test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes));
475 test_step.dependOn(tests.addCliTests(b));464 test_step.dependOn(tests.addCliTests(b));
476 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes));465 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes));
...@@ -489,8 +478,6 @@ pub fn build(b: *std.Build) !void {...@@ -489,8 +478,6 @@ pub fn build(b: *std.Build) !void {
489 .skip_non_native = skip_non_native,478 .skip_non_native = skip_non_native,
490 .skip_cross_glibc = skip_cross_glibc,479 .skip_cross_glibc = skip_cross_glibc,
491 .skip_libc = skip_libc,480 .skip_libc = skip_libc,
492 .skip_stage1 = skip_stage1,
493 .skip_stage2 = true, // TODO get all these passing
494 // I observed a value of 3398275072 on my M1, and multiplied by 1.1 to481 // I observed a value of 3398275072 on my M1, and multiplied by 1.1 to
495 // get this amount:482 // get this amount:
496 .max_rss = 3738102579,483 .max_rss = 3738102579,
lib/compiler_rt/common.zig+2-1
...@@ -6,7 +6,8 @@ pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal el...@@ -6,7 +6,8 @@ pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal el
6/// Determines the symbol's visibility to other objects.6/// Determines the symbol's visibility to other objects.
7/// For WebAssembly this allows the symbol to be resolved to other modules, but will not7/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
8/// export it to the host runtime.8/// export it to the host runtime.
9pub const visibility: std.builtin.SymbolVisibility = if (builtin.target.isWasm()) .hidden else .default;9pub const visibility: std.builtin.SymbolVisibility =
10 if (builtin.target.isWasm() and linkage != .Internal) .hidden else .default;
10pub const want_aeabi = switch (builtin.abi) {11pub const want_aeabi = switch (builtin.abi) {
11 .eabi,12 .eabi,
12 .eabihf,13 .eabihf,
lib/std/Build.zig+41-2
...@@ -454,6 +454,10 @@ pub const ExecutableOptions = struct {...@@ -454,6 +454,10 @@ pub const ExecutableOptions = struct {
454 optimize: std.builtin.Mode = .Debug,454 optimize: std.builtin.Mode = .Debug,
455 linkage: ?CompileStep.Linkage = null,455 linkage: ?CompileStep.Linkage = null,
456 max_rss: usize = 0,456 max_rss: usize = 0,
457 link_libc: ?bool = null,
458 single_threaded: ?bool = null,
459 use_llvm: ?bool = null,
460 use_lld: ?bool = null,
457};461};
458462
459pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {463pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
...@@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {...@@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
466 .kind = .exe,470 .kind = .exe,
467 .linkage = options.linkage,471 .linkage = options.linkage,
468 .max_rss = options.max_rss,472 .max_rss = options.max_rss,
473 .link_libc = options.link_libc,
474 .single_threaded = options.single_threaded,
475 .use_llvm = options.use_llvm,
476 .use_lld = options.use_lld,
469 });477 });
470}478}
471479
...@@ -475,6 +483,10 @@ pub const ObjectOptions = struct {...@@ -475,6 +483,10 @@ pub const ObjectOptions = struct {
475 target: CrossTarget,483 target: CrossTarget,
476 optimize: std.builtin.Mode,484 optimize: std.builtin.Mode,
477 max_rss: usize = 0,485 max_rss: usize = 0,
486 link_libc: ?bool = null,
487 single_threaded: ?bool = null,
488 use_llvm: ?bool = null,
489 use_lld: ?bool = null,
478};490};
479491
480pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {492pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
...@@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {...@@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
485 .optimize = options.optimize,497 .optimize = options.optimize,
486 .kind = .obj,498 .kind = .obj,
487 .max_rss = options.max_rss,499 .max_rss = options.max_rss,
500 .link_libc = options.link_libc,
501 .single_threaded = options.single_threaded,
502 .use_llvm = options.use_llvm,
503 .use_lld = options.use_lld,
488 });504 });
489}505}
490506
...@@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct {...@@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct {
495 target: CrossTarget,511 target: CrossTarget,
496 optimize: std.builtin.Mode,512 optimize: std.builtin.Mode,
497 max_rss: usize = 0,513 max_rss: usize = 0,
514 link_libc: ?bool = null,
515 single_threaded: ?bool = null,
516 use_llvm: ?bool = null,
517 use_lld: ?bool = null,
498};518};
499519
500pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {520pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
...@@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {...@@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
507 .target = options.target,527 .target = options.target,
508 .optimize = options.optimize,528 .optimize = options.optimize,
509 .max_rss = options.max_rss,529 .max_rss = options.max_rss,
530 .link_libc = options.link_libc,
531 .single_threaded = options.single_threaded,
532 .use_llvm = options.use_llvm,
533 .use_lld = options.use_lld,
510 });534 });
511}535}
512536
...@@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct {...@@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct {
517 optimize: std.builtin.Mode,541 optimize: std.builtin.Mode,
518 version: ?std.builtin.Version = null,542 version: ?std.builtin.Version = null,
519 max_rss: usize = 0,543 max_rss: usize = 0,
544 link_libc: ?bool = null,
545 single_threaded: ?bool = null,
546 use_llvm: ?bool = null,
547 use_lld: ?bool = null,
520};548};
521549
522pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {550pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
...@@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {...@@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
529 .target = options.target,557 .target = options.target,
530 .optimize = options.optimize,558 .optimize = options.optimize,
531 .max_rss = options.max_rss,559 .max_rss = options.max_rss,
560 .link_libc = options.link_libc,
561 .single_threaded = options.single_threaded,
562 .use_llvm = options.use_llvm,
563 .use_lld = options.use_lld,
532 });564 });
533}565}
534566
...@@ -541,6 +573,10 @@ pub const TestOptions = struct {...@@ -541,6 +573,10 @@ pub const TestOptions = struct {
541 max_rss: usize = 0,573 max_rss: usize = 0,
542 filter: ?[]const u8 = null,574 filter: ?[]const u8 = null,
543 test_runner: ?[]const u8 = null,575 test_runner: ?[]const u8 = null,
576 link_libc: ?bool = null,
577 single_threaded: ?bool = null,
578 use_llvm: ?bool = null,
579 use_lld: ?bool = null,
544};580};
545581
546pub fn addTest(b: *Build, options: TestOptions) *CompileStep {582pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
...@@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep {...@@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
553 .max_rss = options.max_rss,589 .max_rss = options.max_rss,
554 .filter = options.filter,590 .filter = options.filter,
555 .test_runner = options.test_runner,591 .test_runner = options.test_runner,
592 .link_libc = options.link_libc,
593 .single_threaded = options.single_threaded,
594 .use_llvm = options.use_llvm,
595 .use_lld = options.use_lld,
556 });596 });
557}597}
558598
...@@ -639,8 +679,7 @@ pub fn addRunArtifact(b: *Build, exe: *CompileStep) *RunStep {...@@ -639,8 +679,7 @@ pub fn addRunArtifact(b: *Build, exe: *CompileStep) *RunStep {
639 run_step.addArtifactArg(exe);679 run_step.addArtifactArg(exe);
640680
641 if (exe.kind == .@"test") {681 if (exe.kind == .@"test") {
642 run_step.stdio = .zig_test;682 run_step.enableTestRunnerMode();
643 run_step.addArgs(&.{"--listen=-"});
644 }683 }
645684
646 if (exe.vcpkg_bin_path) |path| {685 if (exe.vcpkg_bin_path) |path| {
lib/std/Build/CompileStep.zig+15-5
...@@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default,...@@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default,
63// so it is not an EmitOption for now.63// so it is not an EmitOption for now.
64emit_h: bool = false,64emit_h: bool = false,
65bundle_compiler_rt: ?bool = null,65bundle_compiler_rt: ?bool = null,
66single_threaded: ?bool = null,66single_threaded: ?bool,
67stack_protector: ?bool = null,67stack_protector: ?bool = null,
68disable_stack_probing: bool,68disable_stack_probing: bool,
69disable_sanitize_c: bool,69disable_sanitize_c: bool,
...@@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject),...@@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject),
101include_dirs: ArrayList(IncludeDir),101include_dirs: ArrayList(IncludeDir),
102c_macros: ArrayList([]const u8),102c_macros: ArrayList([]const u8),
103installed_headers: ArrayList(*Step),103installed_headers: ArrayList(*Step),
104is_linking_libc: bool = false,104is_linking_libc: bool,
105is_linking_libcpp: bool = false,105is_linking_libcpp: bool,
106vcpkg_bin_path: ?[]const u8 = null,106vcpkg_bin_path: ?[]const u8 = null,
107107
108/// This may be set in order to override the default install directory108/// This may be set in order to override the default install directory
...@@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void),...@@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void),
207stack_size: ?u64 = null,207stack_size: ?u64 = null,
208208
209want_lto: ?bool = null,209want_lto: ?bool = null,
210use_llvm: ?bool = null,210use_llvm: ?bool,
211use_lld: ?bool = null,211use_lld: ?bool,
212212
213/// This is an advanced setting that can change the intent of this CompileStep.213/// This is an advanced setting that can change the intent of this CompileStep.
214/// If this slice has nonzero length, it means that this CompileStep exists to214/// If this slice has nonzero length, it means that this CompileStep exists to
...@@ -287,6 +287,10 @@ pub const Options = struct {...@@ -287,6 +287,10 @@ pub const Options = struct {
287 max_rss: usize = 0,287 max_rss: usize = 0,
288 filter: ?[]const u8 = null,288 filter: ?[]const u8 = null,
289 test_runner: ?[]const u8 = null,289 test_runner: ?[]const u8 = null,
290 link_libc: ?bool = null,
291 single_threaded: ?bool = null,
292 use_llvm: ?bool = null,
293 use_lld: ?bool = null,
290};294};
291295
292pub const Kind = enum {296pub const Kind = enum {
...@@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {...@@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {
412 .output_dirname_source = GeneratedFile{ .step = &self.step },416 .output_dirname_source = GeneratedFile{ .step = &self.step },
413417
414 .target_info = target_info,418 .target_info = target_info,
419
420 .is_linking_libc = options.link_libc orelse false,
421 .is_linking_libcpp = false,
422 .single_threaded = options.single_threaded,
423 .use_llvm = options.use_llvm,
424 .use_lld = options.use_lld,
415 };425 };
416426
417 if (self.kind == .lib) {427 if (self.kind == .lib) {
lib/std/Build/RunStep.zig+5
...@@ -140,6 +140,11 @@ pub fn setName(self: *RunStep, name: []const u8) void {...@@ -140,6 +140,11 @@ pub fn setName(self: *RunStep, name: []const u8) void {
140 self.rename_step_with_output_arg = false;140 self.rename_step_with_output_arg = false;
141}141}
142142
143pub fn enableTestRunnerMode(rs: *RunStep) void {
144 rs.stdio = .zig_test;
145 rs.addArgs(&.{"--listen=-"});
146}
147
143pub fn addArtifactArg(self: *RunStep, artifact: *CompileStep) void {148pub fn addArtifactArg(self: *RunStep, artifact: *CompileStep) void {
144 self.argv.append(Arg{ .artifact = artifact }) catch @panic("OOM");149 self.argv.append(Arg{ .artifact = artifact }) catch @panic("OOM");
145 self.step.dependOn(&artifact.step);150 self.step.dependOn(&artifact.step);
lib/std/zig/Server.zig+4-8
...@@ -104,11 +104,9 @@ pub fn receiveMessage(s: *Server) !InMessage.Header {...@@ -104,11 +104,9 @@ pub fn receiveMessage(s: *Server) !InMessage.Header {
104 const buf = fifo.readableSlice(0);104 const buf = fifo.readableSlice(0);
105 assert(fifo.readableLength() == buf.len);105 assert(fifo.readableLength() == buf.len);
106 if (buf.len >= @sizeOf(Header)) {106 if (buf.len >= @sizeOf(Header)) {
107 const header = @ptrCast(*align(1) const Header, buf[0..@sizeOf(Header)]);
108 // workaround for https://github.com/ziglang/zig/issues/14904107 // workaround for https://github.com/ziglang/zig/issues/14904
109 const bytes_len = bswap_and_workaround_u32(&header.bytes_len);108 const bytes_len = bswap_and_workaround_u32(buf[4..][0..4]);
110 // workaround for https://github.com/ziglang/zig/issues/14904109 const tag = bswap_and_workaround_tag(buf[0..][0..4]);
111 const tag = bswap_and_workaround_tag(&header.tag);
112110
113 if (buf.len - @sizeOf(Header) >= bytes_len) {111 if (buf.len - @sizeOf(Header) >= bytes_len) {
114 fifo.discard(@sizeOf(Header));112 fifo.discard(@sizeOf(Header));
...@@ -281,14 +279,12 @@ fn bswap_u32_array(slice: []u32) void {...@@ -281,14 +279,12 @@ fn bswap_u32_array(slice: []u32) void {
281}279}
282280
283/// workaround for https://github.com/ziglang/zig/issues/14904281/// workaround for https://github.com/ziglang/zig/issues/14904
284fn bswap_and_workaround_u32(x: *align(1) const u32) u32 {282fn bswap_and_workaround_u32(bytes_ptr: *const [4]u8) u32 {
285 const bytes_ptr = @ptrCast(*const [4]u8, x);
286 return std.mem.readIntLittle(u32, bytes_ptr);283 return std.mem.readIntLittle(u32, bytes_ptr);
287}284}
288285
289/// workaround for https://github.com/ziglang/zig/issues/14904286/// workaround for https://github.com/ziglang/zig/issues/14904
290fn bswap_and_workaround_tag(x: *align(1) const InMessage.Tag) InMessage.Tag {287fn bswap_and_workaround_tag(bytes_ptr: *const [4]u8) InMessage.Tag {
291 const bytes_ptr = @ptrCast(*const [4]u8, x);
292 const int = std.mem.readIntLittle(u32, bytes_ptr);288 const int = std.mem.readIntLittle(u32, bytes_ptr);
293 return @intToEnum(InMessage.Tag, int);289 return @intToEnum(InMessage.Tag, int);
294}290}
test/behavior/atomics.zig+6
...@@ -209,6 +209,12 @@ test "atomicrmw with floats" {...@@ -209,6 +209,12 @@ test "atomicrmw with floats" {
209 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO209 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
210 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO210 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
211211
212 if (builtin.zig_backend == .stage2_c) {
213 // TODO: test.c:34929:7: error: address argument to atomic operation must be a pointer to integer or pointer ('zig_f32 *' (aka 'float *') invalid
214 // when compiling with -std=c99 -pedantic
215 return error.SkipZigTest;
216 }
217
212 if ((builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) and218 if ((builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) and
213 builtin.cpu.arch == .aarch64)219 builtin.cpu.arch == .aarch64)
214 {220 {
test/behavior/bugs/12680.zig+4
...@@ -11,6 +11,10 @@ test "export a function twice" {...@@ -11,6 +11,10 @@ test "export a function twice" {
11 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;11 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
12 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;12 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
13 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO13 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
14 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
15 // TODO: test.c: error: aliases are not supported on darwin
16 return error.SkipZigTest;
17 }
1418
15 // If it exports the function correctly, `test_func` and `testFunc` will points to the same address.19 // If it exports the function correctly, `test_func` and `testFunc` will points to the same address.
16 try expectEqual(test_func(), other_file.testFunc());20 try expectEqual(test_func(), other_file.testFunc());
test/behavior/cast.zig+20
...@@ -1313,6 +1313,16 @@ test "cast f16 to wider types" {...@@ -1313,6 +1313,16 @@ test "cast f16 to wider types" {
1313 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1313 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1314 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO1314 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
13151315
1316 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1317 // TODO: test is failing
1318 return error.SkipZigTest;
1319 }
1320
1321 if (builtin.os.tag == .windows and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
1322 // TODO: test is failing
1323 return error.SkipZigTest;
1324 }
1325
1316 const S = struct {1326 const S = struct {
1317 fn doTheTest() !void {1327 fn doTheTest() !void {
1318 var x: f16 = 1234.0;1328 var x: f16 = 1234.0;
...@@ -1339,6 +1349,11 @@ test "cast f128 to narrower types" {...@@ -1339,6 +1349,11 @@ test "cast f128 to narrower types" {
1339 return error.SkipZigTest;1349 return error.SkipZigTest;
1340 }1350 }
13411351
1352 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1353 // TODO: test is failing
1354 return error.SkipZigTest;
1355 }
1356
1342 const S = struct {1357 const S = struct {
1343 fn doTheTest() !void {1358 fn doTheTest() !void {
1344 var x: f128 = 1234.0;1359 var x: f128 = 1234.0;
...@@ -1429,6 +1444,11 @@ test "coerce between pointers of compatible differently-named floats" {...@@ -1429,6 +1444,11 @@ test "coerce between pointers of compatible differently-named floats" {
1429 return error.SkipZigTest;1444 return error.SkipZigTest;
1430 }1445 }
14311446
1447 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
1448 // TODO: test is failing
1449 return error.SkipZigTest;
1450 }
1451
1432 const F = switch (@typeInfo(c_longdouble).Float.bits) {1452 const F = switch (@typeInfo(c_longdouble).Float.bits) {
1433 16 => f16,1453 16 => f16,
1434 32 => f32,1454 32 => f32,
test/behavior/floatop.zig+35
...@@ -542,6 +542,11 @@ test "another, possibly redundant, @fabs test" {...@@ -542,6 +542,11 @@ test "another, possibly redundant, @fabs test" {
542 return error.SkipZigTest;542 return error.SkipZigTest;
543 }543 }
544544
545 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
546 // TODO: test is failing
547 return error.SkipZigTest;
548 }
549
545 try testFabsLegacy(f128, 12.0);550 try testFabsLegacy(f128, 12.0);
546 comptime try testFabsLegacy(f128, 12.0);551 comptime try testFabsLegacy(f128, 12.0);
547 try testFabsLegacy(f64, 12.0);552 try testFabsLegacy(f64, 12.0);
...@@ -586,6 +591,11 @@ test "a third @fabs test, surely there should not be three fabs tests" {...@@ -586,6 +591,11 @@ test "a third @fabs test, surely there should not be three fabs tests" {
586 return error.SkipZigTest;591 return error.SkipZigTest;
587 }592 }
588593
594 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
595 // TODO: test is failing
596 return error.SkipZigTest;
597 }
598
589 inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| {599 inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| {
590 // normals600 // normals
591 try expect(@fabs(@as(T, 1.0)) == 1.0);601 try expect(@fabs(@as(T, 1.0)) == 1.0);
...@@ -688,6 +698,11 @@ test "@floor f128" {...@@ -688,6 +698,11 @@ test "@floor f128" {
688 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO698 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
689 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO699 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
690700
701 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
702 // TODO: test is failing
703 return error.SkipZigTest;
704 }
705
691 try testFloorLegacy(f128, 12.0);706 try testFloorLegacy(f128, 12.0);
692 comptime try testFloorLegacy(f128, 12.0);707 comptime try testFloorLegacy(f128, 12.0);
693}708}
...@@ -778,6 +793,11 @@ test "@ceil f128" {...@@ -778,6 +793,11 @@ test "@ceil f128" {
778 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO793 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
779 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO794 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
780795
796 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
797 // TODO: test is failing
798 return error.SkipZigTest;
799 }
800
781 try testCeilLegacy(f128, 12.0);801 try testCeilLegacy(f128, 12.0);
782 comptime try testCeilLegacy(f128, 12.0);802 comptime try testCeilLegacy(f128, 12.0);
783}803}
...@@ -874,6 +894,11 @@ test "@trunc f128" {...@@ -874,6 +894,11 @@ test "@trunc f128" {
874 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO894 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
875 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO895 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
876896
897 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
898 // TODO: test is failing
899 return error.SkipZigTest;
900 }
901
877 try testTruncLegacy(f128, 12.0);902 try testTruncLegacy(f128, 12.0);
878 comptime try testTruncLegacy(f128, 12.0);903 comptime try testTruncLegacy(f128, 12.0);
879}904}
...@@ -992,6 +1017,11 @@ test "negation f128" {...@@ -992,6 +1017,11 @@ test "negation f128" {
992 return error.SkipZigTest;1017 return error.SkipZigTest;
993 }1018 }
9941019
1020 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1021 // TODO: test is failing
1022 return error.SkipZigTest;
1023 }
1024
995 const S = struct {1025 const S = struct {
996 fn doTheTest() !void {1026 fn doTheTest() !void {
997 var a: f128 = 1;1027 var a: f128 = 1;
...@@ -1035,6 +1065,11 @@ test "comptime fixed-width float zero divided by zero produces NaN" {...@@ -1035,6 +1065,11 @@ test "comptime fixed-width float zero divided by zero produces NaN" {
1035 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO1065 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
1036 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO1066 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
10371067
1068 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
1069 // TODO: test is failing
1070 return error.SkipZigTest;
1071 }
1072
1038 inline for (.{ f16, f32, f64, f80, f128 }) |F| {1073 inline for (.{ f16, f32, f64, f80, f128 }) |F| {
1039 try expect(math.isNan(@as(F, 0) / @as(F, 0)));1074 try expect(math.isNan(@as(F, 0) / @as(F, 0)));
1040 }1075 }
test/behavior/math.zig+36
...@@ -622,6 +622,11 @@ test "f128" {...@@ -622,6 +622,11 @@ test "f128" {
622 return error.SkipZigTest;622 return error.SkipZigTest;
623 }623 }
624624
625 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
626 // TODO: test is failing
627 return error.SkipZigTest;
628 }
629
625 try test_f128();630 try test_f128();
626 comptime try test_f128();631 comptime try test_f128();
627}632}
...@@ -1299,6 +1304,11 @@ test "remainder division" {...@@ -1299,6 +1304,11 @@ test "remainder division" {
1299 return error.SkipZigTest;1304 return error.SkipZigTest;
1300 }1305 }
13011306
1307 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1308 // TODO: test is failing
1309 return error.SkipZigTest;
1310 }
1311
1302 comptime try remdiv(f16);1312 comptime try remdiv(f16);
1303 comptime try remdiv(f32);1313 comptime try remdiv(f32);
1304 comptime try remdiv(f64);1314 comptime try remdiv(f64);
...@@ -1330,6 +1340,11 @@ test "float remainder division using @rem" {...@@ -1330,6 +1340,11 @@ test "float remainder division using @rem" {
1330 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO1340 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
1331 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO1341 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
13321342
1343 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
1344 // TODO: test is failing
1345 return error.SkipZigTest;
1346 }
1347
1333 comptime try frem(f16);1348 comptime try frem(f16);
1334 comptime try frem(f32);1349 comptime try frem(f32);
1335 comptime try frem(f64);1350 comptime try frem(f64);
...@@ -1372,6 +1387,11 @@ test "float modulo division using @mod" {...@@ -1372,6 +1387,11 @@ test "float modulo division using @mod" {
1372 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO1387 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
1373 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO1388 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
13741389
1390 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
1391 // TODO: test is failing
1392 return error.SkipZigTest;
1393 }
1394
1375 comptime try fmod(f16);1395 comptime try fmod(f16);
1376 comptime try fmod(f32);1396 comptime try fmod(f32);
1377 comptime try fmod(f64);1397 comptime try fmod(f64);
...@@ -1445,6 +1465,11 @@ test "@round f128" {...@@ -1445,6 +1465,11 @@ test "@round f128" {
1445 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO1465 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
1446 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO1466 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
14471467
1468 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1469 // TODO: test is failing
1470 return error.SkipZigTest;
1471 }
1472
1448 try testRound(f128, 12.0);1473 try testRound(f128, 12.0);
1449 comptime try testRound(f128, 12.0);1474 comptime try testRound(f128, 12.0);
1450}1475}
...@@ -1490,6 +1515,11 @@ test "NaN comparison" {...@@ -1490,6 +1515,11 @@ test "NaN comparison" {
1490 return error.SkipZigTest;1515 return error.SkipZigTest;
1491 }1516 }
14921517
1518 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1519 // TODO: test is failing
1520 return error.SkipZigTest;
1521 }
1522
1493 try testNanEqNan(f16);1523 try testNanEqNan(f16);
1494 try testNanEqNan(f32);1524 try testNanEqNan(f32);
1495 try testNanEqNan(f64);1525 try testNanEqNan(f64);
...@@ -1562,6 +1592,12 @@ test "signed zeros are represented properly" {...@@ -1562,6 +1592,12 @@ test "signed zeros are represented properly" {
1562 if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and1592 if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
1563 builtin.zig_backend == .stage2_c)1593 builtin.zig_backend == .stage2_c)
1564 {1594 {
1595 // TODO: test is failing
1596 return error.SkipZigTest;
1597 }
1598
1599 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
1600 // TODO: test is failing
1565 return error.SkipZigTest;1601 return error.SkipZigTest;
1566 }1602 }
15671603
test/behavior/muladd.zig+10
...@@ -75,6 +75,11 @@ test "@mulAdd f128" {...@@ -75,6 +75,11 @@ test "@mulAdd f128" {
75 return error.SkipZigTest;75 return error.SkipZigTest;
76 }76 }
7777
78 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
79 // TODO: test is failing
80 return error.SkipZigTest;
81 }
82
78 comptime try testMulAdd128();83 comptime try testMulAdd128();
79 try testMulAdd128();84 try testMulAdd128();
80}85}
...@@ -203,6 +208,11 @@ test "vector f128" {...@@ -203,6 +208,11 @@ test "vector f128" {
203 return error.SkipZigTest;208 return error.SkipZigTest;
204 }209 }
205210
211 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
212 // TODO: test is failing
213 return error.SkipZigTest;
214 }
215
206 comptime try vector128();216 comptime try vector128();
207 try vector128();217 try vector128();
208}218}
test/behavior/vector.zig+5
...@@ -103,6 +103,11 @@ test "vector float operators" {...@@ -103,6 +103,11 @@ test "vector float operators" {
103 return error.SkipZigTest;103 return error.SkipZigTest;
104 }104 }
105105
106 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
107 // TODO: test is failing
108 return error.SkipZigTest;
109 }
110
106 inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {111 inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
107 const S = struct {112 const S = struct {
108 fn doTheTest() !void {113 fn doTheTest() !void {
test/behavior/widening.zig+10
...@@ -50,6 +50,11 @@ test "float widening" {...@@ -50,6 +50,11 @@ test "float widening" {
50 return error.SkipZigTest;50 return error.SkipZigTest;
51 }51 }
5252
53 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
54 // TODO: test is failing
55 return error.SkipZigTest;
56 }
57
53 var a: f16 = 12.34;58 var a: f16 = 12.34;
54 var b: f32 = a;59 var b: f32 = a;
55 var c: f64 = b;60 var c: f64 = b;
...@@ -77,6 +82,11 @@ test "float widening f16 to f128" {...@@ -77,6 +82,11 @@ test "float widening f16 to f128" {
77 return error.SkipZigTest;82 return error.SkipZigTest;
78 }83 }
7984
85 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
86 // TODO: test is failing
87 return error.SkipZigTest;
88 }
89
80 var x: f16 = 12.34;90 var x: f16 = 12.34;
81 var y: f128 = x;91 var y: f128 = x;
82 try expect(x == y);92 try expect(x == y);
test/tests.zig+162-111
...@@ -22,12 +22,12 @@ pub const CompareOutputContext = @import("src/CompareOutput.zig");...@@ -22,12 +22,12 @@ pub const CompareOutputContext = @import("src/CompareOutput.zig");
22pub const StackTracesContext = @import("src/StackTrace.zig");22pub const StackTracesContext = @import("src/StackTrace.zig");
2323
24const TestTarget = struct {24const TestTarget = struct {
25 target: CrossTarget = @as(CrossTarget, .{}),25 target: CrossTarget = .{},
26 optimize_mode: std.builtin.OptimizeMode = .Debug,26 optimize_mode: std.builtin.OptimizeMode = .Debug,
27 link_libc: bool = false,27 link_libc: ?bool = null,
28 single_threaded: bool = false,28 single_threaded: ?bool = null,
29 disable_native: bool = false,29 use_llvm: ?bool = null,
30 backend: ?std.builtin.CompilerBackend = null,30 use_lld: ?bool = null,
31};31};
3232
33const test_targets = blk: {33const test_targets = blk: {
...@@ -43,13 +43,47 @@ const test_targets = blk: {...@@ -43,13 +43,47 @@ const test_targets = blk: {
43 .{43 .{
44 .single_threaded = true,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 },
4681
47 .{82 .{
48 .target = .{83 .target = .{
49 .ofmt = .c,84 .ofmt = .c,
50 },85 },
51 .link_libc = true,86 .link_libc = true,
52 .backend = .stage2_c,
53 },87 },
54 .{88 .{
55 .target = .{89 .target = .{
...@@ -57,22 +91,24 @@ const test_targets = blk: {...@@ -57,22 +91,24 @@ const test_targets = blk: {
57 .os_tag = .linux,91 .os_tag = .linux,
58 .abi = .none,92 .abi = .none,
59 },93 },
60 .backend = .stage2_x86_64,94 .use_llvm = false,
95 .use_lld = false,
61 },96 },
62 .{97 .{
63 .target = .{98 .target = .{
64 .cpu_arch = .aarch64,99 .cpu_arch = .aarch64,
65 .os_tag = .linux,100 .os_tag = .linux,
66 },101 },
67 .backend = .stage2_aarch64,102 .use_llvm = false,
103 .use_lld = false,
68 },104 },
69 .{105 .{
70 .target = .{106 .target = .{
71 .cpu_arch = .wasm32,107 .cpu_arch = .wasm32,
72 .os_tag = .wasi,108 .os_tag = .wasi,
73 },109 },
74 .single_threaded = true,110 .use_llvm = false,
75 .backend = .stage2_wasm,111 .use_lld = false,
76 },112 },
77 // https://github.com/ziglang/zig/issues/13623113 // https://github.com/ziglang/zig/issues/13623
78 //.{114 //.{
...@@ -80,7 +116,8 @@ const test_targets = blk: {...@@ -80,7 +116,8 @@ const test_targets = blk: {
80 // .cpu_arch = .arm,116 // .cpu_arch = .arm,
81 // .os_tag = .linux,117 // .os_tag = .linux,
82 // },118 // },
83 // .backend = .stage2_arm,119 // .use_llvm = false,
120 // .use_lld = false,
84 //},121 //},
85 // https://github.com/ziglang/zig/issues/13623122 // https://github.com/ziglang/zig/issues/13623
86 //.{123 //.{
...@@ -88,7 +125,8 @@ const test_targets = blk: {...@@ -88,7 +125,8 @@ const test_targets = blk: {
88 // .arch_os_abi = "arm-linux-none",125 // .arch_os_abi = "arm-linux-none",
89 // .cpu_features = "generic+v8a",126 // .cpu_features = "generic+v8a",
90 // }) catch unreachable,127 // }) catch unreachable,
91 // .backend = .stage2_arm,128 // .use_llvm = false,
129 // .use_lld = false,
92 //},130 //},
93 .{131 .{
94 .target = .{132 .target = .{
...@@ -96,7 +134,8 @@ const test_targets = blk: {...@@ -96,7 +134,8 @@ const test_targets = blk: {
96 .os_tag = .macos,134 .os_tag = .macos,
97 .abi = .none,135 .abi = .none,
98 },136 },
99 .backend = .stage2_aarch64,137 .use_llvm = false,
138 .use_lld = false,
100 },139 },
101 .{140 .{
102 .target = .{141 .target = .{
...@@ -104,7 +143,8 @@ const test_targets = blk: {...@@ -104,7 +143,8 @@ const test_targets = blk: {
104 .os_tag = .macos,143 .os_tag = .macos,
105 .abi = .none,144 .abi = .none,
106 },145 },
107 .backend = .stage2_x86_64,146 .use_llvm = false,
147 .use_lld = false,
108 },148 },
109 .{149 .{
110 .target = .{150 .target = .{
...@@ -112,7 +152,8 @@ const test_targets = blk: {...@@ -112,7 +152,8 @@ const test_targets = blk: {
112 .os_tag = .windows,152 .os_tag = .windows,
113 .abi = .gnu,153 .abi = .gnu,
114 },154 },
115 .backend = .stage2_x86_64,155 .use_llvm = false,
156 .use_lld = false,
116 },157 },
117158
118 .{159 .{
...@@ -121,7 +162,6 @@ const test_targets = blk: {...@@ -121,7 +162,6 @@ const test_targets = blk: {
121 .os_tag = .wasi,162 .os_tag = .wasi,
122 },163 },
123 .link_libc = false,164 .link_libc = false,
124 .single_threaded = true,
125 },165 },
126 .{166 .{
127 .target = .{167 .target = .{
...@@ -129,7 +169,6 @@ const test_targets = blk: {...@@ -129,7 +169,6 @@ const test_targets = blk: {
129 .os_tag = .wasi,169 .os_tag = .wasi,
130 },170 },
131 .link_libc = true,171 .link_libc = true,
132 .single_threaded = true,
133 },172 },
134173
135 .{174 .{
...@@ -413,43 +452,6 @@ const test_targets = blk: {...@@ -413,43 +452,6 @@ const test_targets = blk: {
413 },452 },
414 .link_libc = true,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};
455457
...@@ -913,8 +915,6 @@ const ModuleTestOptions = struct {...@@ -913,8 +915,6 @@ const ModuleTestOptions = struct {
913 skip_non_native: bool,915 skip_non_native: bool,
914 skip_cross_glibc: bool,916 skip_cross_glibc: bool,
915 skip_libc: bool,917 skip_libc: bool,
916 skip_stage1: bool,
917 skip_stage2: bool,
918 max_rss: usize = 0,918 max_rss: usize = 0,
919};919};
920920
...@@ -922,49 +922,65 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -922,49 +922,65 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
922 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);922 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
923923
924 for (test_targets) |test_target| {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 continue;930 continue;
927931
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 continue;933 continue;
930934
931 if (options.skip_libc and test_target.link_libc)935 if (options.skip_libc and test_target.link_libc == true)
932 continue;936 continue;
933937
934 if (test_target.link_libc and test_target.target.getOs().requiresLibC()) {938 if (options.skip_single_threaded and test_target.single_threaded == true)
935 // This would be a redundant test.
936 continue;939 continue;
937 }
938940
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 continue;943 continue;
941944
942 if (test_target.disable_native and945 // TODO get the x86_64 self-hosted backend tests passing on Windows
943 test_target.target.getOsTag() == builtin.os.tag and946 if (test_target.target.getCpuArch() == .x86_64 and
944 test_target.target.getCpuArch() == builtin.cpu.arch)947 test_target.target.getOsTag() == .windows and
948 test_target.use_llvm == false)
945 {949 {
946 continue;950 continue;
947 }951 }
948952
949 if (test_target.backend) |backend| switch (backend) {953 // TODO get compiler-rt tests passing for wasm32-wasi
950 .stage1 => if (options.skip_stage1) continue,954 // currently causes "LLVM ERROR: Unable to expand fixed point multiplication."
951 .stage2_llvm => {},955 if (test_target.target.getCpuArch() == .wasm32 and
952 else => if (options.skip_stage2) continue,956 test_target.target.getOsTag() == .wasi and
953 };957 mem.eql(u8, options.name, "compiler-rt"))
958 {
959 continue;
960 }
961
962 // TODO get universal-libc tests passing for self-hosted backends.
963 if (test_target.use_llvm == false and mem.eql(u8, options.name, "universal-libc"))
964 continue;
965
966 // TODO get std lib tests passing for self-hosted backends.
967 if (test_target.use_llvm == false and mem.eql(u8, options.name, "std"))
968 continue;
969
970 // TODO get std lib tests passing for the C backend
971 if (test_target.target.ofmt == std.Target.ObjectFormat.c and
972 mem.eql(u8, options.name, "std"))
973 {
974 continue;
975 }
954976
955 const want_this_mode = for (options.optimize_modes) |m| {977 const want_this_mode = for (options.optimize_modes) |m| {
956 if (m == test_target.optimize_mode) break true;978 if (m == test_target.optimize_mode) break true;
957 } else false;979 } else false;
958 if (!want_this_mode) continue;980 if (!want_this_mode) continue;
959981
960 const libc_prefix = if (test_target.target.getOs().requiresLibC())982 const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
961 ""983 const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM");
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");
968984
969 // wasm32-wasi builds need more RAM, idk why985 // wasm32-wasi builds need more RAM, idk why
970 const max_rss = if (test_target.target.getOs().tag == .wasi)986 const max_rss = if (test_target.target.getOs().tag == .wasi)
...@@ -978,45 +994,80 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -978,45 +994,80 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
978 .target = test_target.target,994 .target = test_target.target,
979 .max_rss = max_rss,995 .max_rss = max_rss,
980 .filter = options.test_filter,996 .filter = options.test_filter,
997 .link_libc = test_target.link_libc,
998 .single_threaded = test_target.single_threaded,
999 .use_llvm = test_target.use_llvm,
1000 .use_lld = test_target.use_lld,
981 });1001 });
982 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";1002 const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else "";
983 const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";1003 const backend_suffix = if (test_target.use_llvm == true)
984 these_tests.single_threaded = test_target.single_threaded;1004 "-llvm"
985 if (test_target.link_libc) {1005 else if (test_target.target.ofmt == std.Target.ObjectFormat.c)
986 these_tests.linkSystemLibrary("c");1006 "-cbe"
987 }1007 else if (test_target.use_llvm == false)
1008 "-selfhosted"
1009 else
1010 "";
1011
988 these_tests.overrideZigLibDir("lib");1012 these_tests.overrideZigLibDir("lib");
989 these_tests.addIncludePath("test");1013 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 };
10071014
1008 const run = b.addRunArtifact(these_tests);1015 const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}", .{
1009 run.skip_foreign_checks = true;
1010 run.setName(b.fmt("run test {s}-{s}-{s}-{s}-{s}-{s}", .{
1011 options.name,1016 options.name,
1012 triple_prefix,1017 triple_txt,
1013 @tagName(test_target.optimize_mode),1018 @tagName(test_target.optimize_mode),
1014 libc_prefix,1019 libc_suffix,
1015 single_threaded_txt,1020 single_threaded_suffix,
1016 backend_txt,1021 backend_suffix,
1017 }));1022 });
1023
1024 if (test_target.target.ofmt == std.Target.ObjectFormat.c) {
1025 var altered_target = test_target.target;
1026 altered_target.ofmt = null;
10181027
1019 step.dependOn(&run.step);1028 const compile_c = b.addExecutable(.{
1029 .name = qualified_name,
1030 .link_libc = test_target.link_libc,
1031 .target = altered_target,
1032 });
1033 compile_c.overrideZigLibDir("lib");
1034 compile_c.addCSourceFileSource(.{
1035 .source = these_tests.getOutputSource(),
1036 .args = &.{
1037 // TODO output -std=c89 compatible C code
1038 "-std=c99",
1039 "-pedantic",
1040 "-Werror",
1041 // TODO stop violating these pedantic errors. spotted on linux
1042 "-Wno-address-of-packed-member",
1043 "-Wno-gnu-folding-constant",
1044 "-Wno-incompatible-pointer-types",
1045 "-Wno-overlength-strings",
1046 // TODO stop violating these pedantic errors. spotted on darwin
1047 "-Wno-dollar-in-identifier-extension",
1048 "-Wno-absolute-value",
1049 },
1050 });
1051 compile_c.addIncludePath("lib"); // for zig.h
1052 if (test_target.link_libc == false and test_target.target.getOsTag() == .windows) {
1053 compile_c.subsystem = .Console;
1054 compile_c.linkSystemLibrary("kernel32");
1055 compile_c.linkSystemLibrary("ntdll");
1056 }
1057
1058 const run = b.addRunArtifact(compile_c);
1059 run.skip_foreign_checks = true;
1060 run.enableTestRunnerMode();
1061 run.setName(b.fmt("run test {s}", .{qualified_name}));
1062
1063 step.dependOn(&run.step);
1064 } else {
1065 const run = b.addRunArtifact(these_tests);
1066 run.skip_foreign_checks = true;
1067 run.setName(b.fmt("run test {s}", .{qualified_name}));
1068
1069 step.dependOn(&run.step);
1070 }
1020 }1071 }
1021 return step;1072 return step;
1022}1073}