diff --git a/build.zig b/build.zig index b4172e5893c1502422705f1687b7f2e03b934458..c914d0f161f818a493d933c77dba7884258a4921 100644 --- a/build.zig +++ b/build.zig @@ -233,7 +233,6 @@ pub fn build(b: *std.Build) !void { exe.root_module.addOptions("build_options", exe_options); exe_options.addOption(u32, "mem_leak_frames", mem_leak_frames); - exe_options.addOption(bool, "skip_non_native", skip_non_native); exe_options.addOption(bool, "have_llvm", enable_llvm); exe_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); exe_options.addOption(bool, "llvm_has_csky", llvm_has_csky); diff --git a/lib/std/math.zig b/lib/std/math.zig index 0df59050ce6e42fc42be3c420efcadf464b231eb..5487e0cb37520ec415f7db1a712c88a8e1f2e9c1 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -461,6 +461,11 @@ pub fn wrap(x: anytype, r: anytype) @TypeOf(x) { } } test wrap { + if (builtin.os.tag == .windows and builtin.cpu.arch == .x86) { + // https://codeberg.org/ziglang/zig/issues/35520 + return error.SkipZigTest; + } + // Within range try testing.expect(wrap(@as(i32, -75), @as(i32, 180)) == -75); try testing.expect(wrap(@as(i32, -75), @as(i32, -180)) == -75); diff --git a/lib/std/math/isnan.zig b/lib/std/math/isnan.zig index cbfe15a2fd6a37dbe4cd963bdc2310f36c75f60d..bf2af9be1db7472aaceae82c3d052e606ce454b7 100644 --- a/lib/std/math/isnan.zig +++ b/lib/std/math/isnan.zig @@ -29,6 +29,11 @@ test isNan { test isSignalNan { if (builtin.zig_backend == .stage2_x86_64 and builtin.object_format == .coff and builtin.abi != .gnu) return error.SkipZigTest; + if (builtin.os.tag == .windows) { + // https://codeberg.org/ziglang/zig/issues/35519 + return error.SkipZigTest; + } + inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| { // TODO: Signalling NaN values get converted to quiet NaN values in // some cases where they shouldn't such that this can fail. diff --git a/src/link/Elf.zig b/src/link/Elf.zig index f59e4d859752182b347033592ec26bc9118a46e7..3b582bf8228e2c4a8fcb11799bab254ea9c398b4 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1691,9 +1691,6 @@ pub fn updateFunc( func_index: InternPool.Index, mir: *const codegen.AnyMir, ) link.File.UpdateNavError!void { - if (build_options.skip_non_native and builtin.object_format != .elf) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } return self.zigObjectPtr().?.updateFunc(self, pt, func_index, mir); } @@ -1702,9 +1699,6 @@ pub fn updateNav( pt: Zcu.PerThread, nav: InternPool.Nav.Index, ) link.File.UpdateNavError!void { - if (build_options.skip_non_native and builtin.object_format != .elf) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } return self.zigObjectPtr().?.updateNav(self, pt, nav); } @@ -1714,9 +1708,6 @@ pub fn updateContainerType( ty: InternPool.Index, success: bool, ) link.File.UpdateContainerTypeError!void { - if (build_options.skip_non_native and builtin.object_format != .elf) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } return self.zigObjectPtr().?.updateContainerType(pt, ty, success) catch |err| switch (err) { error.OutOfMemory => |e| return e, }; @@ -1728,9 +1719,6 @@ pub fn updateExports( exported: Zcu.Exported, export_indices: []const Zcu.Export.Index, ) link.File.UpdateExportsError!void { - if (build_options.skip_non_native and builtin.object_format != .elf) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } return self.zigObjectPtr().?.updateExports(self, pt, exported, export_indices); } diff --git a/src/link/MachO.zig b/src/link/MachO.zig index ec22c9e07036ae7cc9396be27e09e2ec67f31393..02f599e591cf36a6ac2a24630b2f794635495797 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -3075,16 +3075,10 @@ pub fn updateFunc( func_index: InternPool.Index, mir: *const codegen.AnyMir, ) link.File.UpdateNavError!void { - if (build_options.skip_non_native and builtin.object_format != .macho) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } return self.getZigObject().?.updateFunc(self, pt, func_index, mir); } pub fn updateNav(self: *MachO, pt: Zcu.PerThread, nav: InternPool.Nav.Index) link.File.UpdateNavError!void { - if (build_options.skip_non_native and builtin.object_format != .macho) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } return self.getZigObject().?.updateNav(self, pt, nav); } @@ -3098,9 +3092,6 @@ pub fn updateExports( exported: Zcu.Exported, export_indices: []const Zcu.Export.Index, ) link.File.UpdateExportsError!void { - if (build_options.skip_non_native and builtin.object_format != .macho) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } return self.getZigObject().?.updateExports(self, pt, exported, export_indices); } diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 2a22e88efe7d10b3cfa4ecd0748890bf8b707d61..72119160c459bc77eeb80a0ffefbc966e29caf08 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -3192,10 +3192,6 @@ pub fn updateFunc( func_index: InternPool.Index, any_mir: *const codegen.AnyMir, ) !void { - if (build_options.skip_non_native and builtin.object_format != .wasm) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } - dev.check(.wasm_backend); // This linker implementation only works with codegen backend `.stage2_wasm`. @@ -3279,9 +3275,6 @@ pub fn updateFunc( // Generate code for the "Nav", storing it in memory to be later written to // the file on flush(). pub fn updateNav(wasm: *Wasm, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) !void { - if (build_options.skip_non_native and builtin.object_format != .wasm) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } const zcu = pt.zcu; const ip = &zcu.intern_pool; const nav = ip.getNav(nav_index); @@ -3378,10 +3371,6 @@ pub fn updateExports( exported: Zcu.Exported, export_indices: []const Zcu.Export.Index, ) !void { - if (build_options.skip_non_native and builtin.object_format != .wasm) { - @panic("Attempted to compile for object format that was disabled by build configuration"); - } - const zcu = pt.zcu; const gpa = zcu.gpa; const ip = &zcu.intern_pool; diff --git a/test/behavior/align.zig b/test/behavior/align.zig index 55eb1c604e8831b5b65fe51cb082b97cee81bd3b..3de3dd090670331c27e4856e90246483546a2432 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -29,6 +29,11 @@ test "large alignment of local constant" { if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; // flaky if (builtin.zig_backend == .stage2_c and builtin.target.abi == .msvc) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64 and builtin.os.tag == .windows) { + // https://codeberg.org/ziglang/zig/issues/35537 + return error.SkipZigTest; + } + const x: f32 align(128) = 12.34; try std.testing.expect(@intFromPtr(&x) % 128 == 0); } diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index 44e6abe4a2fbb8fcdba707ea5cc211ec02fbcb6f..693656095332986f1062f0dd546acbe23c2bf8ff 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -948,6 +948,11 @@ test "@log2 with vectors" { builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) return error.SkipZigTest; + if (builtin.os.tag == .windows and builtin.cpu.arch == .x86) { + // https://codeberg.org/ziglang/zig/issues/35518 + return error.SkipZigTest; + } + try testLog2WithVectors(); try comptime testLog2WithVectors(); } diff --git a/test/src/Cases.zig b/test/src/Cases.zig index 2cc37fb656b8906887f5c0928787e9627d57cc1c..9ffc5ec61645f2ecc6364389b63b58e2b5717935 100644 --- a/test/src/Cases.zig +++ b/test/src/Cases.zig @@ -481,7 +481,7 @@ pub fn lowerToBuildSteps( if (case.case.? == .Error and options.skip_compile_errors) continue; - if (options.skip_non_native and !case.target.query.isNative()) + if (options.skip_non_native and !@import("../tests.zig").isNative(&case.target, &b.graph.host.result)) continue; if (options.skip_spirv and case.target.query.cpu_arch != null and case.target.query.cpu_arch.?.isSpirV()) continue; diff --git a/test/tests.zig b/test/tests.zig index 9fbb4c90b195e13c6bd89ebe443dc312521b1643..2ec14e0f618f2094f6d537db17646eb6ccda9004 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -200,6 +200,7 @@ const module_test_targets = blk: { // .use_lld = false, // .optimize_mode = .ReleaseFast, // .strip = true, + // .skip_modules = &.{"std"}, // TODO get these passing //}, //.{ // .target = .{ @@ -212,6 +213,7 @@ const module_test_targets = blk: { // .use_lld = false, // .optimize_mode = .ReleaseFast, // .strip = true, + // .skip_modules = &.{"std"}, // TODO get these passing //}, .{ @@ -1609,6 +1611,8 @@ const module_test_targets = blk: { .abi = .msvc, }, .link_libc = true, + // https://codeberg.org/ziglang/zig/issues/35517 + .skip_modules = &.{"libc"}, }, .{ .target = .{ @@ -1624,6 +1628,8 @@ const module_test_targets = blk: { .abi = .gnu, }, .link_libc = true, + // https://codeberg.org/ziglang/zig/issues/35517 + .skip_modules = &.{"libc"}, }, .{ @@ -1634,6 +1640,8 @@ const module_test_targets = blk: { }, .use_llvm = false, .use_lld = false, + // https://codeberg.org/ziglang/zig/issues/35537 + .skip_modules = &.{"behavior"}, }, .{ .target = .{ @@ -1649,6 +1657,8 @@ const module_test_targets = blk: { .abi = .msvc, }, .link_libc = true, + // https://codeberg.org/ziglang/zig/issues/35517 + .skip_modules = &.{"libc"}, }, .{ .target = .{ @@ -1989,13 +1999,14 @@ const c_abi_targets = blk: { // Windows Targets - .{ - .target = .{ - .cpu_arch = .x86, - .os_tag = .windows, - .abi = .gnu, - }, - }, + // https://codeberg.org/ziglang/zig/issues/35521 + //.{ + // .target = .{ + // .cpu_arch = .x86, + // .os_tag = .windows, + // .abi = .gnu, + // }, + //}, .{ .target = .{ .cpu_arch = .x86_64, @@ -2026,8 +2037,7 @@ const incremental_targets: []const []const u8 = &.{ //"wasm32-wasi-selfhosted", }; -fn compatible32bitArch(b: *std.Build) ?std.Target.Cpu.Arch { - const host = b.graph.host.result; +fn compatible32bitArch(host: *const std.Target) ?std.Target.Cpu.Arch { return switch (host.os.tag) { .windows => switch (host.cpu.arch) { .x86_64 => .x86, @@ -2050,6 +2060,108 @@ fn compatible32bitArch(b: *std.Build) ?std.Target.Cpu.Arch { }; } +pub fn isNative(actual_target: *const std.Build.ResolvedTarget, host: *const std.Target) bool { + if (actual_target.query.isNative()) return true; + const actual = &actual_target.result; + + if (actual.cpu.arch != host.cpu.arch and + actual.cpu.arch != compatible32bitArch(host)) + { + return false; + } + + if (actual.os.tag != host.os.tag) + return false; + + // Remove features that don't actually affect compatibility. + const irrelevant: std.Target.Cpu.Feature.Set = switch (host.cpu.arch) { + .x86_64 => std.Target.x86.featureSet(&.{ + .@"16bit_mode", + .@"32bit_mode", + .@"64bit", + .false_deps_getmant, + .false_deps_lzcnt_tzcnt, + .false_deps_mulc, + .false_deps_mullq, + .false_deps_perm, + .false_deps_popcnt, + .false_deps_range, + .fast_11bytenop, + .fast_15bytenop, + .fast_7bytenop, + .fast_bextr, + .fast_dpwssd, + .fast_gather, + .fast_hops, + .fast_imm16, + .fast_lzcnt, + .fast_movbe, + .fast_scalar_fsqrt, + .fast_scalar_shift_masks, + .fast_shld_rotate, + .fast_variable_crosslane_shuffle, + .fast_variable_perlane_shuffle, + .fast_vector_fsqrt, + .fast_vector_shift_masks, + .faster_shift_than_shuffle, + .no_bypass_delay, + .no_bypass_delay_blend, + .no_bypass_delay_mov, + .no_bypass_delay_shuffle, + .prefer_128_bit, + .prefer_256_bit, + .prefer_legacy_setcc, + .prefer_mask_registers, + .prefer_movmsk_over_vtest, + .prefer_no_gather, + .prefer_no_scatter, + .slow_3ops_lea, + .slow_incdec, + .slow_lea, + .slow_pmaddwd, + .slow_pmulld, + .slow_pmullq, + .slow_shld, + .slow_two_mem_ops, + .slow_unaligned_mem_16, + .slow_unaligned_mem_32, + }), + .aarch64, .aarch64_be => std.Target.aarch64.featureSet(&.{ + .addr_lsl_slow_14, + .alu_lsl_fast, + .avoid_ldapur, + .disable_fast_inc_vl, + .exynos_cheap_as_move, + .fuse_address, + .fuse_addsub_2reg_const1, + .fuse_adrp_add, + .fuse_aes, + .fuse_arith_logic, + .fuse_crypto_eor, + .fuse_csel, + .fuse_cset, + .fuse_literals, + .predictable_select_expensive, + .slow_misaligned_128store, + .slow_paired_128, + .slow_strqro_store, + .use_experimental_zeroing_pseudos, + .use_fixed_over_scalable_if_equal_cost, + .use_postra_scheduler, + .use_reciprocal_square_root, + .use_wzr_to_vec_move, + }), + else => .empty, + }; + var set = actual.cpu.features; + set.removeFeatureSet(irrelevant); + + if (!host.cpu.features.isSuperSetOf(set)) + return false; + + return true; +} + /// For stack trace tests, we only test native by default, because external executors are pretty /// unreliable at stack tracing. However, if there's a 32-bit equivalent target which the host can /// trivially run, we may as well at least test that! @@ -2057,7 +2169,7 @@ fn nativeAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Bu const host = b.graph.host.result; const only_native = (&b.graph.host)[0..1]; if (skip_non_native) return only_native; - const arch32 = compatible32bitArch(b) orelse return only_native; + const arch32 = compatible32bitArch(&b.graph.host.result) orelse return only_native; return b.graph.arena.dupe(std.Build.ResolvedTarget, &.{ b.graph.host, b.resolveTargetQuery(.{ .cpu_arch = arch32, .os_tag = host.os.tag }), @@ -2074,7 +2186,7 @@ fn wineAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Buil .os_tag = .windows, })) catch @panic("OOM"); if (!skip_non_native) { - if (compatible32bitArch(b)) |arch| { + if (compatible32bitArch(&b.graph.host.result)) |arch| { targets.append(b.graph.arena, b.resolveTargetQuery(.{ .cpu_arch = arch, .os_tag = .windows, @@ -2519,11 +2631,21 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { if (!options.test_extra_targets and test_target.extra_target) continue; - if (options.skip_non_native and !test_target.target.isNative()) + if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) continue; const target = &resolved_target.result; + if (target.cpu.arch == .powerpc64le and target.ofmt == .c) { + // https://codeberg.org/ziglang/zig/issues/35522 + continue; + } + + if (target.cpu.arch == .s390x and target.ofmt == .c) { + // https://codeberg.org/ziglang/zig/issues/35523 + continue; + } + if (std.mem.eql(u8, options.name, "libc")) { // The libc API tests obviously need to link libc. So for test // target entries where we wouldn't link libc by default, skip the @@ -2562,11 +2684,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { if (options.skip_single_threaded and test_target.single_threaded == true) continue; - if (!would_use_llvm and target.cpu.arch == .aarch64) { - // TODO get std tests passing for the aarch64 self-hosted backend. - if (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; @@ -2812,8 +2929,6 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { const step = b.step("test-c-abi", "Run the C ABI tests"); for (c_abi_targets) |c_abi_target| { - if (options.skip_non_native and !c_abi_target.target.isNative()) continue; - if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue; if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue; @@ -2827,6 +2942,9 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); const target = &resolved_target.result; + if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) + continue; + if (options.test_target_filters.len > 0) { for (options.test_target_filters) |filter| { if (std.mem.indexOf(u8, triple_txt, filter) != null) break;