master
 1const std = @import("std");
 2
 3pub fn build(b: *std.Build) void {
 4    // Library with explicitly set cpu features
 5    const lib = b.addExecutable(.{
 6        .name = "lib",
 7        .root_module = b.createModule(.{
 8            .root_source_file = b.path("main.zig"),
 9            .optimize = .Debug,
10            .target = b.resolveTargetQuery(.{
11                .cpu_arch = .wasm32,
12                .cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp },
13                .cpu_features_add = std.Target.wasm.featureSet(&.{.atomics}),
14                .os_tag = .freestanding,
15            }),
16        }),
17    });
18    lib.entry = .disabled;
19    lib.use_llvm = false;
20    lib.use_lld = false;
21
22    // Verify the result contains the features explicitly set on the target for the library.
23    const check = lib.checkObject();
24    check.checkInHeaders();
25    check.checkExact("name target_features");
26    check.checkExact("features 1");
27    check.checkExact("+ atomics");
28
29    const test_step = b.step("test", "Run linker test");
30    test_step.dependOn(&check.step);
31    b.default_step = test_step;
32}