aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-10-16 10:20:52 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-10-16 12:21:46 -0400
commitcbb6d2239f84ee13279655fc591530a23301d188 (patch)
treec89c4ecb59a0a91521ff32b81755ac56fb9336d7 /src/analyze.cpp
parent8cfb0cfbcee8161c52f71bccc3cf1b8d988f83b0 (diff)
downloadzig-cbb6d2239f84ee13279655fc591530a23301d188.tar.gz
zig-cbb6d2239f84ee13279655fc591530a23301d188.zip
look for libc at runtime on windows
See #539 before we close the issue we should also detect MSVC 2017 but this gets us started with supporting MSVC 2015
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 3bb4fe6511..292943a6e6 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -3359,6 +3359,61 @@ void find_libc_include_path(CodeGen *g) {
}
void find_libc_lib_path(CodeGen *g) {
+#ifdef ZIG_OS_WINDOWS
+ if (!g->msvc_lib_dir && g->zig_target.os == ZigLLVM_Win32) {
+ Buf *msvc_lib_dir;
+ if (g->zig_target.arch.arch == ZigLLVM_arm) {
+ msvc_lib_dir = buf_create_from_str("C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\arm");
+ } else if (g->zig_target.arch.arch == ZigLLVM_x86_64) {
+ msvc_lib_dir = buf_create_from_str("C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\amd64");
+ } else if (g->zig_target.arch.arch == ZigLLVM_x86) {
+ msvc_lib_dir = buf_create_from_str("C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib");
+ } else {
+ zig_panic("unable to determine msvc lib path");
+ }
+ Buf *test_path = buf_alloc();
+ os_path_join(msvc_lib_dir, buf_create_from_str("vcruntime.lib"), test_path);
+ bool result;
+ int err;
+ if ((err = os_file_exists(test_path, &result))) {
+ result = false;
+ }
+ if (result) {
+ g->msvc_lib_dir = msvc_lib_dir;
+ } else {
+ zig_panic("Unable to determine msvc lib path.");
+ }
+ }
+
+ if (!g->kernel32_lib_dir && g->zig_target.os == ZigLLVM_Win32) {
+ Buf *kernel32_lib_dir;
+ if (g->zig_target.arch.arch == ZigLLVM_arm) {
+ kernel32_lib_dir = buf_create_from_str(
+ "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\arm");
+ } else if (g->zig_target.arch.arch == ZigLLVM_x86_64) {
+ kernel32_lib_dir = buf_create_from_str(
+ "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x64");
+ } else if (g->zig_target.arch.arch == ZigLLVM_x86) {
+ kernel32_lib_dir = buf_create_from_str(
+ "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x86");
+ } else {
+ zig_panic("unable to determine kernel32 lib path");
+ }
+ Buf *test_path = buf_alloc();
+ os_path_join(kernel32_lib_dir, buf_create_from_str("kernel32.lib"), test_path);
+ bool result;
+ int err;
+ if ((err = os_file_exists(test_path, &result))) {
+ result = false;
+ }
+ if (result) {
+ g->kernel32_lib_dir = kernel32_lib_dir;
+ } else {
+ zig_panic("Unable to determine kernel32 lib path.");
+ }
+ }
+#endif
+
// later we can handle this better by reporting an error via the normal mechanism
if (!g->libc_lib_dir || buf_len(g->libc_lib_dir) == 0) {
zig_panic("Unable to determine libc lib path.");