Since mingw 13 was made current on Cygwin a couple of days ago [1],
I'm seeing test failures on 32-bit mingw:
* of GNU libunistring: test-lstat fails.
* of GNU gettext: Several tests fail. I can reproduce it manually with
$ ./msgfmt -c -o /dev/null mf-test10.po1
msgfmt.exe: error while writing "/dev/null" file: Input/output error
* of a testdir of modules 'stat' and 'fstat' without module
'windows-stat-timespec'.
FAIL: test-lstat
================
../../gltests/test-lstat.h:33: assertion 'func ("./", &st2) == 0' failed
FAIL test-lstat.exe (exit status: 3)
FAIL: test-stat
===============
../../gltests/test-stat.h:34: assertion 'func ("./", &st2) == 0' failed
FAIL test-stat.exe (exit status: 3)
In this situation (32-bit mingw, without 'windows-stat-timespec'),
REPLACE_STRUCT_TIMEVAL is 0, and _USE_32BIT_TIME_T is defined.
The mingw <sys/stat.h> changed: Now it defines _stati64 to _stat32i64,
and _stat32i64, when applied to the "NUL" device on mingw, reports
that "NUL" is a regular file. The supersede.c logic thus arranges to
write the output to a temporary file and, at the end, attempts to
move/rename that temporary file to "NUL" — which fails.
The fix is to map _stat32i64 to rpl_stat, because rpl_stat() has
extra code for handling "NUL" and other character devices.
[1] https://cygwin.com/pipermail/cygwin-announce/2025-June/012366.html
2025-06-12 Bruno Haible <[email protected]>
stat: Add support for mingw 13 in 32-bit mode.
* lib/sys_stat.in.h (_stat32i64): Redirect to rpl_stat.
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 8bde5a7d63..c3c38fd653 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -849,7 +849,11 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
# elif @WINDOWS_64_BIT_ST_SIZE@
/* Above, we define stat to _stati64. */
# if defined __MINGW32__ && defined _stati64
-# ifndef _USE_32BIT_TIME_T
+# ifdef _USE_32BIT_TIME_T
+ /* The system headers possibly define _stati64 to _stat32i64. */
+# undef _stat32i64
+# define _stat32i64(name, st) rpl_stat (name, st)
+# else
/* The system headers define _stati64 to _stat64. */
# undef _stat64
# define _stat64(name, st) rpl_stat (name, st)