From adc9b77d5fc4d1520905f1b1f4b3c80d6d424da6 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 13 Apr 2023 16:44:28 -0700 Subject: [PATCH 1/8] std.Build: add some more init options to CompileStep --- lib/std/Build.zig | 40 +++++++++++++++++++++++++++++++++++ lib/std/Build/CompileStep.zig | 20 +++++++++++++----- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/lib/std/Build.zig b/lib/std/Build.zig index 7faa7780b22a73e52f4f00b639f6b3bc3f16039c..0cade2b6f33f3fe10c5c057261aa0cae1917b061 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -454,6 +454,10 @@ pub const ExecutableOptions = struct { optimize: std.builtin.Mode = .Debug, linkage: ?CompileStep.Linkage = null, max_rss: usize = 0, + link_libc: ?bool = null, + single_threaded: ?bool = null, + use_llvm: ?bool = null, + use_lld: ?bool = null, }; pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep { @@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep { .kind = .exe, .linkage = options.linkage, .max_rss = options.max_rss, + .link_libc = options.link_libc, + .single_threaded = options.single_threaded, + .use_llvm = options.use_llvm, + .use_lld = options.use_lld, }); } @@ -475,6 +483,10 @@ pub const ObjectOptions = struct { target: CrossTarget, optimize: std.builtin.Mode, max_rss: usize = 0, + link_libc: ?bool = null, + single_threaded: ?bool = null, + use_llvm: ?bool = null, + use_lld: ?bool = null, }; pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep { @@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep { .optimize = options.optimize, .kind = .obj, .max_rss = options.max_rss, + .link_libc = options.link_libc, + .single_threaded = options.single_threaded, + .use_llvm = options.use_llvm, + .use_lld = options.use_lld, }); } @@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct { target: CrossTarget, optimize: std.builtin.Mode, max_rss: usize = 0, + link_libc: ?bool = null, + single_threaded: ?bool = null, + use_llvm: ?bool = null, + use_lld: ?bool = null, }; pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep { @@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep { .target = options.target, .optimize = options.optimize, .max_rss = options.max_rss, + .link_libc = options.link_libc, + .single_threaded = options.single_threaded, + .use_llvm = options.use_llvm, + .use_lld = options.use_lld, }); } @@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct { optimize: std.builtin.Mode, version: ?std.builtin.Version = null, max_rss: usize = 0, + link_libc: ?bool = null, + single_threaded: ?bool = null, + use_llvm: ?bool = null, + use_lld: ?bool = null, }; pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep { @@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep { .target = options.target, .optimize = options.optimize, .max_rss = options.max_rss, + .link_libc = options.link_libc, + .single_threaded = options.single_threaded, + .use_llvm = options.use_llvm, + .use_lld = options.use_lld, }); } @@ -541,6 +573,10 @@ pub const TestOptions = struct { max_rss: usize = 0, filter: ?[]const u8 = null, test_runner: ?[]const u8 = null, + link_libc: ?bool = null, + single_threaded: ?bool = null, + use_llvm: ?bool = null, + use_lld: ?bool = null, }; pub fn addTest(b: *Build, options: TestOptions) *CompileStep { @@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep { .max_rss = options.max_rss, .filter = options.filter, .test_runner = options.test_runner, + .link_libc = options.link_libc, + .single_threaded = options.single_threaded, + .use_llvm = options.use_llvm, + .use_lld = options.use_lld, }); } diff --git a/lib/std/Build/CompileStep.zig b/lib/std/Build/CompileStep.zig index 7ca9dda23b94aa4d1eedf7bf43903b7f048ed372..9340ec8d99ffc9cab281b45bf9855cd94d62886d 100644 --- a/lib/std/Build/CompileStep.zig +++ b/lib/std/Build/CompileStep.zig @@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default, // so it is not an EmitOption for now. emit_h: bool = false, bundle_compiler_rt: ?bool = null, -single_threaded: ?bool = null, +single_threaded: ?bool, stack_protector: ?bool = null, disable_stack_probing: bool, disable_sanitize_c: bool, @@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject), include_dirs: ArrayList(IncludeDir), c_macros: ArrayList([]const u8), installed_headers: ArrayList(*Step), -is_linking_libc: bool = false, -is_linking_libcpp: bool = false, +is_linking_libc: bool, +is_linking_libcpp: bool, vcpkg_bin_path: ?[]const u8 = null, /// This may be set in order to override the default install directory @@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void), stack_size: ?u64 = null, want_lto: ?bool = null, -use_llvm: ?bool = null, -use_lld: ?bool = null, +use_llvm: ?bool, +use_lld: ?bool, /// This is an advanced setting that can change the intent of this CompileStep. /// If this slice has nonzero length, it means that this CompileStep exists to @@ -287,6 +287,10 @@ pub const Options = struct { max_rss: usize = 0, filter: ?[]const u8 = null, test_runner: ?[]const u8 = null, + link_libc: ?bool = null, + single_threaded: ?bool = null, + use_llvm: ?bool = null, + use_lld: ?bool = null, }; pub const Kind = enum { @@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { .output_dirname_source = GeneratedFile{ .step = &self.step }, .target_info = target_info, + + .is_linking_libc = options.link_libc orelse false, + .is_linking_libcpp = false, + .single_threaded = options.single_threaded, + .use_llvm = options.use_llvm, + .use_lld = options.use_lld, }; if (self.kind == .lib) { -- 2.54.0 From 3c93c1664a3c3546076b39c2d40405f5db537dae Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 13 Apr 2023 16:44:45 -0700 Subject: [PATCH 2/8] tests: avoid skipping native tests Make the test targets use options that match the actual options of CompileStep. This makes the code more straightforward, and ends up making fewer tests incorrectly skipped. For example, now the CI runner on Windows will no longer skip self-hosted x86_64 backend tests. --- build.zig | 21 +----- test/tests.zig | 201 ++++++++++++++++++++++--------------------------- 2 files changed, 96 insertions(+), 126 deletions(-) diff --git a/build.zig b/build.zig index e41033a5279476fe3258ba80899341bc38663523..1385409ec303b0f330251d1e875c84a573725d80 100644 --- a/build.zig +++ b/build.zig @@ -85,9 +85,7 @@ pub fn build(b: *std.Build) !void { const skip_cross_glibc = b.option(bool, "skip-cross-glibc", "Main test suite skips builds that require cross glibc") orelse false; const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false; const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false; - const skip_stage1 = b.option(bool, "skip-stage1", "Main test suite skips stage1 compile error tests") orelse false; const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse false; - const skip_stage2_tests = b.option(bool, "skip-stage2-tests", "Main test suite skips self-hosted compiler tests") orelse false; const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; @@ -187,9 +185,7 @@ pub fn build(b: *std.Build) !void { const compile_step = b.step("compile", "Build the self-hosted compiler"); compile_step.dependOn(&exe.step); - if (!skip_stage2_tests) { - test_step.dependOn(&exe.step); - } + test_step.dependOn(&exe.step); exe.single_threaded = single_threaded; @@ -360,7 +356,6 @@ pub fn build(b: *std.Build) !void { test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); test_cases_options.addOption(bool, "skip_non_native", skip_non_native); test_cases_options.addOption(bool, "skip_cross_glibc", skip_cross_glibc); - test_cases_options.addOption(bool, "skip_stage1", skip_stage1); test_cases_options.addOption(bool, "have_llvm", enable_llvm); test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky); @@ -416,7 +411,7 @@ pub fn build(b: *std.Build) !void { const test_cases_step = b.step("test-cases", "Run the main compiler test cases"); try tests.addCases(b, test_cases_step, test_filter, check_case_exe); - if (!skip_stage2_tests) test_step.dependOn(test_cases_step); + test_step.dependOn(test_cases_step); test_step.dependOn(tests.addModuleTests(b, .{ .test_filter = test_filter, @@ -428,8 +423,6 @@ pub fn build(b: *std.Build) !void { .skip_non_native = skip_non_native, .skip_cross_glibc = skip_cross_glibc, .skip_libc = skip_libc, - .skip_stage1 = skip_stage1, - .skip_stage2 = skip_stage2_tests, .max_rss = 1 * 1024 * 1024 * 1024, })); @@ -443,8 +436,6 @@ pub fn build(b: *std.Build) !void { .skip_non_native = skip_non_native, .skip_cross_glibc = skip_cross_glibc, .skip_libc = true, - .skip_stage1 = skip_stage1, - .skip_stage2 = true, // TODO get all these passing })); test_step.dependOn(tests.addModuleTests(b, .{ @@ -457,8 +448,6 @@ pub fn build(b: *std.Build) !void { .skip_non_native = skip_non_native, .skip_cross_glibc = skip_cross_glibc, .skip_libc = true, - .skip_stage1 = skip_stage1, - .skip_stage2 = true, // TODO get all these passing })); test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes)); @@ -466,11 +455,11 @@ pub fn build(b: *std.Build) !void { b, optimization_modes, enable_macos_sdk, - skip_stage2_tests, + false, enable_symlinks_windows, )); test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release)); - test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows)); + test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, false, enable_symlinks_windows)); test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes)); test_step.dependOn(tests.addCliTests(b)); test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes)); @@ -489,8 +478,6 @@ pub fn build(b: *std.Build) !void { .skip_non_native = skip_non_native, .skip_cross_glibc = skip_cross_glibc, .skip_libc = skip_libc, - .skip_stage1 = skip_stage1, - .skip_stage2 = true, // TODO get all these passing // I observed a value of 3398275072 on my M1, and multiplied by 1.1 to // get this amount: .max_rss = 3738102579, diff --git a/test/tests.zig b/test/tests.zig index 18af132992b1065bfe73529a196d89308da5d9c3..490222cb6f2ded95e71f90b44fbfea54aeb2fd12 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -22,12 +22,12 @@ pub const CompareOutputContext = @import("src/CompareOutput.zig"); pub const StackTracesContext = @import("src/StackTrace.zig"); const TestTarget = struct { - target: CrossTarget = @as(CrossTarget, .{}), + target: CrossTarget = .{}, optimize_mode: std.builtin.OptimizeMode = .Debug, - link_libc: bool = false, - single_threaded: bool = false, - disable_native: bool = false, - backend: ?std.builtin.CompilerBackend = null, + link_libc: ?bool = null, + single_threaded: ?bool = null, + use_llvm: ?bool = null, + use_lld: ?bool = null, }; const test_targets = blk: { @@ -43,13 +43,47 @@ const test_targets = blk: { .{ .single_threaded = true, }, + .{ + .optimize_mode = .ReleaseFast, + }, + .{ + .link_libc = true, + .optimize_mode = .ReleaseFast, + }, + .{ + .optimize_mode = .ReleaseFast, + .single_threaded = true, + }, + + .{ + .optimize_mode = .ReleaseSafe, + }, + .{ + .link_libc = true, + .optimize_mode = .ReleaseSafe, + }, + .{ + .optimize_mode = .ReleaseSafe, + .single_threaded = true, + }, + + .{ + .optimize_mode = .ReleaseSmall, + }, + .{ + .link_libc = true, + .optimize_mode = .ReleaseSmall, + }, + .{ + .optimize_mode = .ReleaseSmall, + .single_threaded = true, + }, .{ .target = .{ .ofmt = .c, }, .link_libc = true, - .backend = .stage2_c, }, .{ .target = .{ @@ -57,22 +91,24 @@ const test_targets = blk: { .os_tag = .linux, .abi = .none, }, - .backend = .stage2_x86_64, + .use_llvm = false, + .use_lld = false, }, .{ .target = .{ .cpu_arch = .aarch64, .os_tag = .linux, }, - .backend = .stage2_aarch64, + .use_llvm = false, + .use_lld = false, }, .{ .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi, }, - .single_threaded = true, - .backend = .stage2_wasm, + .use_llvm = false, + .use_lld = false, }, // https://github.com/ziglang/zig/issues/13623 //.{ @@ -80,7 +116,8 @@ const test_targets = blk: { // .cpu_arch = .arm, // .os_tag = .linux, // }, - // .backend = .stage2_arm, + // .use_llvm = false, + // .use_lld = false, //}, // https://github.com/ziglang/zig/issues/13623 //.{ @@ -88,7 +125,8 @@ const test_targets = blk: { // .arch_os_abi = "arm-linux-none", // .cpu_features = "generic+v8a", // }) catch unreachable, - // .backend = .stage2_arm, + // .use_llvm = false, + // .use_lld = false, //}, .{ .target = .{ @@ -96,7 +134,8 @@ const test_targets = blk: { .os_tag = .macos, .abi = .none, }, - .backend = .stage2_aarch64, + .use_llvm = false, + .use_lld = false, }, .{ .target = .{ @@ -104,7 +143,8 @@ const test_targets = blk: { .os_tag = .macos, .abi = .none, }, - .backend = .stage2_x86_64, + .use_llvm = false, + .use_lld = false, }, .{ .target = .{ @@ -112,7 +152,8 @@ const test_targets = blk: { .os_tag = .windows, .abi = .gnu, }, - .backend = .stage2_x86_64, + .use_llvm = false, + .use_lld = false, }, .{ @@ -121,7 +162,6 @@ const test_targets = blk: { .os_tag = .wasi, }, .link_libc = false, - .single_threaded = true, }, .{ .target = .{ @@ -129,7 +169,6 @@ const test_targets = blk: { .os_tag = .wasi, }, .link_libc = true, - .single_threaded = true, }, .{ @@ -413,43 +452,6 @@ const test_targets = blk: { }, .link_libc = true, }, - - // Do the release tests last because they take a long time - .{ - .optimize_mode = .ReleaseFast, - }, - .{ - .link_libc = true, - .optimize_mode = .ReleaseFast, - }, - .{ - .optimize_mode = .ReleaseFast, - .single_threaded = true, - }, - - .{ - .optimize_mode = .ReleaseSafe, - }, - .{ - .link_libc = true, - .optimize_mode = .ReleaseSafe, - }, - .{ - .optimize_mode = .ReleaseSafe, - .single_threaded = true, - }, - - .{ - .optimize_mode = .ReleaseSmall, - }, - .{ - .link_libc = true, - .optimize_mode = .ReleaseSmall, - }, - .{ - .optimize_mode = .ReleaseSmall, - .single_threaded = true, - }, }; }; @@ -913,8 +915,6 @@ const ModuleTestOptions = struct { skip_non_native: bool, skip_cross_glibc: bool, skip_libc: bool, - skip_stage1: bool, - skip_stage2: bool, max_rss: usize = 0, }; @@ -922,49 +922,41 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc); for (test_targets) |test_target| { - if (options.skip_non_native and !test_target.target.isNative()) + const is_native = test_target.target.isNative() or + (test_target.target.getOsTag() == builtin.os.tag and + test_target.target.getCpuArch() == builtin.cpu.arch); + + if (options.skip_non_native and !is_native) continue; - if (options.skip_cross_glibc and test_target.target.isGnuLibC() and test_target.link_libc) + if (options.skip_cross_glibc and test_target.target.isGnuLibC() and test_target.link_libc == true) continue; - if (options.skip_libc and test_target.link_libc) + if (options.skip_libc and test_target.link_libc == true) continue; - if (test_target.link_libc and test_target.target.getOs().requiresLibC()) { - // This would be a redundant test. + if (options.skip_single_threaded and test_target.single_threaded == true) continue; - } - if (options.skip_single_threaded and test_target.single_threaded) + // TODO get compiler-rt tests passing for self-hosted backends. + if (test_target.use_llvm == false and mem.eql(u8, options.name, "compiler-rt")) continue; - if (test_target.disable_native and - test_target.target.getOsTag() == builtin.os.tag and - test_target.target.getCpuArch() == builtin.cpu.arch) - { + // TODO get universal-libc tests passing for self-hosted backends. + if (test_target.use_llvm == false and mem.eql(u8, options.name, "universal-libc")) continue; - } - if (test_target.backend) |backend| switch (backend) { - .stage1 => if (options.skip_stage1) continue, - .stage2_llvm => {}, - else => if (options.skip_stage2) continue, - }; + // TODO get std lib tests passing for self-hosted backends. + if (test_target.use_llvm == false and mem.eql(u8, options.name, "std")) + continue; const want_this_mode = for (options.optimize_modes) |m| { if (m == test_target.optimize_mode) break true; } else false; if (!want_this_mode) continue; - const libc_prefix = if (test_target.target.getOs().requiresLibC()) - "" - else if (test_target.link_libc) - "c" - else - "bare"; - - const triple_prefix = test_target.target.zigTriple(b.allocator) catch @panic("OOM"); + const libc_suffix = if (test_target.link_libc == true) "-libc" else ""; + const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM"); // wasm32-wasi builds need more RAM, idk why const max_rss = if (test_target.target.getOs().tag == .wasi) @@ -978,42 +970,33 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { .target = test_target.target, .max_rss = max_rss, .filter = options.test_filter, + .link_libc = test_target.link_libc, + .single_threaded = test_target.single_threaded, + .use_llvm = test_target.use_llvm, + .use_lld = test_target.use_lld, }); - const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; - const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default"; - these_tests.single_threaded = test_target.single_threaded; - if (test_target.link_libc) { - these_tests.linkSystemLibrary("c"); - } + const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else ""; + const backend_suffix = if (test_target.use_llvm == true) + "-llvm" + else if (test_target.target.ofmt == std.Target.ObjectFormat.c) + "-cbe" + else if (test_target.use_llvm == false) + "-selfhosted" + else + ""; + these_tests.overrideZigLibDir("lib"); these_tests.addIncludePath("test"); - if (test_target.backend) |backend| switch (backend) { - .stage1 => { - @panic("stage1 testing requested"); - }, - .stage2_llvm => { - these_tests.use_llvm = true; - }, - .stage2_c => { - these_tests.use_llvm = false; - }, - else => { - these_tests.use_llvm = false; - // TODO: force self-hosted linkers to avoid LLD creeping in - // until the auto-select mechanism deems them worthy - these_tests.use_lld = false; - }, - }; const run = b.addRunArtifact(these_tests); run.skip_foreign_checks = true; - run.setName(b.fmt("run test {s}-{s}-{s}-{s}-{s}-{s}", .{ + run.setName(b.fmt("run test {s}-{s}-{s}{s}{s}{s}", .{ options.name, - triple_prefix, + triple_txt, @tagName(test_target.optimize_mode), - libc_prefix, - single_threaded_txt, - backend_txt, + libc_suffix, + single_threaded_suffix, + backend_suffix, })); step.dependOn(&run.step); -- 2.54.0 From 4a233d18717e0f5729218e02eebf29ad46449a38 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 13 Apr 2023 17:22:53 -0700 Subject: [PATCH 3/8] CI: more C backend test coverage The CI now runs C backend tests in addition to compiling them. It uses -std=c99 -pedantic -Werror in order to catch non-conformant C code. This necessitated disabling a test case that caused a C compile error, in addition to disabling a handful of warnings that are already being triggered by Zig's C backend output for the behavior tests. The upshot is that I was able to, very cleanly, integrate the C backend tests into the build system, so that it communicates via the test runner protocol along with all the other behavior tests. --- lib/std/Build.zig | 3 +-- lib/std/Build/RunStep.zig | 5 ++++ lib/std/zig/Server.zig | 12 +++------ test/behavior/atomics.zig | 6 +++++ test/tests.zig | 51 +++++++++++++++++++++++++++++++++++---- 5 files changed, 62 insertions(+), 15 deletions(-) diff --git a/lib/std/Build.zig b/lib/std/Build.zig index 0cade2b6f33f3fe10c5c057261aa0cae1917b061..34806adf488f1890a80b006b2296bd1420efb130 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -679,8 +679,7 @@ pub fn addRunArtifact(b: *Build, exe: *CompileStep) *RunStep { run_step.addArtifactArg(exe); if (exe.kind == .@"test") { - run_step.stdio = .zig_test; - run_step.addArgs(&.{"--listen=-"}); + run_step.enableTestRunnerMode(); } if (exe.vcpkg_bin_path) |path| { diff --git a/lib/std/Build/RunStep.zig b/lib/std/Build/RunStep.zig index 5658c5936fd9dfeed4d6eb35c8995d1c89fc626b..9d1fd85e39473b9017d348a1f67692ca83b2fb51 100644 --- a/lib/std/Build/RunStep.zig +++ b/lib/std/Build/RunStep.zig @@ -140,6 +140,11 @@ pub fn setName(self: *RunStep, name: []const u8) void { self.rename_step_with_output_arg = false; } +pub fn enableTestRunnerMode(rs: *RunStep) void { + rs.stdio = .zig_test; + rs.addArgs(&.{"--listen=-"}); +} + pub fn addArtifactArg(self: *RunStep, artifact: *CompileStep) void { self.argv.append(Arg{ .artifact = artifact }) catch @panic("OOM"); self.step.dependOn(&artifact.step); diff --git a/lib/std/zig/Server.zig b/lib/std/zig/Server.zig index 788e36178244e1414b35ce978864ec9a575783b0..0c099744ccb96dbb4f63d3caf8a2cbd459820c30 100644 --- a/lib/std/zig/Server.zig +++ b/lib/std/zig/Server.zig @@ -104,11 +104,9 @@ pub fn receiveMessage(s: *Server) !InMessage.Header { const buf = fifo.readableSlice(0); assert(fifo.readableLength() == buf.len); if (buf.len >= @sizeOf(Header)) { - const header = @ptrCast(*align(1) const Header, buf[0..@sizeOf(Header)]); // workaround for https://github.com/ziglang/zig/issues/14904 - const bytes_len = bswap_and_workaround_u32(&header.bytes_len); - // workaround for https://github.com/ziglang/zig/issues/14904 - const tag = bswap_and_workaround_tag(&header.tag); + const bytes_len = bswap_and_workaround_u32(buf[4..][0..4]); + const tag = bswap_and_workaround_tag(buf[0..][0..4]); if (buf.len - @sizeOf(Header) >= bytes_len) { fifo.discard(@sizeOf(Header)); @@ -281,14 +279,12 @@ fn bswap_u32_array(slice: []u32) void { } /// workaround for https://github.com/ziglang/zig/issues/14904 -fn bswap_and_workaround_u32(x: *align(1) const u32) u32 { - const bytes_ptr = @ptrCast(*const [4]u8, x); +fn bswap_and_workaround_u32(bytes_ptr: *const [4]u8) u32 { return std.mem.readIntLittle(u32, bytes_ptr); } /// workaround for https://github.com/ziglang/zig/issues/14904 -fn bswap_and_workaround_tag(x: *align(1) const InMessage.Tag) InMessage.Tag { - const bytes_ptr = @ptrCast(*const [4]u8, x); +fn bswap_and_workaround_tag(bytes_ptr: *const [4]u8) InMessage.Tag { const int = std.mem.readIntLittle(u32, bytes_ptr); return @intToEnum(InMessage.Tag, int); } diff --git a/test/behavior/atomics.zig b/test/behavior/atomics.zig index 04dd2661bb0d6ee0a32a5e925eba59a9d463a04f..6b6e7c8430dd59533223bf256dbcba017f40773b 100644 --- a/test/behavior/atomics.zig +++ b/test/behavior/atomics.zig @@ -209,6 +209,12 @@ test "atomicrmw with floats" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_c) { + // TODO: test.c:34929:7: error: address argument to atomic operation must be a pointer to integer or pointer ('zig_f32 *' (aka 'float *') invalid + // when compiling with -std=c99 -pedantic + return error.SkipZigTest; + } + if ((builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) and builtin.cpu.arch == .aarch64) { diff --git a/test/tests.zig b/test/tests.zig index 490222cb6f2ded95e71f90b44fbfea54aeb2fd12..02eca3ed19e32a5062169386af898b7e5d82b7ed 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -988,18 +988,59 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { these_tests.overrideZigLibDir("lib"); these_tests.addIncludePath("test"); - const run = b.addRunArtifact(these_tests); - run.skip_foreign_checks = true; - run.setName(b.fmt("run test {s}-{s}-{s}{s}{s}{s}", .{ + const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}", .{ options.name, triple_txt, @tagName(test_target.optimize_mode), libc_suffix, single_threaded_suffix, backend_suffix, - })); + }); - step.dependOn(&run.step); + if (test_target.target.ofmt == std.Target.ObjectFormat.c) { + var altered_target = test_target.target; + altered_target.ofmt = null; + + const compile_c = b.addExecutable(.{ + .name = qualified_name, + .link_libc = test_target.link_libc, + .target = altered_target, + }); + compile_c.overrideZigLibDir("lib"); + compile_c.addCSourceFileSource(.{ + .source = these_tests.getOutputSource(), + .args = &.{ + // TODO output -std=c89 compatible C code + "-std=c99", + "-pedantic", + "-Werror", + // TODO stop violating these pedantic errors + "-Wno-address-of-packed-member", + "-Wno-gnu-folding-constant", + "-Wno-incompatible-pointer-types", + "-Wno-overlength-strings", + }, + }); + compile_c.addIncludePath("lib"); // for zig.h + if (test_target.link_libc == false and test_target.target.getOsTag() == .windows) { + compile_c.subsystem = .Console; + compile_c.linkSystemLibrary("kernel32"); + compile_c.linkSystemLibrary("ntdll"); + } + + const run = b.addRunArtifact(compile_c); + run.skip_foreign_checks = true; + run.enableTestRunnerMode(); + run.setName(b.fmt("run test {s}", .{qualified_name})); + + step.dependOn(&run.step); + } else { + const run = b.addRunArtifact(these_tests); + run.skip_foreign_checks = true; + run.setName(b.fmt("run test {s}", .{qualified_name})); + + step.dependOn(&run.step); + } } return step; } -- 2.54.0 From 9b631b2b32c963535f33321b0ab5d91a211235f7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 14 Apr 2023 13:06:01 -0700 Subject: [PATCH 4/8] compiler_rt: use default visibility for non-exported symbols --- lib/compiler_rt/common.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/compiler_rt/common.zig b/lib/compiler_rt/common.zig index ec4f545f37879c8c8492cc16c2fb7f3a3c8d8191..eaabffa07390dc0a712cc66ca1660ae3129a53ee 100644 --- a/lib/compiler_rt/common.zig +++ b/lib/compiler_rt/common.zig @@ -6,7 +6,8 @@ pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal el /// Determines the symbol's visibility to other objects. /// For WebAssembly this allows the symbol to be resolved to other modules, but will not /// export it to the host runtime. -pub const visibility: std.builtin.SymbolVisibility = if (builtin.target.isWasm()) .hidden else .default; +pub const visibility: std.builtin.SymbolVisibility = + if (builtin.target.isWasm() and linkage != .Internal) .hidden else .default; pub const want_aeabi = switch (builtin.abi) { .eabi, .eabihf, -- 2.54.0 From 29c8d93b820b5b8cd66d77b3c983f1c665e5884b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 14 Apr 2023 13:06:22 -0700 Subject: [PATCH 5/8] disable not-yet-passing test suites * wasm32-wasi compiler_rt tests * std lib tests with the C backend --- test/tests.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/tests.zig b/test/tests.zig index 02eca3ed19e32a5062169386af898b7e5d82b7ed..e80454933e7f01bf971c161c56c2c856374947fb 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -942,6 +942,15 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { if (test_target.use_llvm == false and mem.eql(u8, options.name, "compiler-rt")) continue; + // TODO get compiler-rt tests passing for wasm32-wasi + // currently causes "LLVM ERROR: Unable to expand fixed point multiplication." + if (test_target.target.getCpuArch() == .wasm32 and + test_target.target.getOsTag() == .wasi and + mem.eql(u8, options.name, "compiler-rt")) + { + continue; + } + // TODO get universal-libc tests passing for self-hosted backends. if (test_target.use_llvm == false and mem.eql(u8, options.name, "universal-libc")) continue; @@ -950,6 +959,13 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { if (test_target.use_llvm == false and mem.eql(u8, options.name, "std")) continue; + // TODO get std lib tests passing for the C backend + if (test_target.target.ofmt == std.Target.ObjectFormat.c and + mem.eql(u8, options.name, "std")) + { + continue; + } + const want_this_mode = for (options.optimize_modes) |m| { if (m == test_target.optimize_mode) break true; } else false; -- 2.54.0 From a281d298816b6881e16ebfabb3743526bd8a1577 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 14 Apr 2023 13:07:34 -0700 Subject: [PATCH 6/8] disable not-yet-passing C backend tests --- test/behavior/bugs/12680.zig | 4 ++++ test/behavior/cast.zig | 15 +++++++++++++++ test/behavior/floatop.zig | 25 +++++++++++++++++++++++++ test/behavior/math.zig | 26 ++++++++++++++++++++++++++ test/behavior/muladd.zig | 10 ++++++++++ test/behavior/vector.zig | 5 +++++ test/behavior/widening.zig | 10 ++++++++++ test/tests.zig | 5 ++++- 8 files changed, 99 insertions(+), 1 deletion(-) diff --git a/test/behavior/bugs/12680.zig b/test/behavior/bugs/12680.zig index 0f31b66f45cf344ffc940331e767658ede49163a..362e03f8a813f2e1103322e9895f57f01c7cd082 100644 --- a/test/behavior/bugs/12680.zig +++ b/test/behavior/bugs/12680.zig @@ -11,6 +11,10 @@ test "export a function twice" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { + // TODO: test.c: error: aliases are not supported on darwin + return error.SkipZigTest; + } // If it exports the function correctly, `test_func` and `testFunc` will points to the same address. try expectEqual(test_func(), other_file.testFunc()); diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 16efe710e353e973dca606ce7acbbc3c3f860490..455dab47662065c780b6295076b9d5c58e1cbf07 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -1313,6 +1313,11 @@ test "cast f16 to wider types" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + const S = struct { fn doTheTest() !void { var x: f16 = 1234.0; @@ -1339,6 +1344,11 @@ test "cast f128 to narrower types" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + const S = struct { fn doTheTest() !void { var x: f128 = 1234.0; @@ -1429,6 +1439,11 @@ test "coerce between pointers of compatible differently-named floats" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + const F = switch (@typeInfo(c_longdouble).Float.bits) { 16 => f16, 32 => f32, diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index f95840abeefc68fc1d3082986b64637f2c4e2957..da1667b077427a4baef3067eae7ae1aea01370cc 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -542,6 +542,11 @@ test "another, possibly redundant, @fabs test" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + try testFabsLegacy(f128, 12.0); comptime try testFabsLegacy(f128, 12.0); try testFabsLegacy(f64, 12.0); @@ -586,6 +591,11 @@ test "a third @fabs test, surely there should not be three fabs tests" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| { // normals try expect(@fabs(@as(T, 1.0)) == 1.0); @@ -688,6 +698,11 @@ test "@floor f128" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + try testFloorLegacy(f128, 12.0); comptime try testFloorLegacy(f128, 12.0); } @@ -874,6 +889,11 @@ test "@trunc f128" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + try testTruncLegacy(f128, 12.0); comptime try testTruncLegacy(f128, 12.0); } @@ -992,6 +1012,11 @@ test "negation f128" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + const S = struct { fn doTheTest() !void { var a: f128 = 1; diff --git a/test/behavior/math.zig b/test/behavior/math.zig index 9e3c2b02fd0a2227e3e79a7dc6f5e34248bf8682..b69ac04d402b06332344ab84518d3adf9b999718 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -622,6 +622,11 @@ test "f128" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + try test_f128(); comptime try test_f128(); } @@ -1299,6 +1304,11 @@ test "remainder division" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + comptime try remdiv(f16); comptime try remdiv(f32); comptime try remdiv(f64); @@ -1445,6 +1455,11 @@ test "@round f128" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + try testRound(f128, 12.0); comptime try testRound(f128, 12.0); } @@ -1490,6 +1505,11 @@ test "NaN comparison" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + try testNanEqNan(f16); try testNanEqNan(f32); try testNanEqNan(f64); @@ -1562,6 +1582,12 @@ test "signed zeros are represented properly" { if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and builtin.zig_backend == .stage2_c) { + // TODO: test is failing + return error.SkipZigTest; + } + + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing return error.SkipZigTest; } diff --git a/test/behavior/muladd.zig b/test/behavior/muladd.zig index e698b4615c95d35499295f569ab0c725f66fd853..35bf4ce49679cd6a6c32e551c794c2857cfff459 100644 --- a/test/behavior/muladd.zig +++ b/test/behavior/muladd.zig @@ -75,6 +75,11 @@ test "@mulAdd f128" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + comptime try testMulAdd128(); try testMulAdd128(); } @@ -203,6 +208,11 @@ test "vector f128" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + comptime try vector128(); try vector128(); } diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig index 9c58fd1a36352c18f841ce1fe9e2ed3f2a5231cb..49ed0a619f35ea55b4367d1cbefa982d718486fd 100644 --- a/test/behavior/vector.zig +++ b/test/behavior/vector.zig @@ -103,6 +103,11 @@ test "vector float operators" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { const S = struct { fn doTheTest() !void { diff --git a/test/behavior/widening.zig b/test/behavior/widening.zig index 0992943fc3b4bbc21103e6ce5bd9696abe2071e6..249cbb6648ba14231a8da5f27a3df0d22a419581 100644 --- a/test/behavior/widening.zig +++ b/test/behavior/widening.zig @@ -50,6 +50,11 @@ test "float widening" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + var a: f16 = 12.34; var b: f32 = a; var c: f64 = b; @@ -77,6 +82,11 @@ test "float widening f16 to f128" { return error.SkipZigTest; } + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + // TODO: test is failing + return error.SkipZigTest; + } + var x: f16 = 12.34; var y: f128 = x; try expect(x == y); diff --git a/test/tests.zig b/test/tests.zig index e80454933e7f01bf971c161c56c2c856374947fb..207b3db9f84377527d4016bebe00e8df50990ccf 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -1030,11 +1030,14 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { "-std=c99", "-pedantic", "-Werror", - // TODO stop violating these pedantic errors + // TODO stop violating these pedantic errors. spotted on linux "-Wno-address-of-packed-member", "-Wno-gnu-folding-constant", "-Wno-incompatible-pointer-types", "-Wno-overlength-strings", + // TODO stop violating these pedantic errors. spotted on darwin + "-Wno-dollar-in-identifier-extension", + "-Wno-absolute-value", }, }); compile_c.addIncludePath("lib"); // for zig.h -- 2.54.0 From e9d854743aba390d757e56714e2b323e99e5722b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 15 Apr 2023 10:32:54 -0700 Subject: [PATCH 7/8] disable more failing C backend tests --- test/behavior/cast.zig | 9 +++++++-- test/behavior/floatop.zig | 20 +++++++++++++++----- test/behavior/math.zig | 18 ++++++++++++++---- test/behavior/muladd.zig | 2 +- test/behavior/vector.zig | 2 +- test/behavior/widening.zig | 4 ++-- 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 455dab47662065c780b6295076b9d5c58e1cbf07..642d4cd18e32826a51eb11d79edacbe597c8fc3b 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -1313,7 +1313,12 @@ test "cast f16 to wider types" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { + // TODO: test is failing + return error.SkipZigTest; + } + + if (builtin.os.tag == .windows and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { // TODO: test is failing return error.SkipZigTest; } @@ -1344,7 +1349,7 @@ test "cast f128 to narrower types" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index da1667b077427a4baef3067eae7ae1aea01370cc..c4f1168efc5f8691b80327203242c8a4c128fbc1 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -542,7 +542,7 @@ test "another, possibly redundant, @fabs test" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -591,7 +591,7 @@ test "a third @fabs test, surely there should not be three fabs tests" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -698,7 +698,7 @@ test "@floor f128" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -793,6 +793,11 @@ test "@ceil f128" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) { + // TODO: test is failing + return error.SkipZigTest; + } + try testCeilLegacy(f128, 12.0); comptime try testCeilLegacy(f128, 12.0); } @@ -889,7 +894,7 @@ test "@trunc f128" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -1012,7 +1017,7 @@ test "negation f128" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -1060,6 +1065,11 @@ test "comptime fixed-width float zero divided by zero produces NaN" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) { + // TODO: test is failing + return error.SkipZigTest; + } + inline for (.{ f16, f32, f64, f80, f128 }) |F| { try expect(math.isNan(@as(F, 0) / @as(F, 0))); } diff --git a/test/behavior/math.zig b/test/behavior/math.zig index b69ac04d402b06332344ab84518d3adf9b999718..5da24f77477f54f47b59ba427e8bddb2b680a6d2 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -622,7 +622,7 @@ test "f128" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -1304,7 +1304,7 @@ test "remainder division" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -1340,6 +1340,11 @@ test "float remainder division using @rem" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) { + // TODO: test is failing + return error.SkipZigTest; + } + comptime try frem(f16); comptime try frem(f32); comptime try frem(f64); @@ -1382,6 +1387,11 @@ test "float modulo division using @mod" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) { + // TODO: test is failing + return error.SkipZigTest; + } + comptime try fmod(f16); comptime try fmod(f32); comptime try fmod(f64); @@ -1455,7 +1465,7 @@ test "@round f128" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -1505,7 +1515,7 @@ test "NaN comparison" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } diff --git a/test/behavior/muladd.zig b/test/behavior/muladd.zig index 35bf4ce49679cd6a6c32e551c794c2857cfff459..abc251ecbdded2c0d30faed2d5116bda1f05291d 100644 --- a/test/behavior/muladd.zig +++ b/test/behavior/muladd.zig @@ -75,7 +75,7 @@ test "@mulAdd f128" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig index 49ed0a619f35ea55b4367d1cbefa982d718486fd..8875f60eb7e31522ca94944ba5aceb04ec588765 100644 --- a/test/behavior/vector.zig +++ b/test/behavior/vector.zig @@ -103,7 +103,7 @@ test "vector float operators" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } diff --git a/test/behavior/widening.zig b/test/behavior/widening.zig index 249cbb6648ba14231a8da5f27a3df0d22a419581..5638446cb841e35abe614cfbced8e99f065fb9c9 100644 --- a/test/behavior/widening.zig +++ b/test/behavior/widening.zig @@ -50,7 +50,7 @@ test "float widening" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } @@ -82,7 +82,7 @@ test "float widening f16 to f128" { return error.SkipZigTest; } - if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { + if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) { // TODO: test is failing return error.SkipZigTest; } -- 2.54.0 From 9e6647582da0d7cbf8a441cefea0bb9fae18bb5c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 15 Apr 2023 12:45:47 -0700 Subject: [PATCH 8/8] disable x86_64-windows self-hosted backend behavior tests because they are not passing on the CI yet. --- test/tests.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/tests.zig b/test/tests.zig index 207b3db9f84377527d4016bebe00e8df50990ccf..cb5e848200d9552bf1a81e816513b9f2638086ed 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -942,6 +942,14 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { if (test_target.use_llvm == false and mem.eql(u8, options.name, "compiler-rt")) continue; + // TODO get the x86_64 self-hosted backend tests passing on Windows + if (test_target.target.getCpuArch() == .x86_64 and + test_target.target.getOsTag() == .windows and + test_target.use_llvm == false) + { + continue; + } + // TODO get compiler-rt tests passing for wasm32-wasi // currently causes "LLVM ERROR: Unable to expand fixed point multiplication." if (test_target.target.getCpuArch() == .wasm32 and -- 2.54.0