diff --git a/pkg/highway/build.zig b/pkg/highway/build.zig index b6e188b13..0cc816992 100644 --- a/pkg/highway/build.zig +++ b/pkg/highway/build.zig @@ -20,7 +20,11 @@ pub fn build(b: *std.Build) !void { }), .linkage = .static, }); - lib.linkLibCpp(); + // On MSVC, the C++ standard library is provided by the MSVC runtime + // and linking Zig's bundled libc++ would conflict with it. + if (target.result.abi != .msvc) { + lib.linkLibCpp(); + } if (upstream_) |upstream| { lib.addIncludePath(upstream.path("")); module.addIncludePath(upstream.path("")); diff --git a/pkg/simdutf/build.zig b/pkg/simdutf/build.zig index 8dcd141c1..6a9445bfe 100644 --- a/pkg/simdutf/build.zig +++ b/pkg/simdutf/build.zig @@ -12,7 +12,11 @@ pub fn build(b: *std.Build) !void { }), .linkage = .static, }); - lib.linkLibCpp(); + // On MSVC, the C++ standard library is provided by the MSVC runtime + // and linking Zig's bundled libc++ would conflict with it. + if (target.result.abi != .msvc) { + lib.linkLibCpp(); + } lib.addIncludePath(b.path("vendor")); if (target.result.os.tag.isDarwin()) { diff --git a/pkg/utfcpp/build.zig b/pkg/utfcpp/build.zig index 08efb4ac8..27b0ebaa2 100644 --- a/pkg/utfcpp/build.zig +++ b/pkg/utfcpp/build.zig @@ -12,7 +12,11 @@ pub fn build(b: *std.Build) !void { }), .linkage = .static, }); - lib.linkLibCpp(); + // On MSVC, the C++ standard library is provided by the MSVC runtime + // and linking Zig's bundled libc++ would conflict with it. + if (target.result.abi != .msvc) { + lib.linkLibCpp(); + } if (target.result.os.tag.isDarwin()) { const apple_sdk = @import("apple_sdk"); diff --git a/src/build/GhosttyZig.zig b/src/build/GhosttyZig.zig index e63120e74..3a40e521e 100644 --- a/src/build/GhosttyZig.zig +++ b/src/build/GhosttyZig.zig @@ -64,8 +64,10 @@ fn initVt( .optimize = cfg.optimize, // SIMD require libc/libcpp (both) but otherwise we don't care. + // On MSVC, the C++ standard library is provided by the MSVC runtime + // and linking libc++ would conflict with it. .link_libc = if (cfg.simd) true else null, - .link_libcpp = if (cfg.simd) true else null, + .link_libcpp = if (cfg.simd and cfg.target.result.abi != .msvc) true else null, }); vt.addOptions("build_options", general_options); vt_options.add(b, vt); diff --git a/src/build/SharedDeps.zig b/src/build/SharedDeps.zig index bc6fb19aa..475bf626f 100644 --- a/src/build/SharedDeps.zig +++ b/src/build/SharedDeps.zig @@ -399,8 +399,12 @@ pub fn add( step.addIncludePath(b.path("src/apprt/gtk")); } - // libcpp is required for various dependencies - step.linkLibCpp(); + // libcpp is required for various dependencies. On MSVC, the C++ + // standard library is provided by the MSVC runtime and linking + // libc++ would conflict with it. + if (step.rootModuleTarget().abi != .msvc) { + step.linkLibCpp(); + } // We always require the system SDK so that our system headers are available. // This makes things like `os/log.h` available for cross-compiling. diff --git a/src/simd/codepoint_width.cpp b/src/simd/codepoint_width.cpp index 4eb7da66d..294922c65 100644 --- a/src/simd/codepoint_width.cpp +++ b/src/simd/codepoint_width.cpp @@ -6,6 +6,7 @@ #include #include +#include HWY_BEFORE_NAMESPACE(); namespace ghostty { diff --git a/src/simd/index_of.h b/src/simd/index_of.h index 8c214d9d0..531af9f8f 100644 --- a/src/simd/index_of.h +++ b/src/simd/index_of.h @@ -6,6 +6,8 @@ #endif #include + +#include #include HWY_BEFORE_NAMESPACE();