Skip to content

Commit

Permalink
Restore build with some mingw.org compilers using mingw runtimes >= 3.21
Browse files Browse the repository at this point in the history
MinGW runtime version 3.21 added a definition of mkstemp(), so requires a
fix similar to f33b2f5 for MinGW-w64's runtime 4.0 onwards.

Based on a patch by Dan Collins on GH#15446.

This commit also tweaks 43b3b04, having discovered that mingw runtime
3.22 also contains a definition of timespec.

For me, this fixes the build with my mingw.org 5.3.0 compiler using any of
the mingw runtimes 3.21, 3.22.4 or 5.0 without breaking older versions such
as 4.9.3 with the 3.20 runtime (or even with the withdrawn 4.0.3 runtime,
which had __MINGW32_MAJOR/MINOR_VERSION set to 3.20 whilst adding new a
__MINGW_MAJOR/MINOR_VERSION set to 4.0).

However, 6.3.0 and 7.3.0 have other issues when compiling win32sck.c, while
8.2.0 and 9.2.0 have other issues again when compiling win32.c. See
GH#18510 for more details.

Also, C++ mode builds with some MinGW/MinGW-w64 compilers are still broken,
as documented in 8a217c9. See GH#16459 for more details.
  • Loading branch information
steve-m-hay committed Jan 26, 2021
1 parent fc65ff1 commit 341a561
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
8 changes: 3 additions & 5 deletions README.win32
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ following compilers on the Intel x86 architecture:

Microsoft Visual C++ version 6.0 or later
Intel C++ Compiler (experimental)
Gcc by mingw.org gcc version 3.4.5 or later
with runtime < 3.21
Gcc by mingw.org gcc version 3.4.5-5.3.0
Gcc by mingw-w64.org gcc version 4.4.3 or later

Note that the last two of these are actually competing projects both
Expand Down Expand Up @@ -324,8 +323,7 @@ L<http://www.mingw-w64.org/>

You also need dmake or gmake. See L</"Make"> above on how to get it.

Note that the MinGW build currently requires a MinGW runtime version earlier
than 3.21 (check __MINGW32_MAJOR_VERSION and __MINGW32_MINOR_VERSION).
Note that the MinGW build currently fails with version 6.3.0 or later.

Note also that the C++ mode build currently fails with MinGW 3.4.5 and 4.7.2
or later, and with MinGW64 64-bit 6.3.0 or later.
Expand Down Expand Up @@ -970,6 +968,6 @@ Win9x support was added in 5.6 (Benjamin Stuhl).

Support for 64-bit Windows added in 5.8 (ActiveState Corp).

Last updated: 30 April 2019
Last updated: 26 January 2020

=cut
5 changes: 3 additions & 2 deletions dist/Time-HiRes/HiRes.xs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ typedef struct {
} my_cxt_t;

/* Visual C++ 2013 and older don't have the timespec structure.
* Neither do mingw.org compilers with MinGW runtimes older than 5.0. */
* Neither do mingw.org compilers with MinGW runtimes older than 3.22. */
# if((defined(_MSC_VER) && _MSC_VER < 1900) || \
(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) && \
defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION < 5))
defined(__MINGW32_MAJOR_VERSION) && (__MINGW32_MAJOR_VERSION < 3 || \
(__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION < 22))))
struct timespec {
time_t tv_sec;
long tv_nsec;
Expand Down
5 changes: 4 additions & 1 deletion pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ L</Modules and Pragmata> section.
=item Windows

Building with mingw.org compilers (version 3.4.5 or later) using mingw runtime
versions < 5.0 now works again. This was broken in Perl 5.31.4.
versions < 3.22 now works again. This was broken in Perl 5.31.4.

Building with mingw.org compilers (version 3.4.5 or later) using mingw runtime
versions >= 3.21 now works (for compilers up to version 5.3.0).

=back

Expand Down
2 changes: 1 addition & 1 deletion win32/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile to build perl on Windows using GMAKE.
# Supported compilers:
# Microsoft Visual C++ 7.0 or later
# MinGW with gcc-3.4.5 or later with runtime < 3.21
# MinGW with gcc-3.4.5-5.3.0
# MinGW64 with gcc-4.4.3 or later
# Windows SDK 64-bit compiler and tools
#
Expand Down
2 changes: 1 addition & 1 deletion win32/makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile to build perl on Windows using DMAKE.
# Supported compilers:
# Microsoft Visual C++ 7.0 or later
# MinGW with gcc-3.4.5 or later with runtime < 3.21
# MinGW with gcc-3.4.5-5.3.0
# MinGW64 with gcc-4.4.3 or later
# Windows SDK 64-bit compiler and tools
#
Expand Down
4 changes: 3 additions & 1 deletion win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,9 @@ chown(const char *path, uid_t owner, gid_t group)
* XXX this needs strengthening (for PerlIO)
* -- BKS, 11-11-200
*/
#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 4
#if((!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 4) && \
(!defined(__MINGW32_MAJOR_VERSION) || __MINGW32_MAJOR_VERSION < 3 || \
(__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION < 21)))
int mkstemp(const char *path)
{
dTHX;
Expand Down
4 changes: 3 additions & 1 deletion win32/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ extern void *sbrk(ptrdiff_t need);
#endif
extern char * getlogin(void);
extern int chown(const char *p, uid_t o, gid_t g);
#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 4
#if((!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 4) && \
(!defined(__MINGW32_MAJOR_VERSION) || __MINGW32_MAJOR_VERSION < 3 || \
(__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION < 21)))
extern int mkstemp(const char *path);
#endif
#endif
Expand Down

0 comments on commit 341a561

Please sign in to comment.