vezel-dev / zig-sdk

An MSBuild SDK for building Zig, C, and C++ projects using the Zig compiler.

Home Page:https://docs.vezel.dev/zig-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a way to switch between Mingw-w64 and MSVC ABIs

alexrp opened this issue · comments

It's generally fine to mix C++ code compiled for different ABIs as long as the code using each ABI is isolated in separate modules and those modules only talk through a C interface.

Unfortunately, things are not so simple when linking to a static library that contains C++ code. If that code is not compiled for the ABI being targeted, things break in all sorts of ways at link time. This is only really a problem on Windows where there are two major C++ ABIs: MSVC and Mingw-w64.

To enable users to link to static libraries compiled for the MSVC ABI, there needs to be a property to control the ABI on Windows. We should still default to the Mingw-w64 ABI since that's amenable to cross-compilation, but if Zig grows support for cross-compiling for the MSVC ABI one day, we will likely want to switch the default to that.