When cross-compiling for windows from linux, what is the difference between using targets:
zig build -Dtarget=native-windows-gnu
zig build -Dtarget=native-windows-msvc
?
It appears that -msvc is impossible to do from linux if I need to link libc, because I would need to install the windows sdk on linux which is impossible?
Targeting the msvc ABI means using the headers/libraries from the Windows SDK/MSVC. Those are under a proprietary license which means that they cannot be distributed. When targeting msvc, Zig attempts to find the location of those headers/libraries using techniques similar to those used in vswhere (registry lookups, etc). This means that the msvc target will effectively only work when the host system is Windows (and the host system needs the SDK/MSVC files installed separately from Zig).
MinGW (which is what the gnu ABI means when targeting Windows) is an effort to provide those same headers/libraries (in terms of ABI-compatibility) that can actually be distributed, and Zig in turn does distribute them. This means that Zig is able to target the gnu ABI for Windows from any host system (and that capability only depends on the Zig installation itself).
So, basically, if you want cross-compilation for Windows targets and are linking libc, then you’ll want to get things working with the gnu ABI.
Here’s an issue from when Zig switched the default Windows ABI from msvc to gnu: