build: avoid MSVC C++ runtime in no-libcxx builds

AI-assisted: Codex
This commit is contained in:
Riccardo Mazzarini
2026-07-25 16:35:50 +02:00
committed by Mitchell Hashimoto
parent 1fe1b2d23c
commit 84254a9d8c
5 changed files with 41 additions and 7 deletions

View File

@@ -99,6 +99,13 @@ pub fn build(b: *std.Build) !void {
"-fmath-errno",
"-fno-exceptions",
});
} else if (target.result.abi == .msvc) {
try flags.appendSlice(b.allocator, &.{
// -fno-autolink also drops UCRT's /alternatename fallback.
"-D_Avx2WmemEnabledWeakValue=_Avx2WmemEnabled",
"-fno-autolink",
"-fno-stack-protector",
});
}
lib.root_module.addCSourceFiles(.{ .flags = flags.items, .files = &.{

View File

@@ -50,10 +50,16 @@ pub fn build(b: *std.Build) !void {
if (no_libcxx) {
try flags.append(b.allocator, "-DSIMDUTF_NO_LIBCXX");
if (target.result.abi != .msvc) {
// Clang/GCC-only flags; MSVC doesn't accept these.
try flags.append(b.allocator, "-fno-exceptions");
try flags.append(b.allocator, "-fno-rtti");
try flags.append(b.allocator, "-fno-exceptions");
try flags.append(b.allocator, "-fno-rtti");
if (target.result.abi == .msvc) {
try flags.appendSlice(b.allocator, &.{
"-D_USE_STD_VECTOR_ALGORITHMS=0",
// -fno-autolink also drops UCRT's /alternatename fallback.
"-D_Avx2WmemEnabledWeakValue=_Avx2WmemEnabled",
"-fno-autolink",
"-fno-stack-protector",
});
}
lib.root_module.addCMacro("SIMDUTF_NO_LIBCXX", "1");