Building a recent diffutils snapshot on FreeBSD 5.2.1, I see this compilation error:
CCLD diff ../lib/libdiffutils.a(libdiffutils_a-save-cwd.o): In function `save_cwd': /usr/home/bruno/diffutils-3.10.242-d65b/build/lib/../../lib/save-cwd.c:65: undefined reference to `rpl_getcwd' gmake[2]: *** [diff] Error 1 gmake[2]: Leaving directory `/usr/home/bruno/diffutils-3.10.242-d65b/build/src' The reason is that this package has - getcwd-lgpl.c in lib/ - disabled - getcwd.c in gnulib-tests/ - enabled, with REPLACE_GETCWD=1 But the REPLACE_GETCWD=1 setting makes a side effect on lib/unistd.h, namely it enables '#define getcwd rpl_getcwd'. The fix is to make sure that the tests contain module 'getcwd-lgpl', not 'getcwd'. 2025-01-05 Bruno Haible <br...@clisp.org> tests: Don't use module 'getcwd' as dependency. * modules/getcwd (Comment): New section. * modules/xgetcwd (Comment): Likewise. * modules/xgetcwd-lgpl: New file, based on modules/xgetcwd. * modules/chown-tests (Depends-on): Add xgetcwd-lgpl. Remove xgetcwd. * modules/fchownat-tests (Depends-on): Likewise. * modules/fdutimensat-tests (Depends-on): Likewise. * modules/futimens-tests (Depends-on): Likewise. * modules/lchown-tests (Depends-on): Likewise. * modules/stat-time-tests (Depends-on): Likewise. * modules/utime-tests (Depends-on): Likewise. * modules/utimens-tests (Depends-on): Likewise. * modules/utimensat-tests (Depends-on): Likewise. diff --git a/modules/chown-tests b/modules/chown-tests index 2760ff4c0e..486c3ffa34 100644 --- a/modules/chown-tests +++ b/modules/chown-tests @@ -15,7 +15,7 @@ bool stdckdint-h symlink xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: AC_CHECK_FUNCS_ONCE([getgid getegid]) diff --git a/modules/fchownat-tests b/modules/fchownat-tests index 2132fd01a2..75c0acff55 100644 --- a/modules/fchownat-tests +++ b/modules/fchownat-tests @@ -16,7 +16,7 @@ stat-time stdckdint-h symlink xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: AC_CHECK_FUNCS_ONCE([getgid getegid]) diff --git a/modules/fdutimensat-tests b/modules/fdutimensat-tests index 2798e2b0e0..99080034bf 100644 --- a/modules/fdutimensat-tests +++ b/modules/fdutimensat-tests @@ -17,7 +17,7 @@ timespec dup utimecmp xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: diff --git a/modules/futimens-tests b/modules/futimens-tests index d40c3c849c..c2fd40f0e9 100644 --- a/modules/futimens-tests +++ b/modules/futimens-tests @@ -16,7 +16,7 @@ timespec dup utimecmp xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: diff --git a/modules/getcwd b/modules/getcwd index 03117c9c65..b21b71f7d2 100644 --- a/modules/getcwd +++ b/modules/getcwd @@ -1,6 +1,12 @@ Description: Return the current working directory. +Comment: +This module should not be used as a dependency from a test module, +otherwise when this module occurs as a tests-related module, it will +have side effects on the compilation of the 'getcwd-lgpl' module, if +that module occurs among the main modules in lib/. + Files: lib/getcwd.c m4/getcwd-abort-bug.m4 diff --git a/modules/lchown-tests b/modules/lchown-tests index 44fdf84c9b..2ec5a074b5 100644 --- a/modules/lchown-tests +++ b/modules/lchown-tests @@ -15,7 +15,7 @@ stat-time bool symlink xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: AC_CHECK_FUNCS_ONCE([getgid getegid]) diff --git a/modules/stat-time-tests b/modules/stat-time-tests index e38fb2d19a..c1f962c243 100644 --- a/modules/stat-time-tests +++ b/modules/stat-time-tests @@ -9,7 +9,7 @@ stdckdint-h time-h unistd-h xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: diff --git a/modules/utime-tests b/modules/utime-tests index bd30c02138..aa63e9a022 100644 --- a/modules/utime-tests +++ b/modules/utime-tests @@ -14,7 +14,7 @@ symlink timespec utimecmp xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: diff --git a/modules/utimens-tests b/modules/utimens-tests index 93365373ec..37388a688c 100644 --- a/modules/utimens-tests +++ b/modules/utimens-tests @@ -17,7 +17,7 @@ symlink timespec utimecmp xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: diff --git a/modules/utimensat-tests b/modules/utimensat-tests index 5b65328e28..7436a18502 100644 --- a/modules/utimensat-tests +++ b/modules/utimensat-tests @@ -14,7 +14,7 @@ stdckdint-h timespec utimecmp xconcat-filename -xgetcwd +xgetcwd-lgpl configure.ac: diff --git a/modules/xgetcwd b/modules/xgetcwd index 9660d4fb2d..f53ce3e3ca 100644 --- a/modules/xgetcwd +++ b/modules/xgetcwd @@ -1,6 +1,12 @@ Description: Return the current working directory, without size limitations. +Comment: +This module should not be used as a dependency from a test module, +otherwise when this module occurs as a tests-related module, it will +have side effects on the compilation of the 'getcwd-lgpl' module, if +that module occurs among the main modules in lib/. + Files: lib/xgetcwd.h lib/xgetcwd.c diff --git a/modules/xgetcwd-lgpl b/modules/xgetcwd-lgpl new file mode 100644 index 0000000000..64e7c8f60d --- /dev/null +++ b/modules/xgetcwd-lgpl @@ -0,0 +1,26 @@ +Description: +Return the current working directory, without size limitations. + +Files: +lib/xgetcwd.h +lib/xgetcwd.c +m4/xgetcwd.m4 + +Depends-on: +getcwd-lgpl +xalloc + +configure.ac: +gl_XGETCWD + +Makefile.am: +lib_SOURCES += xgetcwd.c + +Include: +"xgetcwd.h" + +License: +GPL + +Maintainer: +Jim Meyering