disable AVX512 until Zig issue is resolved

https://github.com/ziglang/zig/issues/20414
This commit is contained in:
Mitchell Hashimoto
2024-06-24 15:06:16 -07:00
parent c1ead2e2f1
commit 98689413b4
2 changed files with 28 additions and 6 deletions

View File

@ -1028,11 +1028,31 @@ fn addDeps(
// C++ files
step.linkLibCpp();
step.addIncludePath(b.path("src"));
step.addCSourceFiles(.{ .files = &.{
{
// From hwy/detect_targets.h
const HWY_AVX3_SPR: c_int = 1 << 4;
const HWY_AVX3_ZEN4: c_int = 1 << 6;
const HWY_AVX3_DL: c_int = 1 << 7;
const HWY_AVX3: c_int = 1 << 8;
// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
// To workaround this we just disable AVX512 support completely.
// The performance difference between AVX2 and AVX512 is not
// significant for our use case and AVX512 is very rare on consumer
// hardware anyways.
const HWY_DISABLED_TARGETS: c_int = HWY_AVX3_SPR | HWY_AVX3_ZEN4 | HWY_AVX3_DL | HWY_AVX3;
step.addCSourceFiles(.{
.files = &.{
"src/simd/codepoint_width.cpp",
"src/simd/index_of.cpp",
"src/simd/vt.cpp",
} });
},
.flags = if (step.rootModuleTarget().cpu.arch == .x86_64) &.{
b.fmt("-DHWY_DISABLED_TARGETS={}", .{HWY_DISABLED_TARGETS}),
} else &.{},
});
}
// If we're building a lib we have some different deps
const lib = step.kind == .lib;

View File

@ -19,7 +19,9 @@ pub fn build(b: *std.Build) !void {
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
try flags.appendSlice(&.{});
// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
// (See root Ghostty build.zig on why we do this)
try flags.appendSlice(&.{"-DSIMDUTF_IMPLEMENTATION_ICELAKE=0"});
lib.addCSourceFiles(.{
.flags = flags.items,