Обсуждение: make maintainer-clean and config.cache

Поиск
Список
Период
Сортировка

make maintainer-clean and config.cache

От
Jeff Janes
Дата:
In side-note in another thread Tom pointed out the speed improvements of using an autoconf cache when re-building, which sounded nice to me as config takes an annoyingly long time and is not parallelized.

But the config.cache files gets deleted by make maintainer-clean.  Doesn't that mostly defeat the purpose of having a cache?  Am I doing something wrong here, or just thinking about it wrong?

time ./configure --config-cache > /dev/null 
real 0m21.538s

time ./configure --config-cache > /dev/null 
real 0m3.425s

make maintainer-clean > /dev/null ; 
## presumably git checkout a new commit here
time ./configure --config-cache > /dev/null 
real 0m21.260s

Cheers,

Jeff

Re: make maintainer-clean and config.cache

От
Tom Lane
Дата:
Jeff Janes <jeff.janes@gmail.com> writes:
> But the config.cache files gets deleted by make maintainer-clean.  Doesn't
> that mostly defeat the purpose of having a cache?  Am I doing something
> wrong here, or just thinking about it wrong?

Well, a few things about that:

(1) distclean *must* remove config.cache to be sure we don't accidentally
include one in tarballs;

(2) it's also a good idea for distclean to remove it so that the common
pattern "make distclean; git pull" doesn't leave you with a stale cache
file if somebody updated configure;

(3) IMO, letting it default to config.cache isn't best practice anyway.

I always use --cache-file to select a cache file, which I keep outside
the source directory.  The main advantage of that is that it's possible
to switch between different CFLAGS settings, different compilers, etc,
without having to lose your cache, by instead specifying a different
cache file for each set of settings.  I don't take this as far as some
people might want to --- I just keep one for default CFLAGS and one for
non-default, per branch.  Somebody who was more into performance testing
than I might have a more complex rule for that.

For amusement's sake, here's (most of) my standard shell script for
invoking PG's configure.  This goes along with a setup script that
sets $PGINSTROOT and some other variables depending on which branch
I'm testing:

# This provides caching for just one non-default CFLAGS setting per branch,
# but that seems like enough for now.
if [ x"$CFLAGS" = x"" ]; then
  ACCACHEFILE="$HOME/accache/config-`basename $PGINSTROOT`.cache"
else
  ACCACHEFILE="$HOME/accache/config-`basename $PGINSTROOT`-cflags.cache"
fi

# Trash the cache file when configure script changes.
if [ ./configure -nt "$ACCACHEFILE" ]; then
  rm -f "$ACCACHEFILE"
fi

./configure --with-pgport="$DEFPORT" --prefix="$PGINSTROOT" \
    --cache-file="$ACCACHEFILE" \
    --enable-debug --enable-cassert $PGCONFIGOPTS "$@"

            regards, tom lane