diff --git a/build.zig b/build.zig index a70059b8..859f3007 100644 --- a/build.zig +++ b/build.zig @@ -5,6 +5,7 @@ const fs = std.fs; const heap = std.heap; const mem = std.mem; const LibExeObjStep = std.build.LibExeObjStep; +const Target = std.Target; pub fn build(b: *std.build.Builder) !void { const src_path = "src/libsodium"; @@ -135,12 +136,13 @@ pub fn build(b: *std.build.Builder) !void { lib.defineCMacro("HAVE_EMMINTRIN_H", "1"); lib.defineCMacro("HAVE_PMMINTRIN_H", "1"); lib.defineCMacro("HAVE_SMMINTRIN_H", "1"); + lib.defineCMacro("HAVE_TMMINTRIN_H", "1"); lib.defineCMacro("HAVE_WMMINTRIN_H", "1"); }, .aarch64, .aarch64_be => { const cpu_features = target.getCpuFeatures(); - const has_neon = cpu_features.isEnabled(@enumToInt(std.Target.aarch64.Feature.neon)); - const has_crypto = cpu_features.isEnabled(@enumToInt(std.Target.aarch64.Feature.crypto)); + const has_neon = cpu_features.isEnabled(@enumToInt(Target.aarch64.Feature.neon)); + const has_crypto = cpu_features.isEnabled(@enumToInt(Target.aarch64.Feature.crypto)); if (has_neon and has_crypto) { lib.defineCMacro("HAVE_ARMCRYPTO", "1"); } @@ -158,6 +160,15 @@ pub fn build(b: *std.build.Builder) !void { else => {}, } + switch (target.getCpuArch()) { + .x86_64 => { + lib.target.cpu_features_add.addFeature(@enumToInt(Target.x86.Feature.sse4_1)); + lib.target.cpu_features_add.addFeature(@enumToInt(Target.x86.Feature.aes)); + lib.target.cpu_features_add.addFeature(@enumToInt(Target.x86.Feature.pclmul)); + }, + else => {}, + } + var allocator = heap.page_allocator; var walker = try src_dir.walk(allocator); while (try walker.next()) |entry| {