This is the mail archive of the autoconf-patches@gnu.org mailing list for the autoconf project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch to disable config.cache by default (was "config.cacheconsidered harmful")


Back in February, there was a long thread in which (apparently) everyone
agreed that config.cache caused problems for newbies, and that it should be
disabled by default and only turned on if the user supplies
--cache-file=<foo>.

I was very happy to read this conclusion, as users of my own projects have
also had many problems related to stale config.cache files; it doesn't seem
like a worthwhile optimization for general use.  However, I was surprised
to look at the autoconf source code, a month after consensus had apparently
been reached, and find that it was still enabling the cache by default.

Figuring that this was an oversight, I have included a small patch below to
turn off the cache by default, simply by defaulting cache_file to /dev/null
(the recommended way to disable the cache in the documentation).  I also
modified it so that it would not print "loading cache /dev/null" and
"updating cache /dev/null" messages when caching is disabled, and updated
the documentation in autoconf.texi.  Unsurprisingly for such a trivial
patch, it seems to work fine.

Cordially,
Steven G. Johnson

2000-03-31  Steven G. Johnson  <stevenj@alum.mit.edu>

        Disable caching by default, so as not to cause problems when
        newbies accidentally use a stale cache file.

        * acgeneral.m4: set cache_file to /dev/null to disable caching;
        the user can enable caching with --cache-file=<foo>.
        (AC_CACHE_LOAD, AC_CACHE_SAVE): don't print "loading/updating
        /dev/null" messages when caching is disabled.

        * autoconf.texi: noted that caching in disabled, how to enable it,
        and that config.cache is the traditional name of the cache file.


diff -u -r1.428 acgeneral.m4
--- acgeneral.m4        2000/03/31 15:47:30     1.428
+++ acgeneral.m4        2000/03/31 20:35:55
@@ -894,7 +894,7 @@
 # The variables have the same names as the options, with
 # dashes changed to underlines.
 build=NONE
-cache_file=./config.cache
+cache_file=/dev/null
 AC_SUBST(exec_prefix, NONE)dnl
 host=NONE
 no_create=
@@ -1865,7 +1865,7 @@
 # -------------
 define(AC_CACHE_LOAD,
 [if test -r "$cache_file"; then
-  echo "loading cache $cache_file"
+  test "x$cache_file" != "x/dev/null" && echo "loading cache $cache_file"
   dnl Some versions of bash will fail to source /dev/null, so we
   dnl avoid doing that.
   test -f "$cache_file" && . $cache_file
@@ -1918,7 +1918,7 @@
   esac >>confcache
 if cmp -s $cache_file confcache; then :; else
   if test -w $cache_file; then
-    echo "updating cache $cache_file"
+    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
     cat confcache >$cache_file
   else
     echo "not updating unwritable cache $cache_file"


diff -u -r1.247 autoconf.texi
--- autoconf.texi       2000/03/20 10:10:06     1.247
+++ autoconf.texi       2000/03/31 20:51:42
@@ -436,8 +436,9 @@
 the files listed above (@pxref{Invoking config.status});

 @item
-a shell script called @file{config.cache} that saves the results of
-running many of the tests (@pxref{Cache Files});
+an optional shell script normally called called @file{config.cache}
+(created when using @samp{configure --cache-file=./config.cache}) that
+saves the results of running many of the tests (@pxref{Cache Files});

 @item
 a file called @file{config.log} containing any messages produced by
@@ -483,7 +484,7 @@
 Files used in configuring a software package:
 @example
 @group
-                       .-------------> config.cache
+                       .-------------> [config.cache]
 configure* ------------+-------------> config.log
                        |
 [config.h.in] -.       v            .-> [config.h] -.
@@ -4769,17 +4770,21 @@
 and configure runs.  It is not useful on other systems.  If its contents
 are invalid for some reason, the user may delete or edit it.

-By default, configure uses @file{./config.cache} as the cache file,
-creating it if it does not exist already.  @code{configure} accepts the
-@samp{--cache-file=@var{file}} option to use a different cache file;
-that is what @code{configure} does when it calls @code{configure}
-scripts in subdirectories, so they share the cache.
+By default, configure uses no cache file (technically, it uses
+@samp{--cache-file=/dev/null}), so as to forestall problems caused by
+accidental use of stale cache files.
+
+To enable caching, @code{configure} accepts the optional argument
+@samp{--cache-file=@var{file}} where @var{file} is the name of the cache
+file to use, traditionally @file{./config.cache}.  The cache file is
+created if it does not exist already.  When @code{configure} calls
+@code{configure} scripts in subdirectories, it uses the
+@samp{--cache-file} argument so that they share the same cache.
 @xref{Subdirectories}, for information on configuring subdirectories
 with the @code{AC_CONFIG_SUBDIRS} macro.

-Giving @samp{--cache-file=/dev/null} disables caching, for debugging
-@code{configure}.  @file{config.status} only pays attention to the cache
-file if it is given the @samp{--recheck} option, which makes it rerun
+@file{config.status} only pays attention to the cache file if it is
+given the @samp{--recheck} option, which makes it rerun
 @code{configure}.  If you are anticipating a long debugging period, you
 can also disable cache loading and saving for a @code{configure} script
 by redefining the cache macros at the start of @file{configure.in}:
@@ -5800,7 +5805,7 @@
 #
 # Give Autoconf 2.x generated configure scripts a shared default
 # cache file for feature test results, architecture-specific.
-if test "$cache_file" = ./config.cache; then
+if test "$cache_file" = /dev/null; then
   cache_file="$prefix/var/config.cache"
   # A cache file is only valid for one C compiler.
   CC=gcc



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]