On Thu 06 Nov 2025, Paul Eggert wrote:

> On 2025-11-06 13:42, Andy Moreton wrote:
>
>> With master commit 50a1929f6c0a ("Update from Gnulib by running
>> admin/merge-gnulib") I see the build fails from a clean checkout:
>> make[2]: Entering directory
>> '/c/emacs/git/emacs/master/build/mingw64-x86_64-O2-native/lib'
>>    CC       stdio-consolesafe.o
>> C:/emacs/git/emacs/master/lib/stdio-consolesafe.c:59:1: warning: no previous 
>> prototype for 'gl_consolesafe_fwrite' [-Wmissing-prototypes]
>>     59 | gl_consolesafe_fwrite (const void *ptr, size_t size, size_t nmemb, 
>> FILE *fp)
>>        | ^~~~~~~~~~~~~~~~~~~~~
>> C:/emacs/git/emacs/master/lib/stdio-consolesafe.c:133:1: warning: no
>> previous prototype for 'gl_consolesafe_fprintf' [-Wmissing-prototypes]
>>    133 | gl_consolesafe_fprintf (FILE *restrict fp, const char *restrict 
>> format, ...)
>>        | ^~~~~~~~~~~~~~~~~~~~~~
>
> Thanks for checking this. The above two messages (and similar ones) suggest
> that the following lines in lib/stdio.h are not working as expected:
>
>   #if (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
>   /* Workarounds against msvcrt bugs.  */
>   _GL_FUNCDECL_SYS (gl_consolesafe_fwrite, size_t,
>                     (const void *ptr, size_t size, size_t nmemb, FILE *fp),
>                     _GL_ARG_NONNULL ((1, 4)));
>   # if defined __MINGW32__
>   _GL_FUNCDECL_SYS (gl_consolesafe_fprintf, int,
>                     (FILE *restrict fp, const char *restrict format, ...),
>                     _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
>                     _GL_ARG_NONNULL ((1, 2)));
>
> Can you figure out why that might be?  E.g., run the command
>
> make V=1
>
> to see what "CC stdio-consolesafe.o" is actually doing, and then use the
> compiler's -E flag (or better yet, -dD -E if that's supported) to see whether
> _WIN32, __CYGWIN__, _UCRT and __MINGW32__ have the expected values for your
> platform, whatever they may be.

This build was using the MSYS2 mingw64 environment (so should be using
msvcrt, not ucrt). With V=1 this shows:

make[2]: Entering directory
'/c/emacs/git/emacs/master/build/mingw64-x86_64-O2-native/lib' gcc -c
-mtune=generic -DUSE_CRT_DLL=1 -I /c/emacs/git/emacs/master/nt/inc
-mtune=generic -MMD -MF deps/stdio-consolesafe.d -MP
-fstrict-flex-arrays -Wall -Warith-conversion -Wdate-time
-Wdouble-promotion -Wduplicated-cond -Wextra -Wformat-signedness
-Wflex-array-member-not-at-end -Winit-self -Winvalid-pch -Wlogical-op
-Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes
-Wmissing-variable-declarations -Wnested-externs -Wnull-dereference
-Wold-style-definition -Wopenmp-simd -Wpacked -Wpointer-arith
-Wstrict-flex-arrays -Wstrict-prototypes -Wsuggest-attribute=noreturn
-Wsuggest-final-methods -Wsuggest-final-types -Wtrampolines
-Wuninitialized -Wunknown-pragmas -Wvariadic-macros
-Wvector-operation-performance -Wwrite-strings -Warray-bounds=2
-Wattribute-alias=2 -Wformat=2 -Wformat-truncation=2
-Wimplicit-fallthrough=5 -Wshift-overflow=2 -Wuse-after-free=3
-Wvla-larger-than=4031 -Wtrailing-whitespace
-Wno-missing-field-initializers -Wno-override-init -Wno-sign-compare
-Wno-type-limits -Wno-unused-parameter -Wno-format-nonliteral
-Wno-bidi-chars -Wno-pointer-sign -fdiagnostics-color=never -O2
-std=gnu17 -g3 -I. -I../src -I/c/emacs/git/emacs/master/lib
-I/c/emacs/git/emacs/master/src -DGL_COMPILE_CRYPTO_STREAM -o
stdio-consolesafe.o /c/emacs/git/emacs/master/lib/stdio-consolesafe.c

Adding -E shows

#define _WIN32 1
#define __MINGW32__ 1

__CYGWIN__ is not defined
_UCRT is not defined


>> C:/emacs/git/emacs/master/lib/stdio-consolesafe.c: In function 
>> 'gl_consolesafe_fprintf':
>> C:/emacs/git/emacs/master/lib/stdio-consolesafe.c:137:3: error: implicit
>> declaration of function 'va_start' [-Wimplicit-function-declaration]
>>    137 |   va_start (args, format);
>>        |   ^~~~~~~~
>
> That (and similar messages) seem to be due to an obvious typo, which I fixed
> that by installing the attached into Gnulib and propagating this into Emacs.

That does not silence the warnings, but does bootstrap from a clean
tree (with a workaround patch for bug#79694).

    AndyM


Reply via email to