Hello Daiki,

> When trying to update Gnulib submodule in GnuTLS, I came across this error:
> 
>   close.c: In function 'rpl_close':
>   close.c:71:5: error: implicit declaration of function '_gl_unregister_fd' 
> [-Wimplicit-function-declaration]
>      71 |     _gl_unregister_fd (fd);
>         |     ^~~~~~~~~~~~~~~~~
>   make[4]: *** [Makefile:3602: libgnu_la-close.lo] Error 1
> 
> Looks like REPLACE_FCHDIR is defined as 1, while fchdir implementation
> is not provided by Gnulib (@GNULIB_FCHDIR@ expands to 0, and fchdir.c is
> not added to the library sources in the genenerated Makefile).
> 
> I haven't managed to minimize the reproducer, but you can easily
> reproduce the issue with podman or docker:
> 
>   podman run -ti 
> registry.gitlab.com/gnutls/build-images:buildenv-mingw-fedora40
>   git clone https://gitlab.com/gnutls/gnutls.git
>   (cd gnutls && git submodule deinit gnulib && git rm -rf gnulib)
>   git clone https://git.sv.gnu.org/git/gnulib.git
>   cd gnutls
>   ./bootstrap --skip-po --gnulib-srcdir=$PWD/../gnulib
>   ./configure --disable-gcc-warnings --host=x86_64-w64-mingw32 
> --target=x86_64-w64-mingw32 --with-included-unistring 
> --disable-full-test-suite --disable-doc
>   make

I can't really reproduce the issue, because the bootstrapping phase fails:

$ git clone https://gitlab.com/gnutls/gnutls.git
$ cd gnutls
$ sed -i -e '/^gtkdocize/d' bootstrap.conf
$ ./bootstrap --skip-po --no-git --gnulib-srcdir=$GNULIB_SRCDIR 2>&1 | tee log0
...
configure.ac:55: warning: The macro 'AC_PROG_CC_C99' is obsolete.
configure.ac:55: You should run autoupdate.
./lib/autoconf/c.m4:1662: AC_PROG_CC_C99 is expanded from...
configure.ac:55: the top level
configure.ac:139: warning: The macro 'AC_HEADER_STDC' is obsolete.
configure.ac:139: You should run autoupdate.
./lib/autoconf/headers.m4:663: AC_HEADER_STDC is expanded from...
configure.ac:139: the top level
configure.ac:374: warning: The macro 'AC_TRY_COMPILE' is obsolete.
configure.ac:374: You should run autoupdate.
./lib/autoconf/general.m4:2845: AC_TRY_COMPILE is expanded from...
m4/hooks.m4:34: LIBGNUTLS_HOOKS is expanded from...
configure.ac:374: the top level
configure.ac:57: error: possibly undefined macro: AC_MSG_WARN
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:71: error: possibly undefined macro: AS_IF
configure.ac:162: error: possibly undefined macro: AC_DEFINE
configure.ac:496: error: possibly undefined macro: AC_MSG_ERROR
autoreconf: error: /gnu/bin/autoconf failed with exit status: 1
./bootstrap: autoreconf failed

Indeed, you can drop AC_PROG_CC_C99 and AC_HEADER_STDC, since you have
AC_PROG_CC in configure.ac (assuming autoconf >= 2.70).

Anyway, let me analyze it without reproducing.

The problem is obviously an interaction between the 'close' and the 'fchdir'
modules.

In this package, you have 3 gnulib-tool invocations, under one configure.ac:

1. m4/gnulib-cache.m4
   'close' included, 'fchdir' not included.

2. lib/unistring/m4/gnulib-cache.m4
   Neither of the two included.

3. src/gl/m4/gnulib-cache.m4
   'close' included, 'fchdir' included (as a dependency of
   chdir-long, fdopendir, fstatat, openat, save-cwd).

The problem is that the gnulib code from #3 creates file descriptors that
refer to directories (this is needed on native Windows for fstatat, openat,
etc.) and thus the library code (#1) supposedly needs support for such
file descriptors.

Can a file descriptor be passed to the library code, that comes from src/
and thus can refer to a directory? If yes, then add the module 'fchdir'
to the library (but careful about LGPLv2+!)
If you can guarantee that this is not the case, the fix/workaround is to
separate these two parts of the package a bit more. Two ways come to mind:

  - Instead of one configure.ac, use two. One for the library, one for the
    rest. So that each has its own config.h, and the '#define REPLACE_FCHDIR 1'
    in the src config.h has no effect on the library.

  - Keep a single configure.ac, but at the end of config.h add, via AH_VERBATIM,
    a definition like this:

      #if BUILDING_THE_LIBRARY
      # undef /**/ REPLACE_FCHDIR
      #endif

> After bisecting, the first commit that introduced the issue seems to be:
> 
>   commit f59ff6beeb3e5f437a4c847b9e1a785b30363e5b
>   Author: Bruno Haible <[email protected]>
>   Date:   Mon Aug 12 16:15:50 2024 +0200
> 
>       fdutimensat, utimensat tests: Fix test failures on Cygwin.
> 
> Reverting this change fixes the issue locally.

This bisect result is not helpful in understanding the situation.

Bruno




Reply via email to