From 5aa281250723c159aa0429941c16b046bba6d316 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 29 Mar 2020 13:17:21 -0400 Subject: [PATCH] linking is now aware -lm is provided by mingw-w64 --- src/link.cpp | 9 +++++++-- src/target.cpp | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/link.cpp b/src/link.cpp index 1a454531b588d355a840c674580e8bb132093807..693aaca0e3520e6e4d177d3c4b9e21af17d2d7bb 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -1903,7 +1903,7 @@ static void construct_linker_job_elf(LinkJob *lj) { // libc is linked specially continue; } - if (buf_eql_str(link_lib->name, "c++") || buf_eql_str(link_lib->name, "c++abi")) { + if (target_is_libcpp_lib_name(g->zig_target, buf_ptr(link_lib->name))) { // libc++ is linked specially continue; } @@ -2470,7 +2470,12 @@ static void construct_linker_job_coff(LinkJob *lj) { if (buf_eql_str(link_lib->name, "c")) { continue; } - if (buf_eql_str(link_lib->name, "c++") || buf_eql_str(link_lib->name, "c++abi")) { + if (target_is_libcpp_lib_name(g->zig_target, buf_ptr(link_lib->name))) { + // libc++ is linked specially + continue; + } + if (g->libc == nullptr && target_is_libc_lib_name(g->zig_target, buf_ptr(link_lib->name))) { + // these libraries are always linked below when targeting glibc continue; } bool is_sys_lib = is_mingw_link_lib(link_lib->name); diff --git a/src/target.cpp b/src/target.cpp index 59b1addc33e4d4d508d3fa220273ce18e9f0d9af..030721683430dd482ee8c4f2cef9871b1392c908 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -1207,6 +1207,15 @@ bool target_is_libc_lib_name(const ZigTarget *target, const char *name) { if (strcmp(name, "c") == 0) return true; + if (target_abi_is_gnu(target->abi) && target->os == OsWindows) { + // mingw-w64 + + if (strcmp(name, "m") == 0) + return true; + + return false; + } + if (target_abi_is_gnu(target->abi) || target_abi_is_musl(target->abi) || target_os_is_darwin(target->os)) { if (strcmp(name, "m") == 0) return true; -- 2.54.0