Re: [Mingw-w64-public] Patch WS2 Inline Functions
On Thu, 22 Jul 2021, Jonathan Marler wrote: The linker errors were found by a Zig user and I took up the challenge to fix it (original issue here: https://github.com/ziglang/zig/issues/9364) Zig's using clang under the hood and on top of it, it adds automatic dynamic compilation of various libc implementations/bindings. For windows it dynamically builds .lib files from the mingw .def files as I understand(see https://github.com/ziglang/zig/blob/18b8738069268cc913bbae9580d2d1 70618a2ae9/src/mingw.zig#L277). It looks like it also builds .a files but ws2_32 seems to have been left out for some reason. Oh, I see. Yes, that definitely explains the issue. Some libraries (lib*crt*, libmingwex) contain a quite volatile set of object files, and we tweak exactly which object files go into which library (on which arch, because there are differences) regularly - I'd hope that Zig keeps up with these changes too. // Martin ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] Patch WS2 Inline Functions
The linker errors were found by a Zig user and I took up the challenge to fix it (original issue here: https://github.com/ziglang/zig/issues/9364) Zig's using clang under the hood and on top of it, it adds automatic dynamic compilation of various libc implementations/bindings. For windows it dynamically builds .lib files from the mingw .def files as I understand (see https://github.com/ziglang/zig/blob/18b8738069268cc913bbae9580d2d170618a2ae9/src/mingw.zig#L277). It looks like it also builds .a files but ws2_32 seems to have been left out for some reason. On Thu, Jul 22, 2021 at 3:48 PM Martin Storsjö wrote: > Hi, > > On Thu, 22 Jul 2021, Jonathan Marler wrote: > > > Yes I think the problem was with my environment. I had libws2_32.lib > > available but did not have libws2_32.a, so I was missing the symbols > coming > > from the source files in ming2-w64-crt. Thanks for the clarification. > > Hmm, ok, that's definitely your issue then. (Where do you get such a file > even - from the WinSDK? Because mingw-w64 itself doesn't produce any *.lib > files at all.) > > // Martin > ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] Patch WS2 Inline Functions
Hi, On Thu, 22 Jul 2021, Jonathan Marler wrote: Yes I think the problem was with my environment. I had libws2_32.lib available but did not have libws2_32.a, so I was missing the symbols coming from the source files in ming2-w64-crt. Thanks for the clarification. Hmm, ok, that's definitely your issue then. (Where do you get such a file even - from the WinSDK? Because mingw-w64 itself doesn't produce any *.lib files at all.) // Martin ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] Patch WS2 Inline Functions
Thanks Martin, Yes I think the problem was with my environment. I had libws2_32.lib available but did not have libws2_32.a, so I was missing the symbols coming from the source files in ming2-w64-crt. Thanks for the clarification. On Thu, Jul 22, 2021 at 3:33 AM Martin Storsjö wrote: > On Wed, 21 Jul 2021, Jonathan Marler wrote: > > > Yeah definitely revert, those redefinition errors are bad news. > > The problem though is that I still get these undefined symbol errors > > even with -lws2_32 with Clang. Forgive me if I'm mistaken here, but in > > order for these symbols to be available, don't they need to be in > > ws2_32.def? Is that right? If so, I don't see them in there which is > > why I think I'm getting the linker errors. > > Your original testcase you posted works exactly the same for me with both > GCC and Clang: > > $ cat ws.c > #include > int main(int argc, char **argv) { > return (int)&IN6_IS_ADDR_UNSPECIFIED; > } > $ x86_64-w64-mingw32-gcc ws.c -w > /usr/bin/x86_64-w64-mingw32-ld: > /tmp/ccvc4epM.o:ws.c:(.rdata$.refptr.IN6_IS_ADDR_UNSPECIFIED[.refptr.IN6_IS_ADDR_UNSPECIFIED]+0x0): > > undefined reference to `IN6_IS_ADDR_UNSPECIFIED' > collect2: error: ld returned 1 exit status > $ x86_64-w64-mingw32-gcc ws.c -w -lws2_32 > $ > $ x86_64-w64-mingw32-clang ws.c -w > ld.lld: error: undefined symbol: IN6_IS_ADDR_UNSPECIFIED > >>> referenced by /tmp/ws-2350d6.o:(main) > clang-13: error: linker command failed with exit code 1 (use -v to see > invocation) > $ x86_64-w64-mingw32-clang ws.c -w -lws2_32 > $ > > The symbol doesn't have to be in ws2_32.def, libws2_32.a consists of both > import entries (based on the def file) and statically linked regular > object files. Check the file with nm libws2_32.a to see what it contains. > > // Martin > ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH] crt: Add missing exports in ws2_32.def
From 669dd778642674b8522daa4c969c0413badc7be4 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Thu, 22 Jul 2021 19:57:06 +0530 Subject: [PATCH] crt: Add missing exports in ws2_32.def Signed-off-by: Biswapriyo Nath --- mingw-w64-crt/lib-common/ws2_32.def.in | 1 + mingw-w64-crt/lib32/ws2_32.def | 14 ++ 2 files changed, 15 insertions(+) diff --git a/mingw-w64-crt/lib-common/ws2_32.def.in b/mingw-w64-crt/lib-common/ws2_32.def.in index 4789b77..b49c4b8 100644 --- a/mingw-w64-crt/lib-common/ws2_32.def.in +++ b/mingw-w64-crt/lib-common/ws2_32.def.in @@ -38,6 +38,7 @@ GetHostNameW GetNameInfoW InetNtopW InetPtonW +ProcessSocketNotifications SetAddrInfoExA SetAddrInfoExW WPUCompleteOverlappedRequest diff --git a/mingw-w64-crt/lib32/ws2_32.def b/mingw-w64-crt/lib32/ws2_32.def index 19f3f69..f78defc 100644 --- a/mingw-w64-crt/lib32/ws2_32.def +++ b/mingw-w64-crt/lib32/ws2_32.def @@ -33,14 +33,19 @@ FreeAddrInfoEx@4 FreeAddrInfoExW@4 FreeAddrInfoW@4 GetAddrInfoExA@40 +GetAddrInfoExCancel@4 +GetAddrInfoExOverlappedResult@4 GetAddrInfoExW@40 GetAddrInfoW@16 +GetHostNameW@8 GetNameInfoW@28 InetNtopW@16 InetPtonW@12 +ProcessSocketNotifications@28 SetAddrInfoExA@48 SetAddrInfoExW@48 WPUCompleteOverlappedRequest@20 +WPUGetProviderPathEx@20 WSAAccept@20 WSAAddressToStringA@20 WSAAddressToStringW@20 @@ -126,21 +131,30 @@ WSAStringToAddressW@20 WSAUnadvertiseProvider@4 WSAWaitForMultipleEvents@20 WSCDeinstallProvider@8 +WSCDeinstallProviderEx@12 WSCEnableNSProvider@8 WSCEnumProtocols@16 +WSCEnumProtocolsEx@20 WSCGetApplicationCategory@24 +WSCGetApplicationCategoryEx@28 WSCGetProviderInfo@24 WSCGetProviderPath@16 WSCInstallNameSpace@20 +WSCInstallNameSpaceEx2@28 WSCInstallNameSpaceEx@24 WSCInstallProvider@20 WSCInstallProviderAndChains@32 +WSCInstallProviderEx@28 WSCSetApplicationCategory@28 +WSCSetApplicationCategoryEx@32 WSCSetProviderInfo@24 WSCUnInstallNameSpace@4 +WSCUnInstallNameSpaceEx2@8 WSCUpdateProvider@20 +WSCUpdateProviderEx@24 WSCWriteNameSpaceOrder@8 WSCWriteProviderOrder@8 +WSCWriteProviderOrderEx@12 WahCloseApcHelper@4 WahCloseHandleHelper@4 WahCloseNotificationHandleHelper@4 -- 2.32.0 ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] Patch WS2 Inline Functions
On Wed, 21 Jul 2021, Jonathan Marler wrote: Yeah definitely revert, those redefinition errors are bad news. The problem though is that I still get these undefined symbol errors even with -lws2_32 with Clang. Forgive me if I'm mistaken here, but in order for these symbols to be available, don't they need to be in ws2_32.def? Is that right? If so, I don't see them in there which is why I think I'm getting the linker errors. Your original testcase you posted works exactly the same for me with both GCC and Clang: $ cat ws.c #include int main(int argc, char **argv) { return (int)&IN6_IS_ADDR_UNSPECIFIED; } $ x86_64-w64-mingw32-gcc ws.c -w /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccvc4epM.o:ws.c:(.rdata$.refptr.IN6_IS_ADDR_UNSPECIFIED[.refptr.IN6_IS_ADDR_UNSPECIFIED]+0x0): undefined reference to `IN6_IS_ADDR_UNSPECIFIED' collect2: error: ld returned 1 exit status $ x86_64-w64-mingw32-gcc ws.c -w -lws2_32 $ $ x86_64-w64-mingw32-clang ws.c -w ld.lld: error: undefined symbol: IN6_IS_ADDR_UNSPECIFIED referenced by /tmp/ws-2350d6.o:(main) clang-13: error: linker command failed with exit code 1 (use -v to see invocation) $ x86_64-w64-mingw32-clang ws.c -w -lws2_32 $ The symbol doesn't have to be in ws2_32.def, libws2_32.a consists of both import entries (based on the def file) and statically linked regular object files. Check the file with nm libws2_32.a to see what it contains. // Martin ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public