|
| 1 | +const std = @import("std"); |
| 2 | + |
| 3 | +pub fn build(b: *std.Build) void { |
| 4 | + inline for (.{ |
| 5 | + .aarch64, |
| 6 | + .aarch64_be, |
| 7 | + .hexagon, |
| 8 | + .loongarch64, |
| 9 | + .mips, |
| 10 | + .mipsel, |
| 11 | + .mips64, |
| 12 | + .mips64el, |
| 13 | + .powerpc, |
| 14 | + .powerpcle, |
| 15 | + .powerpc64, |
| 16 | + .powerpc64le, |
| 17 | + .riscv32, |
| 18 | + .riscv64, |
| 19 | + .s390x, |
| 20 | + .sparc64, |
| 21 | + .x86, |
| 22 | + .x86_64, |
| 23 | + }) |arch| { |
| 24 | + const target = b.resolveTargetQuery(.{ |
| 25 | + .cpu_arch = arch, |
| 26 | + .os_tag = .linux, |
| 27 | + }); |
| 28 | + |
| 29 | + const omit_dbg = b.addExecutable(.{ |
| 30 | + .name = b.fmt("{s}-linux-omit-dbg", .{@tagName(arch)}), |
| 31 | + .root_module = b.createModule(.{ |
| 32 | + .root_source_file = b.path("main.zig"), |
| 33 | + .target = target, |
| 34 | + .optimize = .Debug, |
| 35 | + // We are mainly concerned with CFI directives in our non-libc startup code and syscall |
| 36 | + // code, so make it explicit that we don't want libc. |
| 37 | + .link_libc = false, |
| 38 | + .strip = true, |
| 39 | + }), |
| 40 | + }); |
| 41 | + |
| 42 | + const omit_uwt = b.addExecutable(.{ |
| 43 | + .name = b.fmt("{s}-linux-omit-uwt", .{@tagName(arch)}), |
| 44 | + .root_module = b.createModule(.{ |
| 45 | + .root_source_file = b.path("main.zig"), |
| 46 | + .target = target, |
| 47 | + .optimize = .Debug, |
| 48 | + .link_libc = false, |
| 49 | + .unwind_tables = .none, |
| 50 | + }), |
| 51 | + }); |
| 52 | + |
| 53 | + const omit_both = b.addExecutable(.{ |
| 54 | + .name = b.fmt("{s}-linux-omit-both", .{@tagName(arch)}), |
| 55 | + .root_module = b.createModule(.{ |
| 56 | + .root_source_file = b.path("main.zig"), |
| 57 | + .target = target, |
| 58 | + .optimize = .Debug, |
| 59 | + .link_libc = false, |
| 60 | + .strip = true, |
| 61 | + .unwind_tables = .none, |
| 62 | + }), |
| 63 | + }); |
| 64 | + |
| 65 | + inline for (.{ omit_dbg, omit_uwt, omit_both }) |step| b.installArtifact(step); |
| 66 | + } |
| 67 | +} |
0 commit comments