mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-24 04:25:10 -07:00
build.zig: require at least SSE4.1 when targeting x86_64
This commit is contained in:
parent
1904d6ad21
commit
42743db558
15
build.zig
15
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";
|
||||
@ -132,12 +133,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");
|
||||
}
|
||||
@ -155,6 +157,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| {
|
||||
|
Loading…
Reference in New Issue
Block a user