| ... | @@ -2026,8 +2026,7 @@ const incremental_targets: []const []const u8 = &.{ | ... | @@ -2026,8 +2026,7 @@ const incremental_targets: []const []const u8 = &.{ |
| 2026 | //"wasm32-wasi-selfhosted", | 2026 | //"wasm32-wasi-selfhosted", |
| 2027 | }; | 2027 | }; |
| 2028 | | 2028 | |
| 2029 | fn compatible32bitArch(b: *std.Build) ?std.Target.Cpu.Arch { | 2029 | fn compatible32bitArch(host: *const std.Target) ?std.Target.Cpu.Arch { |
| 2030 | const host = b.graph.host.result; | | |
| 2031 | return switch (host.os.tag) { | 2030 | return switch (host.os.tag) { |
| 2032 | .windows => switch (host.cpu.arch) { | 2031 | .windows => switch (host.cpu.arch) { |
| 2033 | .x86_64 => .x86, | 2032 | .x86_64 => .x86, |
| ... | @@ -2050,6 +2049,108 @@ fn compatible32bitArch(b: *std.Build) ?std.Target.Cpu.Arch { | ... | @@ -2050,6 +2049,108 @@ fn compatible32bitArch(b: *std.Build) ?std.Target.Cpu.Arch { |
| 2050 | }; | 2049 | }; |
| 2051 | } | 2050 | } |
| 2052 | | 2051 | |
| | 2052 | pub fn isNative(actual_target: *const std.Build.ResolvedTarget, host: *const std.Target) bool { |
| | 2053 | if (actual_target.query.isNative()) return true; |
| | 2054 | const actual = &actual_target.result; |
| | 2055 | |
| | 2056 | if (actual.cpu.arch != host.cpu.arch and |
| | 2057 | actual.cpu.arch != compatible32bitArch(host)) |
| | 2058 | { |
| | 2059 | return false; |
| | 2060 | } |
| | 2061 | |
| | 2062 | if (actual.os.tag != host.os.tag) |
| | 2063 | return false; |
| | 2064 | |
| | 2065 | // Remove features that don't actually affect compatibility. |
| | 2066 | const irrelevant: std.Target.Cpu.Feature.Set = switch (host.cpu.arch) { |
| | 2067 | .x86_64 => std.Target.x86.featureSet(&.{ |
| | 2068 | .@"16bit_mode", |
| | 2069 | .@"32bit_mode", |
| | 2070 | .@"64bit", |
| | 2071 | .false_deps_getmant, |
| | 2072 | .false_deps_lzcnt_tzcnt, |
| | 2073 | .false_deps_mulc, |
| | 2074 | .false_deps_mullq, |
| | 2075 | .false_deps_perm, |
| | 2076 | .false_deps_popcnt, |
| | 2077 | .false_deps_range, |
| | 2078 | .fast_11bytenop, |
| | 2079 | .fast_15bytenop, |
| | 2080 | .fast_7bytenop, |
| | 2081 | .fast_bextr, |
| | 2082 | .fast_dpwssd, |
| | 2083 | .fast_gather, |
| | 2084 | .fast_hops, |
| | 2085 | .fast_imm16, |
| | 2086 | .fast_lzcnt, |
| | 2087 | .fast_movbe, |
| | 2088 | .fast_scalar_fsqrt, |
| | 2089 | .fast_scalar_shift_masks, |
| | 2090 | .fast_shld_rotate, |
| | 2091 | .fast_variable_crosslane_shuffle, |
| | 2092 | .fast_variable_perlane_shuffle, |
| | 2093 | .fast_vector_fsqrt, |
| | 2094 | .fast_vector_shift_masks, |
| | 2095 | .faster_shift_than_shuffle, |
| | 2096 | .no_bypass_delay, |
| | 2097 | .no_bypass_delay_blend, |
| | 2098 | .no_bypass_delay_mov, |
| | 2099 | .no_bypass_delay_shuffle, |
| | 2100 | .prefer_128_bit, |
| | 2101 | .prefer_256_bit, |
| | 2102 | .prefer_legacy_setcc, |
| | 2103 | .prefer_mask_registers, |
| | 2104 | .prefer_movmsk_over_vtest, |
| | 2105 | .prefer_no_gather, |
| | 2106 | .prefer_no_scatter, |
| | 2107 | .slow_3ops_lea, |
| | 2108 | .slow_incdec, |
| | 2109 | .slow_lea, |
| | 2110 | .slow_pmaddwd, |
| | 2111 | .slow_pmulld, |
| | 2112 | .slow_pmullq, |
| | 2113 | .slow_shld, |
| | 2114 | .slow_two_mem_ops, |
| | 2115 | .slow_unaligned_mem_16, |
| | 2116 | .slow_unaligned_mem_32, |
| | 2117 | }), |
| | 2118 | .aarch64 => std.Target.aarch64.featureSet(&.{ |
| | 2119 | .addr_lsl_slow_14, |
| | 2120 | .alu_lsl_fast, |
| | 2121 | .avoid_ldapur, |
| | 2122 | .disable_fast_inc_vl, |
| | 2123 | .exynos_cheap_as_move, |
| | 2124 | .fuse_address, |
| | 2125 | .fuse_addsub_2reg_const1, |
| | 2126 | .fuse_adrp_add, |
| | 2127 | .fuse_aes, |
| | 2128 | .fuse_arith_logic, |
| | 2129 | .fuse_crypto_eor, |
| | 2130 | .fuse_csel, |
| | 2131 | .fuse_cset, |
| | 2132 | .fuse_literals, |
| | 2133 | .predictable_select_expensive, |
| | 2134 | .slow_misaligned_128store, |
| | 2135 | .slow_paired_128, |
| | 2136 | .slow_strqro_store, |
| | 2137 | .use_experimental_zeroing_pseudos, |
| | 2138 | .use_fixed_over_scalable_if_equal_cost, |
| | 2139 | .use_postra_scheduler, |
| | 2140 | .use_reciprocal_square_root, |
| | 2141 | .use_wzr_to_vec_move, |
| | 2142 | }), |
| | 2143 | else => .empty, |
| | 2144 | }; |
| | 2145 | var set = actual.cpu.features; |
| | 2146 | set.removeFeatureSet(irrelevant); |
| | 2147 | |
| | 2148 | if (!host.cpu.features.isSuperSetOf(set)) |
| | 2149 | return false; |
| | 2150 | |
| | 2151 | return true; |
| | 2152 | } |
| | 2153 | |
| 2053 | /// For stack trace tests, we only test native by default, because external executors are pretty | 2154 | /// For stack trace tests, we only test native by default, because external executors are pretty |
| 2054 | /// unreliable at stack tracing. However, if there's a 32-bit equivalent target which the host can | 2155 | /// unreliable at stack tracing. However, if there's a 32-bit equivalent target which the host can |
| 2055 | /// trivially run, we may as well at least test that! | 2156 | /// trivially run, we may as well at least test that! |
| ... | @@ -2057,7 +2158,7 @@ fn nativeAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Bu | ... | @@ -2057,7 +2158,7 @@ fn nativeAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Bu |
| 2057 | const host = b.graph.host.result; | 2158 | const host = b.graph.host.result; |
| 2058 | const only_native = (&b.graph.host)[0..1]; | 2159 | const only_native = (&b.graph.host)[0..1]; |
| 2059 | if (skip_non_native) return only_native; | 2160 | if (skip_non_native) return only_native; |
| 2060 | const arch32 = compatible32bitArch(b) orelse return only_native; | 2161 | const arch32 = compatible32bitArch(&b.graph.host.result) orelse return only_native; |
| 2061 | return b.graph.arena.dupe(std.Build.ResolvedTarget, &.{ | 2162 | return b.graph.arena.dupe(std.Build.ResolvedTarget, &.{ |
| 2062 | b.graph.host, | 2163 | b.graph.host, |
| 2063 | b.resolveTargetQuery(.{ .cpu_arch = arch32, .os_tag = host.os.tag }), | 2164 | b.resolveTargetQuery(.{ .cpu_arch = arch32, .os_tag = host.os.tag }), |
| ... | @@ -2074,7 +2175,7 @@ fn wineAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Buil | ... | @@ -2074,7 +2175,7 @@ fn wineAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Buil |
| 2074 | .os_tag = .windows, | 2175 | .os_tag = .windows, |
| 2075 | })) catch @panic("OOM"); | 2176 | })) catch @panic("OOM"); |
| 2076 | if (!skip_non_native) { | 2177 | if (!skip_non_native) { |
| 2077 | if (compatible32bitArch(b)) |arch| { | 2178 | if (compatible32bitArch(&b.graph.host.result)) |arch| { |
| 2078 | targets.append(b.graph.arena, b.resolveTargetQuery(.{ | 2179 | targets.append(b.graph.arena, b.resolveTargetQuery(.{ |
| 2079 | .cpu_arch = arch, | 2180 | .cpu_arch = arch, |
| 2080 | .os_tag = .windows, | 2181 | .os_tag = .windows, |
| ... | @@ -2519,7 +2620,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | ... | @@ -2519,7 +2620,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 2519 | | 2620 | |
| 2520 | if (!options.test_extra_targets and test_target.extra_target) continue; | 2621 | if (!options.test_extra_targets and test_target.extra_target) continue; |
| 2521 | | 2622 | |
| 2522 | if (options.skip_non_native and !test_target.target.isNative()) | 2623 | if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) |
| 2523 | continue; | 2624 | continue; |
| 2524 | | 2625 | |
| 2525 | const target = &resolved_target.result; | 2626 | const target = &resolved_target.result; |
| ... | @@ -2812,8 +2913,6 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { | ... | @@ -2812,8 +2913,6 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { |
| 2812 | const step = b.step("test-c-abi", "Run the C ABI tests"); | 2913 | const step = b.step("test-c-abi", "Run the C ABI tests"); |
| 2813 | | 2914 | |
| 2814 | for (c_abi_targets) |c_abi_target| { | 2915 | for (c_abi_targets) |c_abi_target| { |
| 2815 | if (options.skip_non_native and !c_abi_target.target.isNative()) continue; | | |
| 2816 | | | |
| 2817 | if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue; | 2916 | if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue; |
| 2818 | | 2917 | |
| 2819 | if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue; | 2918 | if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue; |
| ... | @@ -2827,6 +2926,9 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { | ... | @@ -2827,6 +2926,9 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { |
| 2827 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); | 2926 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); |
| 2828 | const target = &resolved_target.result; | 2927 | const target = &resolved_target.result; |
| 2829 | | 2928 | |
| | 2929 | if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) |
| | 2930 | continue; |
| | 2931 | |
| 2830 | if (options.test_target_filters.len > 0) { | 2932 | if (options.test_target_filters.len > 0) { |
| 2831 | for (options.test_target_filters) |filter| { | 2933 | for (options.test_target_filters) |filter| { |
| 2832 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; | 2934 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; |