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

@@ -249,9 +249,14 @@ fn initLib(
lib.bundle_ubsan_rt = false;
if (kind == .static) {
// compiler_rt expects ntdll to provide _fltused when libc is
// linked, and the Zig standard library uses other NT and kernel32
// symbols.
if (target.result.abi == .msvc) {
// Zig's compiler runtime doesn't provide MSVC's security
// cookie symbols when libc is linked. Disable stack-protector
// generation so static consumers don't need BufferOverflowU.
lib.root_module.stack_protector = false;
}
// The Zig standard library uses NT and kernel32 symbols.
lib.root_module.linkSystemLibrary("ntdll", .{});
lib.root_module.linkSystemLibrary("kernel32", .{});
}

View File

@@ -991,6 +991,11 @@ pub fn addSimd(
"-fno-sanitize=undefined",
"-fno-sanitize-trap=undefined",
});
if (target.result.abi == .msvc) try flags.appendSlice(b.allocator, &.{
// -fno-autolink also drops UCRT's /alternatename fallback.
"-D_Avx2WmemEnabledWeakValue=_Avx2WmemEnabled",
"-fno-autolink",
});
m.addCSourceFiles(.{
.files = &.{