mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-30 16:45:44 +00:00
build: add -std=c++17 for SIMD C++ files on MSVC
The SIMD C++ files use C++17 features (std::optional, std::size). With Zig's bundled libc++ these are available implicitly, but MSVC headers guard C++17 features behind the standard version (_HAS_CXX17). Without an explicit -std=c++17 flag, clang defaults to a lower standard and the MSVC <optional> header does not define std::optional.
This commit is contained in:
@@ -790,12 +790,27 @@ pub fn addSimd(
|
|||||||
const HWY_AVX3_DL: c_int = 1 << 7;
|
const HWY_AVX3_DL: c_int = 1 << 7;
|
||||||
const HWY_AVX3: c_int = 1 << 8;
|
const HWY_AVX3: c_int = 1 << 8;
|
||||||
|
|
||||||
|
var flags: std.ArrayListUnmanaged([]const u8) = .empty;
|
||||||
|
|
||||||
// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
|
// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
|
||||||
// To workaround this we just disable AVX512 support completely.
|
// To workaround this we just disable AVX512 support completely.
|
||||||
// The performance difference between AVX2 and AVX512 is not
|
// The performance difference between AVX2 and AVX512 is not
|
||||||
// significant for our use case and AVX512 is very rare on consumer
|
// significant for our use case and AVX512 is very rare on consumer
|
||||||
// hardware anyways.
|
// hardware anyways.
|
||||||
const HWY_DISABLED_TARGETS: c_int = HWY_AVX10_2 | HWY_AVX3_SPR | HWY_AVX3_ZEN4 | HWY_AVX3_DL | HWY_AVX3;
|
const HWY_DISABLED_TARGETS: c_int = HWY_AVX10_2 | HWY_AVX3_SPR | HWY_AVX3_ZEN4 | HWY_AVX3_DL | HWY_AVX3;
|
||||||
|
if (target.result.cpu.arch == .x86_64) try flags.append(
|
||||||
|
b.allocator,
|
||||||
|
b.fmt("-DHWY_DISABLED_TARGETS={}", .{HWY_DISABLED_TARGETS}),
|
||||||
|
);
|
||||||
|
|
||||||
|
// MSVC requires explicit std specification otherwise these
|
||||||
|
// are guarded, at least on Windows 2025. Doing it unconditionally
|
||||||
|
// doesn't cause any issues on other platforms and ensures we get
|
||||||
|
// C++17 support on MSVC.
|
||||||
|
try flags.append(
|
||||||
|
b.allocator,
|
||||||
|
"-std=c++17",
|
||||||
|
);
|
||||||
|
|
||||||
m.addCSourceFiles(.{
|
m.addCSourceFiles(.{
|
||||||
.files = &.{
|
.files = &.{
|
||||||
@@ -804,9 +819,7 @@ pub fn addSimd(
|
|||||||
"src/simd/index_of.cpp",
|
"src/simd/index_of.cpp",
|
||||||
"src/simd/vt.cpp",
|
"src/simd/vt.cpp",
|
||||||
},
|
},
|
||||||
.flags = if (target.result.cpu.arch == .x86_64) &.{
|
.flags = flags.items,
|
||||||
b.fmt("-DHWY_DISABLED_TARGETS={}", .{HWY_DISABLED_TARGETS}),
|
|
||||||
} else &.{},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user