When I create a testdir $ ./gnulib-tool --create-testdir --dir=../testdir-utime --single-configure fdutimensat futimens utimensat utimens and compile it on mingw, I get this warning and compilation error:
i686-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I../../gllib -I.. -DGNULIB_STRICT_CHECKING=1 -I/usr/local/mingw32/include -Wall -g -O2 -MT error.o -MD -MP -MF .deps/error.Tpo -c -o error.o ../../gllib/error.c ../../gllib/error.c: In function ‘print_errno_message’: ../../gllib/error.c:121:24: warning: implicit declaration of function ‘strerror_r’ [-Wimplicit-function-declaration] # define __strerror_r strerror_r ^ ../../gllib/error.c:180:7: note: in expansion of macro ‘__strerror_r’ if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) ^ i686-w64-mingw32-gcc -g -O2 -L/usr/local/mingw32/lib -o test-fdutimensat.exe test-fdutimensat.o libtests.a ../gllib/libgnu.a libtests.a -lws2_32 libtests.a(strerror_r.o): In function `strerror_r': /home/bruno/testdir-utime/build-mingw32/gltests/../../gltests/strerror_r.c:164: undefined reference to `strerror_override' collect2: error: ld returned 1 exit status make[4]: *** [Makefile:2302: test-fdutimensat.exe] Error 1 The problem is that HAVE_STRERROR_R is now defined to 1 in config.h: /* Define to 1, since you should have the function strerror_r. */ #define HAVE_STRERROR_R 1 but strerror_r is not defined in gllib, only in gltests. The underlying problem is that m4/argp.m4 and m4/error.m4 invoke AC_FUNC_STRERROR_R. The modules 'argp' and 'error' depend on 'strerror' but actually, in a multithreaded environment, require 'strerror_r'. Therefore the code currently tries a "use module strerror_r optionally" strategy, which is not supported by gnulib-tool's dependency system. There is now a doc section that describes how this can be done correctly. The previous way is incorrect. I'm reverting the patches from 2016-10-16 [1], 2016-11-04 [2], 2016-11-14 [3], and implementing a correct fix of the second problem from [1] instead: When the strerror_r-posix module is in place, the results of AC_FUNC_STRERROR_R have to be ignored, because they don't reflect the situation after #define strerror_r rpl_strerror_r [1] https://lists.gnu.org/archive/html/bug-gnulib/2016-10/msg00069.html [2] https://lists.gnu.org/archive/html/bug-gnulib/2016-11/msg00043.html [3] https://lists.gnu.org/archive/html/bug-gnulib/2016-11/msg00054.html 2017-04-23 Bruno Haible <br...@clisp.org> Fix conflict between strerror_r-posix module and AC_FUNC_STRERROR_R. * modules/strerror_r-posix (configure.ac): Invoke gl_MODULE_INDICATOR. * lib/error.c: Test GNULIB_STRERROR_R_POSIX before testing HAVE_DECL_STRERROR_R, HAVE_STRERROR_R, or STRERROR_R_CHAR_P. * lib/argp-help.c (__argp_failure): Likewise. diff --git a/lib/argp-help.c b/lib/argp-help.c index 5567eee..ae639bd 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -1873,8 +1873,8 @@ __argp_failure (const struct argp_state *state, int status, int errnum, char const *s = NULL; putc_unlocked (':', stream); putc_unlocked (' ', stream); -# if HAVE_DECL_STRERROR_R -# if STRERROR_R_CHAR_P +# if GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R +# if GNULIB_STRERROR_R_POSIX || STRERROR_R_CHAR_P s = __strerror_r (errnum, buf, sizeof buf); # else if (__strerror_r (errnum, buf, sizeof buf) == 0) diff --git a/lib/error.c b/lib/error.c index 0ed7c86..feda720 100644 --- a/lib/error.c +++ b/lib/error.c @@ -104,7 +104,7 @@ extern void __error_at_line (int status, int errnum, const char *file_name, /* The gnulib override of fcntl is not needed in this file. */ # undef fcntl -# if !HAVE_DECL_STRERROR_R +# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R) # ifndef HAVE_DECL_STRERROR_R "this configure-time declaration test was not run" # endif @@ -117,9 +117,9 @@ int strerror_r (int errnum, char *buf, size_t buflen); #define program_name getprogname () -# if HAVE_STRERROR_R || defined strerror_r +# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r # define __strerror_r strerror_r -# endif /* HAVE_STRERROR_R || defined strerror_r */ +# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */ #endif /* not _LIBC */ #if !_LIBC @@ -172,9 +172,9 @@ print_errno_message (int errnum) { char const *s; -#if defined HAVE_STRERROR_R || _LIBC +#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R char errbuf[1024]; -# if _LIBC || STRERROR_R_CHAR_P +# if _LIBC || GNULIB_STRERROR_R_POSIX || STRERROR_R_CHAR_P s = __strerror_r (errnum, errbuf, sizeof errbuf); # else if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) diff --git a/modules/strerror_r-posix b/modules/strerror_r-posix index e15cf96..f91bc0e 100644 --- a/modules/strerror_r-posix +++ b/modules/strerror_r-posix @@ -19,6 +19,8 @@ if test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1; then gl_PREREQ_STRERROR_R fi gl_STRING_MODULE_INDICATOR([strerror_r]) +dnl For the modules argp, error. +gl_MODULE_INDICATOR([strerror_r-posix]) Makefile.am: