Skip to content

Commit ccfd3d6

Browse files
committed
Add detecting native target infomation
1 parent 6835794 commit ccfd3d6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

build.zig

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ pub fn build(b: *std.Build) void {
4848
}
4949

5050
// the native cpu_arch is null, so we should detect current cpu_arch
51-
// if (target.cpu_arch == .x86_64) {
52-
// exe.addIncludePath(.{ .path = "./inc" });
53-
// const cfiles = [_][]const u8{"src/x86_64_intrins.c"};
54-
// const cflags = [_][]const u8{"-O2"};
55-
// exe.addCSourceFiles(&cfiles, &cflags);
56-
// }
51+
const target_info = std.zig.system.NativeTargetInfo.detect(target) catch
52+
@panic("Couldn't detect native target info");
53+
if (target_info.target.cpu.arch == .x86_64) {
54+
exe.addIncludePath(.{ .path = "./inc" });
55+
const cfiles = [_][]const u8{"src/x86_64_intrins.c"};
56+
const cflags = [_][]const u8{"-O2"};
57+
exe.addCSourceFiles(&cfiles, &cflags);
58+
}
5759

5860
// This declares intent for the executable to be installed into the
5961
// standard location when the user invokes the "install" step (the default

src/simd_x86_64.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const VecU8Index = VectorIndex(@Vector(VecLen(u8), u8));
1414

1515
const c = @cImport({
1616
@cInclude("immintrin.h");
17-
// @cInclude("x86_64_intrins.h");
17+
@cInclude("x86_64_intrins.h");
1818
});
1919

2020
pub const SimdSamples = struct {

0 commit comments

Comments
 (0)