authorgravatar for emekankurumeh@outlook.comemekoi <emekankurumeh@outlook.com> 2019-03-30 00:06:04-05:00
committergravatar for emekankurumeh@outlook.comemekoi <emekankurumeh@outlook.com> 2019-04-04 21:07:02-05:00
log0bd4901a174786a61fadf484f3b8932169533cd4
tree550d8a86da1b885fa0dc8085a2e9aa16accd2c2d
parent6cc443ee457d06ea23713bb78ab832d886029d57

fixed linking of system libraries on mingw


2 files changed, 17 insertions(+), 11 deletions(-)

src/libc_installation.hpp-2
...@@ -29,8 +29,6 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file);...@@ -29,8 +29,6 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file);
2929
30Error ATTRIBUTE_MUST_USE zig_libc_find_native(ZigLibCInstallation *self, bool verbose);30Error ATTRIBUTE_MUST_USE zig_libc_find_native(ZigLibCInstallation *self, bool verbose);
3131
32#if defined(ZIG_OS_LINUX) || defined(ZIG_OS_WINDOWS)
33Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want_dirname, bool verbose);32Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want_dirname, bool verbose);
34#endif
3533
36#endif34#endif
src/link.cpp+17-9
...@@ -1359,17 +1359,25 @@ static void construct_linker_job_coff(LinkJob *lj) {...@@ -1359,17 +1359,25 @@ static void construct_linker_job_coff(LinkJob *lj) {
1359 }1359 }
1360 if (link_lib->provided_explicitly) {1360 if (link_lib->provided_explicitly) {
1361 if (target_abi_is_gnu(lj->codegen->zig_target->abi)) {1361 if (target_abi_is_gnu(lj->codegen->zig_target->abi)) {
1362 static const char *test_names[3] = { "lib%s.dll.a", "lib%s.a", nullptr };1362 static const char *test_names[3] = { "%s\\lib%s.dll.a", "%s\\lib%s.a", nullptr };
13631363 bool exists = false;
1364 for (size_t i = 0; test_names[i] != nullptr; i++) {1364
1365 Buf *test_path = buf_sprintf(test_names[i], buf_ptr(link_lib->name));1365 for (size_t i = 0; test_names[i] != nullptr && !exists; i++) {
1366 bool exists = false;1366 for (size_t j = 0; j < g->lib_dirs.length; j += 1) {
1367 if (os_file_exists(test_path, &exists) != ErrorNone) {1367 const char *lib_dir = g->lib_dirs.at(j);
1368 zig_panic("link: unable to check if file exists: %s", buf_ptr(test_path));1368 Buf *test_path = buf_sprintf(test_names[i], lib_dir, buf_ptr(link_lib->name));
1369 } else if (exists) {1369 if (os_file_exists(test_path, &exists) != ErrorNone) {
1370 lj->args.append(buf_ptr(test_path));1370 zig_panic("link: unable to check if file exists: %s", buf_ptr(test_path));
1371 } else if (exists) {
1372 lj->args.append(buf_ptr(test_path));
1373 break;
1374 }
1371 }1375 }
1372 }1376 }
1377
1378 if (!exists) {
1379 zig_panic("link: unable to find library: %s", buf_ptr(link_lib->name));
1380 }
1373 } else {1381 } else {
1374 lj->args.append(buf_ptr(link_lib->name));1382 lj->args.append(buf_ptr(link_lib->name));
1375 }1383 }