]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Try to update config.cache atomically; respect symlinks.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 14 Aug 2010 06:34:01 +0000 (08:34 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Fri, 27 Aug 2010 17:49:28 +0000 (19:49 +0200)
* lib/autoconf/general.m4 (AC_CACHE_SAVE): Use `mv -f' to update
the cache file if it is a regular file and not a symlink.  Move
first to temporary name in the target directory if not in the
current directory for atomicity across mount points.
* tests/base.at (AC_CACHE_CHECK): Try symlinked cache file.
* doc/autoconf.texi (Cache Files): Leftover temporary cache
files may be deleted by the user.
* NEWS: Update.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/general.m4
tests/base.at

index 5a11ab3ba163cec5b762f18cd88cb25588478503..02308674209c913de9997fba21e69466ac2718e0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-27  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Try to update config.cache atomically; respect symlinks.
+       * lib/autoconf/general.m4 (AC_CACHE_SAVE): Use `mv -f' to update
+       the cache file if it is a regular file and not a symlink.  Move
+       first to temporary name in the target directory if not in the
+       current directory for atomicity across mount points.
+       * tests/base.at (AC_CACHE_CHECK): Try symlinked cache file.
+       * doc/autoconf.texi (Cache Files): Leftover temporary cache
+       files may be deleted by the user.
+       * NEWS: Update.
+
 2010-08-27  Eric Blake  <eblake@redhat.com>
 
        m4sh: protect LINENO against stray macro
diff --git a/NEWS b/NEWS
index 6010e7bc7b53bd81236a2f022811f2222c6f68ee..79ed028b5c583947aaddcc806da6c7e344b041ff 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,11 @@ GNU Autoconf NEWS - User visible changes.
 
 ** The macro m4_define_default is now documented.
 
+** Symlinked config.cache files are supported; configure now tries to
+   update non-symlinked cache files atomically, so that concurrent configure
+   runs do not leave behind broken cache files.  It is still unspecified
+   which subset or union of results is cached though.
+
 
 * Major changes in Autoconf 2.67 (2010-07-21) [stable]
   Released by Eric Blake, based on git versions 2.66.*.
index 95500bec8de5fea75fc4b7c21d0585d61392abc3..19f00bd87ea0d806616f9c0c7aec7cda19593b6a 100644 (file)
@@ -9809,6 +9809,12 @@ results with the existing cache file.)  This may cause problems,
 however, if the system configuration (e.g., the installed libraries or
 compilers) changes and the stale cache file is not deleted.
 
+If @command{configure} is interrupted at the right time when it updates
+a cache file outside of the build directory where the @command{configure}
+script is run, it may leave behind a temporary file named after the
+cache file with digits following it.  You may safely delete such a file.
+
+
 @node Cache Checkpointing
 @subsection Cache Checkpointing
 
index c6f398075d9acf3315b596de71fed10e65e5dfba..14109213ebad7fd1d35c63f9068b104bc89826a8 100644 (file)
@@ -2001,9 +2001,22 @@ _AC_CACHE_DUMP() |
      :end'] >>confcache
 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
   if test -w "$cache_file"; then
-    test "x$cache_file" != "x/dev/null" &&
+    if test "x$cache_file" != "x/dev/null"; then
       AC_MSG_NOTICE([updating cache $cache_file])
-    cat confcache >$cache_file
+      if test ! -f "$cache_file" || test -h "$cache_file"; then
+       cat confcache >"$cache_file"
+      else
+dnl Try to update the cache file atomically even on different mount points;
+dnl at the same time, avoid filename limitation issues in the common case.
+        case $cache_file in #(
+        */* | ?:*)
+         mv -f confcache "$cache_file"$$ &&
+         mv -f "$cache_file"$$ "$cache_file" ;; #(
+        *)
+         mv -f confcache "$cache_file" ;;
+       esac
+      fi
+    fi
   else
     AC_MSG_NOTICE([not updating unwritable cache $cache_file])
   fi
index f21e777048dbbce1b551666f4f4f332f0951eff9..cf120997afb9d438d7be3642f9e6ddcfb6804ec8 100644 (file)
@@ -457,6 +457,15 @@ AT_CHECK_CONFIGURE([], [], [stdout])
 AT_CHECK([grep cache stdout], [1])
 AT_CHECK([LC_ALL=C ls -t config.cache a-stamp-file | sed 1q | grep config.cache], [1])
 
+# Using a symlinked cache file works.
+: > cache
+rm -f config.cache
+AS_LN_S([cache], [config.cache])
+AT_CHECK_CONFIGURE([-C])
+# Either the system does not support symlinks, or the symlinked-to file
+# should be updated.
+AT_CHECK([test -s cache || test ! -h config.cache])
+
 # config.site can specify a site-wide cache, accumulating information.
 # Also test that we don't run afoul of sourcing a file with leading -.
 AT_DATA([-config.site],