diff options
author | Jim Meyering <meyering@fb.com> | 2015-06-29 10:05:31 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2015-06-29 14:20:45 -0700 |
commit | 1f90ddd30bd3a27a085246dcfe39871eeb17cb63 (patch) | |
tree | 4336c24659778946e08eb2d15d1f5d3a3629e80d /m4 | |
parent | b4d1637b79e01a33970965a86f84f808aaaebcec (diff) | |
download | gnulib-1f90ddd30bd3a27a085246dcfe39871eeb17cb63.tar.gz |
linkat: fix invalid definition of LINKAT_SYMLINK_NOTSUP on OS X
It started like this when building coreutils' latest on OS X,
invoking ./configure with a nonempty --cache=.cache:
lib/linkat.c:46:42: error: operator '||' has no right operand
lib/linkat.c: In function 'rpl_linkat':
lib/linkat.c:330:27: error: #if with no expression
Here's linkat.c's line 46:
#if !HAVE_LINKAT || LINKAT_SYMLINK_NOTSUP
Here's some context:
$ grep linkat_nofoll .cache
gl_cv_func_linkat_nofollow=${gl_cv_func_linkat_nofollow=no}
$ grep LINKAT_SYM lib/config.h
#define LINKAT_SYMLINK_NOTSUP
The problem is that m4/linkat.m4's gl_FUNC_LINKAT
uses AC_CACHE_CHECK to set LINKAT_SYMLINK_NOTSUP,
but that violates a tenet of AC_CACHE_CHECK: it must
have no side effect other than setting its cache variable.
What happens is that when the cache is set, we'd skip the
code in that AC_CACHE_CHECK call, and leave LINKAT_SYMLINK_NOTSUP
defined to whatever value it happened to have in configure's
environment. In my case, it was not defined, so this later code:
AC_DEFINE_UNQUOTED([LINKAT_SYMLINK_NOTSUP], [$LINKAT_SYMLINK_NOTSUP],
[Define to 1 if linkat can create hardlinks to symlinks])
would emit code with an empty RHS.
* m4/linkat.m4 (gl_FUNC_LINKAT): Move the setting of
$LINKAT_SYMLINK_NOTSUP out of the AC_CACHE_CHECK code block.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/linkat.m4 | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/m4/linkat.m4 b/m4/linkat.m4 index 03cf23a2e4..9ed082db97 100644 --- a/m4/linkat.m4 +++ b/m4/linkat.m4 @@ -1,4 +1,4 @@ -# serial 6 +# serial 7 # See if we need to provide linkat replacement. dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. @@ -35,21 +35,20 @@ AC_DEFUN([gl_FUNC_LINKAT], [return linkat (AT_FDCWD, "conftest.l1", AT_FDCWD, "conftest.l2", 0); ])], - [gl_cv_func_linkat_nofollow=yes - LINKAT_SYMLINK_NOTSUP=0], - [gl_cv_func_linkat_nofollow=no - LINKAT_SYMLINK_NOTSUP=1], + [gl_cv_func_linkat_nofollow=yes], + [gl_cv_func_linkat_nofollow=no], [case "$host_os" in - darwin*) - gl_cv_func_linkat_nofollow="guessing no" - LINKAT_SYMLINK_NOTSUP=1 ;; - *) - gl_cv_func_linkat_nofollow="guessing yes" - LINKAT_SYMLINK_NOTSUP=0 ;; + darwin*) gl_cv_func_linkat_nofollow="guessing no" ;; + *) gl_cv_func_linkat_nofollow="guessing yes" ;; esac]) rm -rf conftest.l1 conftest.l2]) + case $gl_cv_func_linkat_nofollow in + *no) LINKAT_SYMLINK_NOTSUP=1 ;; + *yes) LINKAT_SYMLINK_NOTSUP=0 ;; + esac + AC_CACHE_CHECK([whether linkat handles trailing slash correctly], [gl_cv_func_linkat_slash], [rm -rf conftest.a conftest.b conftest.c conftest.d conftest.e conftest.s |