Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Win32] Latest devel release (5.29.9) won't build if _WIN32_WINNT >= 0x0600 #16917

Closed
p5pRT opened this issue Apr 2, 2019 · 4 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Apr 2, 2019

Migrated from rt.perl.org#133974 (status was 'open')

Searchable as RT133974$

@p5pRT
Copy link
Author

p5pRT commented Apr 2, 2019

From @sisyphus

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.

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

@p5pRT
Copy link
Author

p5pRT commented Apr 2, 2019

From @xenu

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-archive.perl.org/perl5/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.

@p5pRT
Copy link
Author

p5pRT commented Apr 2, 2019

The RT System itself - Status changed from 'new' to 'open'

@sisyphus
Copy link
Contributor

I was about to close this issue, but discovered that I don't have the permissions for that.
If someone else can close it, then please do so (with my blessing).

@leonerd leonerd closed this as completed Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants