luasocket icon indicating copy to clipboard operation
luasocket copied to clipboard

Remove LUASOCKET_INET_PTON from *.rockspec

Open kou opened this issue 4 years ago • 12 comments

Recent MinGW provides inet_pton(). There is our inet_pton() implementation in src/inet.c. Our inet_pton() is declared in src/inet.h but the declaration causes the following build error:

gcc -O2 -fPIC -c -o src/luasocket.o -IC://msys64/mingw64/include/luajit-2.0 src/luasocket.c -DLUA_COMPAT_APIINTCASTS -DLUASOCKET_DEBUG -DLUASOCKET_INET_PTON -DWINVER=0x0501 -DLUASOCKET_API=__declspec(dllexport) -DMIME_API=__declspec(dllexport)

src/inet.h:46:13: error: conflicting types for 'inet_ntop'
   46 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
      |             ^~~~~~~~~

In file included from src/wsocket.h:12,
                 from src/socket.h:18,
                 from src/inet.h:18,
                 from src/luasocket.c:30:
C:/msys64/mingw64/x86_64-w64-mingw32/include/ws2tcpip.h:451:35: note: previous declaration of 'inet_ntop' was
 here
  451 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize);
      |                                   ^~~~~~~~~

In file included from src/luasocket.c:30:
src/inet.h:47:5: warning: 'inet_pton' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   47 | int inet_pton(int af, const char *src, void *dst);
      |     ^~~~~~~~~

We already know that we don't need our inet_pton() for recent MinGW. 78a1657c7db5510ba66f8d4491f1e8e7370c5943 (#300) removed -DLUASOCKET_INET_PTON but LUASOCKET_INET_PTON in *.rockspec wasn't removed.

It causes "luarocks install luasocket" for MinGW causes the above build error.

kou avatar Jul 10 '20 07:07 kou

See also #298 and #300.

kou avatar Jul 10 '20 07:07 kou

As mentioned in the linked issues, we are looking for a solution that helps users of newer MinGW while continuing to work (conditionally) for users with older MinGW versions.

ewestbrook avatar Jul 10 '20 16:07 ewestbrook

OK. How about 3b7b079 ? We can detect whether our inet_pton() is needed or not by checking InetPtonA.

I can't test this on Windows XP but it'll work.

kou avatar Jul 10 '20 21:07 kou

@ewestbrook Could you review again?

kou avatar Jul 28 '20 23:07 kou

Thanks for approving this! What should we do to merge this into the master?

kou avatar Jul 31 '20 00:07 kou

Calling @diegonehab to the white courtesy telephone, please

ewestbrook avatar Jul 31 '20 00:07 ewestbrook

My question is this: MinGW is a way to compile stuff for Windows. It is supposed to be compatible with, or to replace Visual Studio. Somehow they added this incompatibility. What I want to avoid is to fix MinGW in a way that breaks Visual Studio. Does that make sense? Visual Studio is also free. Can somebody verify this?

diegonehab avatar Jul 31 '20 13:07 diegonehab

How about adding CI jobs for MinGW and Visual Studio? If it makes sense, I'll create a separated pull request for it.

kou avatar Jul 31 '20 21:07 kou

This would be great. Can we integrate VS with github CI?

diegonehab avatar Aug 01 '20 20:08 diegonehab

Yes. GitHub Actions provides Visual Studio 2019 on windows-2019 image https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#visual-studio-enterprise-2019 and Visual Studio 2017 on windows-2016 image https://github.com/actions/virtual-environments/blob/main/images/win/Windows2016-Readme.md#visual-studio-enterprise-2017 .

I'll work on it.

kou avatar Aug 01 '20 20:08 kou

@diegonehab Could you confirm #315?

kou avatar Aug 06 '20 00:08 kou

I'll rebase this on master once #315 is merged.

kou avatar Aug 06 '20 00:08 kou

It seems that #383 fixed this. I close this.

kou avatar Nov 09 '23 00:11 kou

Thanks for the feedback on where your PRs were at. Sorry your contributions didn't get recognized because some work got duplicated in the shuffle. If there are any more issues / PRs that you happen to know the status of or can test (especially Windows related stuff that I'm not in a position to test) I'd be happy to see cleanup keep moving forward.

alerque avatar Nov 09 '23 10:11 alerque

No problem! I don't have any more issues/PRs.

kou avatar Nov 09 '23 20:11 kou