master
 1const std = @import("std");
 2
 3pub fn build(b: *std.Build) void {
 4    const test_step = b.step("test", "Test it");
 5    b.default_step = test_step;
 6
 7    const target = b.standardTargetOptions(.{});
 8    const optimize = b.standardOptimizeOption(.{});
 9
10    if (target.result.ofmt != .elf or !(target.result.abi.isMusl() or target.result.abi.isGnu()))
11        return;
12
13    const exe = b.addExecutable(.{
14        .name = "main",
15        .root_module = b.createModule(.{
16            .root_source_file = null,
17            .optimize = optimize,
18            .target = target,
19            .link_libc = true,
20        }),
21    });
22    exe.root_module.addCSourceFile(.{
23        .file = b.path("main.c"),
24        .flags = &.{},
25    });
26    exe.link_gc_sections = false;
27    exe.bundle_compiler_rt = true;
28
29    // Verify compiler_rt hasn't pulled in any debug handlers
30    const check_exe = exe.checkObject();
31    check_exe.checkInSymtab();
32    check_exe.checkNotPresent("debug.readElfDebugInfo");
33    test_step.dependOn(&check_exe.step);
34}