diff options
| author | Dimenus <rsdimenus@gmail.com> | 2017-11-01 14:33:14 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-11-01 15:33:14 -0400 |
| commit | 38f05d4ac59aa799f947ae1fb4671acafcc283cb (patch) | |
| tree | 1fecfc847e94b56b5f8ccda5a5d0ee79464725cd /src/main.cpp | |
| parent | b35689b70de2da0c28d4d6ab56e2987cddf80e77 (diff) | |
| download | zig-38f05d4ac59aa799f947ae1fb4671acafcc283cb.tar.gz zig-38f05d4ac59aa799f947ae1fb4671acafcc283cb.zip | |
WIN32: Linking with the CRT at runtime. (#570)
Disclaimer: Forgive me if my format sucks, I've never submitted a PR before!
Fixes: #517
I added a few things to allow zig to link with the CRT properly both statically and dynamically. In Visual Studio 2017, Microsoft changed how the c-runtime is factored again. With this change, they also added a COM interface to allow you to query the respective Visual Studio instance for two of them. This does that and also falls back on a registry query for 2015 support. If you're using a Visual Studio instance older than 2015, you'll have to use the existing options available with the zig compiler. Changes are listed below along with a general description of the changes.
all_types.cpp:
The separate variables for msvc/kern32 have been removed and all win32 libc directory paths have been combined into a ZigList since we're querying more than two directories and differentiating one from another doesn't matter to lld.
analyze.cpp:
The existing functions were extended to support querying libc libs & libc headers at runtime.
codegen.cpp/hpp:
Microsoft uses the new 'Universal C Runtime' name now. Doesn't matter from a functionality standpoint. I left the compiler switches as is to not introduce any breaking changes.
link.cpp:
We're linking 4 libs and generating another in order to support the UCRT.
Dynamic: msvcrt/d, vcruntime/d, ucrt/d, legacy_stdio_definitions.lib
Static: libcmt/d, libvcruntime/d libucrt/d, legacy_stdio_definitions.lib
main.cpp:
Update function call names.
os.cpp/hpp:
COM/Registry interface for querying Windows UCRT/SDK.
Sources:
[Windows CRT](https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features)
[VS 2015 Breaking Changes](https://msdn.microsoft.com/en-us/library/bb531344.aspx)
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 358f1cf255..b3622a4e43 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -758,7 +758,7 @@ int main(int argc, char **argv) { if (libc_include_dir) codegen_set_libc_include_dir(g, buf_create_from_str(libc_include_dir)); if (msvc_lib_dir) - codegen_set_msvc_lib_dir(g, buf_create_from_str(msvc_lib_dir)); + codegen_set_ucrt_lib_dir(g, buf_create_from_str(msvc_lib_dir)); if (kernel32_lib_dir) codegen_set_kernel32_lib_dir(g, buf_create_from_str(kernel32_lib_dir)); if (dynamic_linker) |
