diff --git a/build.zig b/build.zig index f808353966..a557dd3c26 100644 --- a/build.zig +++ b/build.zig @@ -43,13 +43,23 @@ const cflags = &[_][]const u8{ const compilers = &[_][]const u8{ "zig", "clang", "gcc", "tcc" }; pub fn build(b: *std.Build) !void { - const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const cc = b.option([]const u8, "cc", "C compiler") orelse "zig"; const no_exec = b.option(bool, "no-exec", "Compile test binary without running it") orelse false; const valgrind = b.option(bool, "valgrind", "Run tests under valgrind") orelse false; + const target = blk: { + var query = b.standardTargetOptionsQueryOnly(.{}); + if (valgrind) { + const arch = query.cpu_arch orelse builtin.cpu.arch; + if (arch == .x86_64) { + query.cpu_features_sub.addFeature(@intFromEnum(std.Target.x86.Feature.avx512f)); + } + } + break :blk b.resolveTargetQuery(query); + }; + const test_step = b.step("test", "Run unit tests"); addTestStep(b, test_step, target, optimize, cc, no_exec, valgrind);