mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
28 lines
928 B
Zig
28 lines
928 B
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
// Library with explicitly set cpu features
|
|
const lib = b.addSharedLibrary(.{
|
|
.name = "lib",
|
|
.root_source_file = .{ .path = "main.zig" },
|
|
.optimize = b.standardOptimizeOption(.{}),
|
|
.target = .{
|
|
.cpu_arch = .wasm32,
|
|
.cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp },
|
|
.cpu_features_add = std.Target.wasm.featureSet(&.{.atomics}),
|
|
.os_tag = .freestanding,
|
|
},
|
|
});
|
|
lib.use_llvm = false;
|
|
lib.use_lld = false;
|
|
|
|
// Verify the result contains the features explicitly set on the target for the library.
|
|
const check = lib.checkObject(.wasm);
|
|
check.checkStart("name target_features");
|
|
check.checkNext("features 1");
|
|
check.checkNext("+ atomics");
|
|
|
|
const test_step = b.step("test", "Run linker test");
|
|
test_step.dependOn(&check.step);
|
|
}
|