| ... | ... | @@ -1,34 +1,56 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | |
| 3 | const targets: []const std.Target.Query = &.{ |
| 4 | .{ .cpu_arch = .aarch64, .os_tag = .freebsd, .abi = .none }, |
| 5 | .{ .cpu_arch = .x86_64, .os_tag = .freebsd, .abi = .none }, |
| 6 | |
| 7 | .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .gnu }, |
| 8 | .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .musl }, |
| 9 | .{ .cpu_arch = .aarch64_be, .os_tag = .linux, .abi = .gnu }, |
| 10 | .{ .cpu_arch = .aarch64_be, .os_tag = .linux, .abi = .musl }, |
| 11 | .{ .cpu_arch = .loongarch64, .os_tag = .linux, .abi = .gnu }, |
| 12 | .{ .cpu_arch = .loongarch64, .os_tag = .linux, .abi = .musl }, |
| 13 | .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .gnuabi64 }, |
| 14 | .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .muslabi64 }, |
| 15 | .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .gnuabi64 }, |
| 16 | .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .muslabi64 }, |
| 17 | .{ .cpu_arch = .powerpc64le, .os_tag = .linux, .abi = .gnu }, |
| 18 | .{ .cpu_arch = .powerpc64le, .os_tag = .linux, .abi = .musl }, |
| 19 | .{ .cpu_arch = .riscv64, .os_tag = .linux, .abi = .gnu }, |
| 20 | .{ .cpu_arch = .riscv64, .os_tag = .linux, .abi = .musl }, |
| 21 | .{ .cpu_arch = .s390x, .os_tag = .linux, .abi = .gnu }, |
| 22 | // .{ .cpu_arch = .s390x, .os_tag = .linux, .abi = .musl }, |
| 23 | .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .gnu }, |
| 24 | .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl }, |
| 25 | |
| 26 | .{ .cpu_arch = .aarch64, .os_tag = .macos, .abi = .none }, |
| 27 | |
| 28 | // .{ .cpu_arch = .x86_64, .os_tag = .netbsd, .abi = .none }, |
| 29 | |
| 30 | // .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .gnu }, |
| 31 | // .{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu }, |
| 32 | }; |
| 33 | |
| 3 | 34 | pub fn build(b: *std.Build) !void { |
| 4 | 35 | const test_step = b.step("test", "Test the program"); |
| 5 | 36 | b.default_step = test_step; |
| 6 | 37 | |
| 7 | 38 | const is_macos = b.graph.host.result.os.tag == .macos; |
| 8 | 39 | |
| 9 | | for ([_]struct { std.Target.Os.Tag, []const std.Target.Cpu.Arch }{ |
| 10 | | // .s390x and mips64(el) fail to build |
| 11 | | .{ .linux, &.{ .aarch64, .aarch64_be, .loongarch64, .powerpc64, .powerpc64le, .riscv64, .x86_64 } }, |
| 12 | | .{ .macos, &.{ .aarch64, .x86_64 } }, |
| 40 | for (targets) |query| { |
| 41 | const target = b.resolveTargetQuery(query); |
| 13 | 42 | |
| 14 | | // powerpc64, powerpc64le, and riscv64 are not supported by TSan yet. |
| 15 | | .{ .freebsd, &.{ .aarch64, .x86_64 } }, |
| 16 | | |
| 17 | | .{ .netbsd, &.{.x86_64} }, |
| 18 | | |
| 19 | | // TSan doesn't have full support for windows yet. |
| 20 | | // .{ .windows, &.{ .aarch64, .x86_64 } }, |
| 21 | | }) |entry| { |
| 22 | | switch (entry[0]) { |
| 23 | | // compiling tsan on macos requires system headers that aren't present during cross-compilation |
| 43 | switch (target.result.os.tag) { |
| 24 | 44 | .macos => { |
| 45 | // compiling tsan on macos requires system headers that aren't present during cross-compilation |
| 25 | 46 | if (!is_macos) continue; |
| 26 | | const target = b.resolveTargetQuery(.{}); |
| 47 | |
| 27 | 48 | const exe = b.addExecutable(.{ |
| 28 | | .name = b.fmt("tsan_{s}_{s}", .{ @tagName(entry[0]), @tagName(target.result.cpu.arch) }), |
| 49 | .name = b.fmt("tsan_{s}_{s}", .{ @tagName(target.result.os.tag), @tagName(target.result.cpu.arch) }), |
| 50 | .linkage = .dynamic, |
| 29 | 51 | .root_module = b.createModule(.{ |
| 30 | 52 | .root_source_file = b.path("main.zig"), |
| 31 | | .target = target, |
| 53 | .target = b.graph.host, |
| 32 | 54 | .optimize = .debug, |
| 33 | 55 | .sanitize_thread = true, |
| 34 | 56 | }), |
| ... | ... | @@ -36,13 +58,10 @@ pub fn build(b: *std.Build) !void { |
| 36 | 58 | const install_exe = b.addInstallArtifact(exe, .{}); |
| 37 | 59 | test_step.dependOn(&install_exe.step); |
| 38 | 60 | }, |
| 39 | | else => for (entry[1]) |arch| { |
| 40 | | const target = b.resolveTargetQuery(.{ |
| 41 | | .os_tag = entry[0], |
| 42 | | .cpu_arch = arch, |
| 43 | | }); |
| 61 | else => { |
| 44 | 62 | const exe = b.addExecutable(.{ |
| 45 | | .name = b.fmt("tsan_{s}_{s}", .{ @tagName(entry[0]), @tagName(arch) }), |
| 63 | .name = b.fmt("tsan_{s}_{s}", .{ @tagName(target.result.os.tag), @tagName(target.result.cpu.arch) }), |
| 64 | .linkage = .dynamic, |
| 46 | 65 | .root_module = b.createModule(.{ |
| 47 | 66 | .root_source_file = b.path("main.zig"), |
| 48 | 67 | .target = target, |