Commit 96ebd8b23b

Andrew Kelley <superjoe30@gmail.com>
2018-04-17 04:33:34
fix windows not respecting --msvc-lib-dir, --kernel32-lib-dir
I believe this was a regression caused by 51a6ff18d454f4cb0faa0f1837df9f0c55a80b43 closes #927
1 parent c7cb5c3
Changed files (1)
src/analyze.cpp
@@ -4421,24 +4421,30 @@ void find_libc_lib_path(CodeGen *g) {
         if (g->zig_target.os == OsWindows) {
             ZigWindowsSDK *sdk = get_windows_sdk(g);
 
-            Buf* vc_lib_dir = buf_alloc();
-            if (os_get_win32_vcruntime_path(vc_lib_dir, g->zig_target.arch.arch)) {
-                zig_panic("Unable to determine vcruntime path.");
+            if (g->msvc_lib_dir == nullptr) {
+                Buf* vc_lib_dir = buf_alloc();
+                if (os_get_win32_vcruntime_path(vc_lib_dir, g->zig_target.arch.arch)) {
+                    zig_panic("Unable to determine vcruntime path.");
+                }
+                g->msvc_lib_dir = vc_lib_dir;
             }
 
-            Buf* ucrt_lib_path = buf_alloc();
-            if (os_get_win32_ucrt_lib_path(sdk, ucrt_lib_path, g->zig_target.arch.arch)) {
-                zig_panic("Unable to determine ucrt path.");
+            if (g->libc_lib_dir == nullptr) {
+                Buf* ucrt_lib_path = buf_alloc();
+                if (os_get_win32_ucrt_lib_path(sdk, ucrt_lib_path, g->zig_target.arch.arch)) {
+                    zig_panic("Unable to determine ucrt path.");
+                }
+                g->libc_lib_dir = ucrt_lib_path;
             }
 
-            Buf* kern_lib_path = buf_alloc();
-            if (os_get_win32_kern32_path(sdk, kern_lib_path, g->zig_target.arch.arch)) {
-                zig_panic("Unable to determine kernel32 path.");
+            if (g->kernel32_lib_dir == nullptr) {
+                Buf* kern_lib_path = buf_alloc();
+                if (os_get_win32_kern32_path(sdk, kern_lib_path, g->zig_target.arch.arch)) {
+                    zig_panic("Unable to determine kernel32 path.");
+                }
+                g->kernel32_lib_dir = kern_lib_path;
             }
 
-            g->msvc_lib_dir = vc_lib_dir;
-            g->libc_lib_dir = ucrt_lib_path;
-            g->kernel32_lib_dir = kern_lib_path;
         } else if (g->zig_target.os == OsLinux) {
             g->libc_lib_dir = get_linux_libc_lib_path("crt1.o");
         } else {