develooper Front page | perl.perl5.porters | Postings from April 2019

Re: [perl #133974] [Win32] Latest devel release (5.29.9) won't buildif _WIN32_WINNT >= 0x0600

Thread Previous
From:
Tomasz Konojacki
Date:
April 2, 2019 07:37
Subject:
Re: [perl #133974] [Win32] Latest devel release (5.29.9) won't buildif _WIN32_WINNT >= 0x0600
Message ID:
20190402093718.B0E1.5C4F47F8@xenu.pl
On Mon, 01 Apr 2019 21:29:50 -0700
"sisyphus \(via RT\)" <perlbug-followup@perl.org> wrote:

> # New Ticket Created by  sisyphus 
> # Please include the string:  [perl #133974]
> # in the subject line of all future correspondence about this issue. 
> # <URL: https://rt.perl.org/Ticket/Display.html?id=133974 >
> 
> 
> This will affect more than perl-5.29.9 - it's just that perl-5.29.9 is the
> first version of perl that I've tried to build using a new gcc-8.2.1
> toolchain built by the MSYS2 project.
> 
> BTW, where is _WIN32_WINNT actually being defined ?
> I couldn't find it - but with this 8.2.1 toolchain it's being defined to
> 0x0601, while earlier compilers set it to 0x0502.

It has nothing to do with the version of MinGW. It can be set using
--with-default-win32-winnt switch in one of MinGW configure scripts and, if
you build it by yourself, the default is still 0x0502:

https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/configure.ac#L144

(the switch affects the _WIN32_WINNT definition in _mingw.h file)

> 
> When it's >= 0x0600, extra stuff gets defined in winsock2.h (including the
> symbol POLLWRBAND), and that prevents dist/IO from compiling.
> 
> A similar thing also happens with cpan/Socket, though I'm not sure whether
> that also traces back to winsock2.h or whether the problem arises
> elsewhere. (I didn't check on that.)
> 
> My workaround was to insert:
> 
> #undef _WIN32_WINNT
> #define _WIN32_WINNT 0x0502
> 
> at the top of:
> 
>  dist/IO/IO.xs
>  dist/IO/poll.c
>  cpan/Socket/Socket.xs
> 
> and that enables the build of 5.29.9 to proceed normally.
> 
> But is that the correct approach to dealing with this issue ?
> Or should we be looking at modifying the perl source such that it doesn't
> need to reduce the value of  _WIN32_WINNT whenever it's >= 0x0600 ?
> 
> Cheers,
> Rob

On non-windows systems we set macros such as _GNU_SOURCE, _XOPEN_SOURCE
or _POSIX_SOURCE in ccflags. Those macros do the same thing as
_WIN32_WINNT, that is, they control the visibility of certain things in
the system headers. IMO we should the same thing with _WIN32_WINNT.

The only problem with this approach is the fact that it will force our
_WIN32_WINNT define on CPAN XS modules, but unfortunately, I don't think
it can be avoided.

BTW, in the future we should consider dropping winxp support and
defining _WIN32_WINNT as 0x0601, but that's another conversation.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About