-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Currently if you download Zig on Windows, and then try to build some C code, without MSVC installed, you get an error saying that Zig cannot find or provide a libc. This is a shame because we actually can provide a libc! The magic sauce is -target native-native-gnu which uses mingw-w64 to provide libc.
This proposal is to make -gnu the default on windows rather than -msvc. This C ABI is binary-compatible with MSVC-compiled code, however the header files are not source-compatible with MSVC libc header files. When zig is responsible for compiling all of the C, C++, and Zig code for a given project, then there is 0 downsides to using mingw-w64 as the C ABI. The upsides are huge: no dependency on MSVC being installed. Zig acts as a C and C++ compiler that works out of the box, without MSVC installed.
I discussed this with @mlarouche on IRC and he indicated that it may sometimes be useful to specify -target native-native-msvc but that it does make sense to make the default mingw-w64.
Some more tid bits:
- the plan is to make it .obj instead of .o always for coff, and to always use .lib (not .a) for libraries, ignoring gnu conventions
- libc_installation.zig: make it look for msvc only if msvc abi is chosen
Related: #6363