Skip to content

Commit 82387ea

Browse files
committed
avoid getcwd() declaration in test; debian bug#1135783
git-svn-id: svn://tug.org/texlive/trunk/Build/source@78924 c570f23f-e606-0410-a88d-b1316a301751
1 parent 724eaa3 commit 82387ea

4 files changed

Lines changed: 37 additions & 22 deletions

File tree

‎texk/kpathsea/ChangeLog‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2026-05-06 Karl Berry <karl@freefriends.org>
2+
3+
* configure.ac (kb_cv_func_getcwd_forks): don't declare
4+
getcwd(), since C23 breaks that. Instead, rely on it being
5+
declared in <unistd.h> (not <stdlib.h>)
6+
The end result of the test failure being to usel
7+
our fallback getcwd() in xgetcwd.c, which stat(2)s pervasively,
8+
and is unusable under NFS :(. Original report and patch
9+
from Emmanuel Thome, bugs.debian.org/1135783 and
10+
https://tug.org/pipermail/tex-k/2026-May/004322.html.
11+
112
2026-04-25 Karl Berry <karl@freefriends.org>
213

314
* doc/kpathsea.texi (Casefolding search): describe earlier and

‎texk/kpathsea/c-auto.in‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
/* Define to 1 if the 'closedir' function returns void instead of int. */
2929
#undef CLOSEDIR_VOID
3030

31-
/* Define to 1 if getcwd is implemented using fork or vfork. Let me know if
32-
you have to add this by hand because configure failed to detect it. */
31+
/* Define to 1 if getcwd is implemented using fork or vfork. Email
32+
tex-k@tug.org with your system info and config.log if you have to add this
33+
by hand because configure failed to detect it. */
3334
#undef GETCWD_FORKS
3435

3536
/* Define to 1 if you have the <assert.h> header file. */

‎texk/kpathsea/configure‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16386,8 +16386,10 @@ fi
1638616386

1638716387

1638816388
if test "x$ac_cv_func_getcwd" = xyes; then
16389-
# We only need to run this if we have getcwd.
16390-
{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking whether getcwd uses fork or vfork" >&5
16389+
# We only need to run this if we have getcwd.
16390+
# Don't declare getcwd(), since C23 doesn't allow empty parens.
16391+
# Instead, we just have to hope that it's declared where it should be.
16392+
{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking whether getcwd uses fork or vfork" >&5
1639116393
printf %s "checking whether getcwd uses fork or vfork... " >&6; }
1639216394
if test ${kb_cv_func_getcwd_forks+y}
1639316395
then :
@@ -16399,10 +16401,9 @@ then :
1639916401
else case e in #(
1640016402
e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1640116403
/* end confdefs.h. */
16402-
#include <stdlib.h>
16403-
int fork() { exit(1); }
16404+
#include <unistd.h>
16405+
int fork() { exit(1); }
1640416406
int vfork() { exit(1); }
16405-
extern char *getcwd();
1640616407
char path[100];
1640716408
int
1640816409
main (void)
@@ -16428,12 +16429,12 @@ esac
1642816429
fi
1642916430
{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $kb_cv_func_getcwd_forks" >&5
1643016431
printf '%s\n' "$kb_cv_func_getcwd_forks" >&6; }
16431-
if test "x$kb_cv_func_getcwd_forks" = xyes; then
16432+
if test "x$kb_cv_func_getcwd_forks" = xyes; then
1643216433

1643316434
printf '%s\n' "#define GETCWD_FORKS 1" >>confdefs.h
1643416435

16435-
fi
16436-
fi
16436+
fi # forks=yes
16437+
fi # have_getcwd
1643716438

1643816439
{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for native WIN32 or MINGW32" >&5
1643916440
printf %s "checking for native WIN32 or MINGW32... " >&6; }

‎texk/kpathsea/configure.ac‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl $Id$
22
dnl Process this file with autoconf to produce a configure script.
33
dnl
4-
dnl Copyright 2015-2021 Karl Berry <tex-live@tug.org>
4+
dnl Copyright 2015-2026 Karl Berry <tex-live@tug.org>
55
dnl Copyright 2009-2015 Peter Breitenlohner <tex-live@tug.org>
66
dnl
77
dnl This file is free software; the copyright holder
@@ -42,25 +42,27 @@ AC_CHECK_DECLS([putenv])
4242
AC_REPLACE_FUNCS([putenv])
4343

4444
if test "x$ac_cv_func_getcwd" = xyes; then
45-
# We only need to run this if we have getcwd.
46-
AC_CACHE_CHECK([whether getcwd uses fork or vfork],
45+
# We only need to run this if we have getcwd.
46+
# Don't declare getcwd(), since C23 doesn't allow empty parens.
47+
# Instead, we just have to hope that it's declared where it should be.
48+
AC_CACHE_CHECK([whether getcwd uses fork or vfork],
4749
[kb_cv_func_getcwd_forks],
48-
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
49-
int fork() { exit(1); }
50+
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
51+
int fork() { exit(1); }
5052
int vfork() { exit(1); }
51-
extern char *getcwd();
5253
char path[100];]],
5354
[[getcwd(path,100);]])],
5455
[kb_cv_func_getcwd_forks=no],
5556
[kb_cv_func_getcwd_forks=yes],
5657
[kb_cv_func_getcwd_forks=no])])
57-
if test "x$kb_cv_func_getcwd_forks" = xyes; then
58-
AC_DEFINE([GETCWD_FORKS], 1,
58+
if test "x$kb_cv_func_getcwd_forks" = xyes; then
59+
AC_DEFINE([GETCWD_FORKS], 1,
5960
[Define to 1 if getcwd is implemented using fork or vfork.
60-
Let me know if you have to add this by hand because configure
61-
failed to detect it.])
62-
fi
63-
fi
61+
Email tex-k@tug.org with your system info and config.log if
62+
you have to add this by hand because configure failed to
63+
detect it.])
64+
fi # forks=yes
65+
fi # have_getcwd
6466

6567
KPSE_COND_MINGW32
6668

0 commit comments

Comments
 (0)