From 74c6ffe78e4b98e58600f22f37a8433f44b53876 Mon Sep 17 00:00:00 2001 From: Alessandro De Blasis Date: Tue, 24 Mar 2026 08:05:40 +0100 Subject: [PATCH] build: fix glslang compilation on Windows with MSVC Apply the same MSVC fixes used for simdutf and highway: conditionally skip linkLibCpp on MSVC since Zig's bundled libc++ headers conflict with MSVC's own C++ runtime, and add -std=c++17 for C++17 features like std::variant and inline variables that glslang requires. Co-Authored-By: Claude Opus 4.6 (1M context) --- pkg/glslang/build.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/glslang/build.zig b/pkg/glslang/build.zig index c41e05217..1dc82a6e3 100644 --- a/pkg/glslang/build.zig +++ b/pkg/glslang/build.zig @@ -51,7 +51,14 @@ fn buildGlslang( .linkage = .static, }); lib.linkLibC(); - lib.linkLibCpp(); + // On MSVC, we must not use linkLibCpp because Zig unconditionally + // passes -nostdinc++ and then adds its bundled libc++/libc++abi + // include paths, which conflict with MSVC's own C++ runtime headers. + // The MSVC SDK include directories (added via linkLibC) contain + // both C and C++ headers, so linkLibCpp is not needed. + if (target.result.abi != .msvc) { + lib.linkLibCpp(); + } if (upstream_) |upstream| lib.addIncludePath(upstream.path("")); lib.addIncludePath(b.path("override")); if (target.result.os.tag.isDarwin()) { @@ -65,6 +72,10 @@ fn buildGlslang( "-fno-sanitize=undefined", "-fno-sanitize-trap=undefined", }); + // MSVC requires explicit std specification otherwise C++17 features + // like std::variant, std::filesystem, and inline variables are + // guarded behind _HAS_CXX17. + try flags.append(b.allocator, "-std=c++17"); if (target.result.os.tag == .freebsd or target.result.abi == .musl) { try flags.append(b.allocator, "-fPIC");