On mingw 10, I see a link error: x86_64-w64-mingw32-gcc -Wno-error -g -O2 -L/usr/local/mingw64/lib -o test-chown.exe test-chown.o libtests.a ../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a /usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: test-chown.o: in function `test_chown': /home/bruno/testdir-all/build-mingw64/gltests/../../gltests/test-chown.h:77: undefined reference to `getgid' /usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: /home/bruno/testdir-all/build-mingw64/gltests/../../gltests/test-chown.h:138: undefined reference to `getgid' /usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: /home/bruno/testdir-all/build-mingw64/gltests/../../gltests/test-chown.h:163: undefined reference to `getgid' collect2: error: ld returned 1 exit status make[4]: *** [Makefile:17019: test-chown.exe] Error 1
This patch fixes it. 2023-04-19 Bruno Haible <[email protected]> chown tests: Fix link error on mingw 10. * modules/chown-tests (configure.ac): Test whether getgid() exists. * modules/fchownat-tests (configure.ac): Likewise. * tests/test-chown.h (getgid): Define a fallback. diff --git a/modules/chown-tests b/modules/chown-tests index 1fa6e44bc7..d013be17e7 100644 --- a/modules/chown-tests +++ b/modules/chown-tests @@ -16,7 +16,7 @@ stdckdint symlink configure.ac: -AC_CHECK_FUNCS_ONCE([getegid]) +AC_CHECK_FUNCS_ONCE([getgid getegid]) Makefile.am: TESTS += test-chown diff --git a/modules/fchownat-tests b/modules/fchownat-tests index f498efaf66..f11d02cdde 100644 --- a/modules/fchownat-tests +++ b/modules/fchownat-tests @@ -17,7 +17,7 @@ stdckdint symlink configure.ac: -AC_CHECK_FUNCS_ONCE([getegid]) +AC_CHECK_FUNCS_ONCE([getgid getegid]) Makefile.am: TESTS += test-fchownat diff --git a/tests/test-chown.h b/tests/test-chown.h index 4c7b6eec33..4e3d417d1b 100644 --- a/tests/test-chown.h +++ b/tests/test-chown.h @@ -18,6 +18,10 @@ #include "nap.h" +#if !HAVE_GETGID +# define getgid() ((gid_t) -1) +#endif + #if !HAVE_GETEGID # define getegid() ((gid_t) -1) #endif
