]> Savannah Git Hosting - gnulib.git/commitdiff
linkat: fix invalid definition of LINKAT_SYMLINK_NOTSUP on OS X
authorJim Meyering <meyering@fb.com>
Mon, 29 Jun 2015 17:05:31 +0000 (10:05 -0700)
committerJim Meyering <meyering@fb.com>
Mon, 29 Jun 2015 21:20:45 +0000 (14:20 -0700)
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.

ChangeLog
m4/linkat.m4

index 55259229a7f54c604e43999550c74a13b48d6e63..465bf0ef50ed3e1db35036697d0e9a794f6d1c84 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,42 @@
+2015-06-29  Jim Meyering  <meyering@fb.com>
+
+       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.
+
 2015-06-28  Jim Meyering  <meyering@fb.com>
 
        mountlist: avoid an unused-label warning on OS X
index 03cf23a2e4da37d2580ac04d5e5f2d67c9a7a2f9..9ed082db971fdfe61030fb9bca3ce2cdbaef2b55 100644 (file)
@@ -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