| ... | ... | @@ -2250,23 +2250,57 @@ const link_targets = blk: { |
| 2250 | 2250 | }; |
| 2251 | 2251 | }; |
| 2252 | 2252 | |
| 2253 | | /// Unlike `test_targets` and `c_abi_targets`, these targets are just simple strings which we pass |
| 2254 | | /// directly to `incr-check`. They include the target triple and the compiler backend. |
| 2253 | const IncrementalTarget = struct { |
| 2254 | target: std.Target.Query, |
| 2255 | backend: enum { selfhosted, llvm, cbe }, |
| 2256 | }; |
| 2257 | |
| 2258 | /// These are passed to `incr-check` as `<target>-<backend>` strings. |
| 2255 | 2259 | /// |
| 2256 | 2260 | /// If only one specific test is failing on a target, instead of entirely disabling the target here, |
| 2257 | 2261 | /// you can skip the target for that specific test only by adding a line like this to the manifest: |
| 2258 | 2262 | /// #skip_target=x86_64-linux-selfhosted |
| 2259 | | const incremental_targets: []const []const u8 = &.{ |
| 2263 | const incremental_targets = &[_]IncrementalTarget{ |
| 2260 | 2264 | // Avoid adding more CBE or LLVM targets without good reason: they're a lot slower than others |
| 2261 | 2265 | // to run due to the output (C source code or LLVM IR) being built non-incrementally (by Clang |
| 2262 | 2266 | // or LLVM). We just have a couple here to make sure that it works. |
| 2263 | | "x86_64-linux-cbe", |
| 2264 | | "x86_64-linux-llvm", |
| 2267 | .{ |
| 2268 | .target = .{ |
| 2269 | .cpu_arch = .x86_64, |
| 2270 | .os_tag = .linux, |
| 2271 | }, |
| 2272 | .backend = .cbe, |
| 2273 | }, |
| 2274 | .{ |
| 2275 | .target = .{ |
| 2276 | .cpu_arch = .x86_64, |
| 2277 | .os_tag = .linux, |
| 2278 | }, |
| 2279 | .backend = .llvm, |
| 2280 | }, |
| 2265 | 2281 | |
| 2266 | | "x86_64-linux-selfhosted", |
| 2282 | .{ |
| 2283 | .target = .{ |
| 2284 | .cpu_arch = .x86_64, |
| 2285 | .os_tag = .linux, |
| 2286 | }, |
| 2287 | .backend = .selfhosted, |
| 2288 | }, |
| 2267 | 2289 | // https://codeberg.org/ziglang/zig/issues/31773 |
| 2268 | | //"x86_64-windows-selfhosted", |
| 2269 | | "wasm32-wasi-selfhosted", |
| 2290 | // .{ |
| 2291 | // .target = .{ |
| 2292 | // .cpu_arch = .x86_64, |
| 2293 | // .os_tag = .windows, |
| 2294 | // }, |
| 2295 | // .backend = .selfhosted, |
| 2296 | // }, |
| 2297 | .{ |
| 2298 | .target = .{ |
| 2299 | .cpu_arch = .wasm32, |
| 2300 | .os_tag = .wasi, |
| 2301 | }, |
| 2302 | .backend = .selfhosted, |
| 2303 | }, |
| 2270 | 2304 | }; |
| 2271 | 2305 | |
| 2272 | 2306 | fn compatible32bitArch(host: *const std.Target) ?std.Target.Cpu.Arch { |
| ... | ... | @@ -3164,8 +3198,14 @@ const LinkTestOptions = struct { |
| 3164 | 3198 | test_filters: []const []const u8, |
| 3165 | 3199 | optimize_modes: []const OptimizeMode, |
| 3166 | 3200 | skip_non_native: bool, |
| 3201 | skip_freebsd: bool, |
| 3202 | skip_netbsd: bool, |
| 3203 | skip_openbsd: bool, |
| 3167 | 3204 | skip_windows: bool, |
| 3205 | skip_darwin: bool, |
| 3206 | skip_linux: bool, |
| 3168 | 3207 | skip_llvm: bool, |
| 3208 | skip_libc: bool, |
| 3169 | 3209 | max_rss: usize, |
| 3170 | 3210 | }; |
| 3171 | 3211 | |
| ... | ... | @@ -3178,22 +3218,37 @@ pub fn addLinkTests(b: *std.Build, options: LinkTestOptions) *Step { |
| 3178 | 3218 | ) orelse false; |
| 3179 | 3219 | |
| 3180 | 3220 | for (link_targets) |link_target| { |
| 3181 | | if (options.skip_non_native and !link_target.target.isNative()) continue; |
| 3182 | | if (options.skip_windows and link_target.target.os_tag == .windows) continue; |
| 3183 | | |
| 3184 | 3221 | const resolved_target = b.resolveTargetQuery(link_target.target); |
| 3185 | | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); |
| 3222 | |
| 3223 | if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) |
| 3224 | continue; |
| 3225 | |
| 3186 | 3226 | const target = &resolved_target.result; |
| 3187 | 3227 | |
| 3228 | if (options.skip_freebsd and target.os.tag == .freebsd) continue; |
| 3229 | if (options.skip_netbsd and target.os.tag == .netbsd) continue; |
| 3230 | if (options.skip_openbsd and target.os.tag == .openbsd) continue; |
| 3231 | if (options.skip_windows and target.os.tag == .windows) continue; |
| 3232 | if (options.skip_darwin and target.os.tag.isDarwin()) continue; |
| 3233 | if (options.skip_linux and target.os.tag == .linux) continue; |
| 3234 | |
| 3235 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); |
| 3236 | |
| 3188 | 3237 | if (options.test_target_filters.len > 0) { |
| 3189 | 3238 | for (options.test_target_filters) |filter| { |
| 3190 | 3239 | if (std.mem.find(u8, triple_txt, filter) != null) break; |
| 3191 | 3240 | } else continue; |
| 3192 | 3241 | } |
| 3193 | 3242 | |
| 3243 | if (options.skip_libc and (link_target.link_libc == true or std.os.targetRequiresLibC(target))) |
| 3244 | continue; |
| 3245 | |
| 3246 | // We can't provide MSVC libc when cross-compiling. |
| 3247 | if (target.abi == .msvc and link_target.link_libc == true and builtin.os.tag != .windows) |
| 3248 | continue; |
| 3249 | |
| 3194 | 3250 | for (options.optimize_modes) |optimize_mode| { |
| 3195 | 3251 | if (link_target.optimize_mode != optimize_mode) continue; |
| 3196 | | if (link_target.link_libc and target.abi == .msvc and b.graph.host.result.os.tag != .windows) continue; |
| 3197 | 3252 | const would_use_llvm = wouldUseLlvm(link_target.use_llvm, link_target.target, optimize_mode); |
| 3198 | 3253 | if (options.skip_llvm and would_use_llvm) continue; |
| 3199 | 3254 | |
| ... | ... | @@ -3290,11 +3345,24 @@ pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step |
| 3290 | 3345 | return step; |
| 3291 | 3346 | } |
| 3292 | 3347 | |
| 3348 | const IncrementalTestOptions = struct { |
| 3349 | test_filters: []const []const u8, |
| 3350 | test_target_filters: []const []const u8, |
| 3351 | skip_non_native: bool, |
| 3352 | skip_wasm: bool, |
| 3353 | skip_freebsd: bool, |
| 3354 | skip_netbsd: bool, |
| 3355 | skip_openbsd: bool, |
| 3356 | skip_windows: bool, |
| 3357 | skip_darwin: bool, |
| 3358 | skip_linux: bool, |
| 3359 | skip_llvm: bool, |
| 3360 | }; |
| 3361 | |
| 3293 | 3362 | pub fn addIncrementalTests( |
| 3294 | 3363 | b: *std.Build, |
| 3295 | 3364 | test_step: *Step, |
| 3296 | | test_filters: []const []const u8, |
| 3297 | | test_target_filters: []const []const u8, |
| 3365 | options: IncrementalTestOptions, |
| 3298 | 3366 | ) !void { |
| 3299 | 3367 | const io = b.graph.io; |
| 3300 | 3368 | |
| ... | ... | @@ -3316,9 +3384,9 @@ pub fn addIncrementalTests( |
| 3316 | 3384 | while (try it.next(io)) |entry| { |
| 3317 | 3385 | if (std.mem.endsWith(u8, entry.basename, ".swp")) continue; |
| 3318 | 3386 | |
| 3319 | | for (test_filters) |test_filter| { |
| 3387 | for (options.test_filters) |test_filter| { |
| 3320 | 3388 | if (std.mem.find(u8, entry.path, test_filter)) |_| break; |
| 3321 | | } else if (test_filters.len > 0) continue; |
| 3389 | } else if (options.test_filters.len > 0) continue; |
| 3322 | 3390 | |
| 3323 | 3391 | switch (entry.kind) { |
| 3324 | 3392 | .file => {}, |
| ... | ... | @@ -3329,13 +3397,35 @@ pub fn addIncrementalTests( |
| 3329 | 3397 | } |
| 3330 | 3398 | b.dependOnFileContents(b.path(b.pathJoin(&.{ "test", "incremental", entry.path }))); |
| 3331 | 3399 | |
| 3332 | | for (incremental_targets) |target_str| { |
| 3333 | | if (test_target_filters.len > 0) { |
| 3334 | | for (test_target_filters) |filter| { |
| 3335 | | if (std.mem.find(u8, target_str, filter) != null) break; |
| 3400 | for (incremental_targets) |test_target| { |
| 3401 | const resolved_target = b.resolveTargetQuery(test_target.target); |
| 3402 | |
| 3403 | if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) |
| 3404 | continue; |
| 3405 | |
| 3406 | const target = &resolved_target.result; |
| 3407 | |
| 3408 | if (options.skip_wasm and target.cpu.arch.isWasm()) continue; |
| 3409 | |
| 3410 | if (options.skip_freebsd and target.os.tag == .freebsd) continue; |
| 3411 | if (options.skip_netbsd and target.os.tag == .netbsd) continue; |
| 3412 | if (options.skip_openbsd and target.os.tag == .openbsd) continue; |
| 3413 | if (options.skip_windows and target.os.tag == .windows) continue; |
| 3414 | if (options.skip_darwin and target.os.tag.isDarwin()) continue; |
| 3415 | if (options.skip_linux and target.os.tag == .linux) continue; |
| 3416 | |
| 3417 | if (options.skip_llvm and test_target.backend == .llvm) continue; |
| 3418 | |
| 3419 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); |
| 3420 | |
| 3421 | if (options.test_target_filters.len > 0) { |
| 3422 | for (options.test_target_filters) |filter| { |
| 3423 | if (std.mem.find(u8, triple_txt, filter) != null) break; |
| 3336 | 3424 | } else continue; |
| 3337 | 3425 | } |
| 3338 | 3426 | |
| 3427 | const target_str = b.fmt("{s}-{t}", .{ triple_txt, test_target.backend }); |
| 3428 | |
| 3339 | 3429 | const run = b.addRunArtifact(incr_check); |
| 3340 | 3430 | run.setName(b.fmt("incr-check {s} '{s}'", .{ target_str, entry.basename })); |
| 3341 | 3431 | |