Speeding Up Autoconf - use of a config.cache

hammy

Active member
Jun 1, 2019
108
68
28
UK
Following up on a link of tips provided by @Unxmaal (https://gitlab.com/gnuwget/wget2/-/wikis/Developer-hints:-Increasing-speed-of-GNU-toolchain), here's a little recipe that's currently working pretty well for me.

Caution: Use of the autoconf config.cache can potentially cause weird things to fail that otherwise shouldn't (due to collisions in test naming). This can certainly speed you up when it works flawlessly - but in the case where autoconf (configure) is failing - you _may_ be seeing a false positive. Buyer beware.

So, cautionary tale out of the way - steps for setup:

* Directory and config.site script directing autoconf where stuff is cached

I currently use a ~/devtools/configcache directory, you can adjust this where suits you, adjust paths in the following.

~/devtools/configcache/config.site contents:

Code:
if test "$cache_file" = /dev/null; then
  # Can't do this, results in new cache for each package
  #  hash=`env|shasum|cut -d ' ' -f1`
  hash=`echo $CPPFLAGS $CC $M4 $PERL $PERL_PATH $SED $CXX $CFLAGS $CXXFLAGS $LDFLAGS $LIBS $host_alias $build_alias|shasum|cut -d ' ' -f1`
  cache_file=$HOME/devtools/configcache/config.cache.$hash
  cache_file_dir=$HOME/devtools/config.cache.$hash.dir
  mkdir -p $cache_file_dir
  cache_file_descr=$cache_file_dir/description
  echo "$RPM_PACKAGE_NAME CPPFLAGS=$CPPFLAGS CC=$CC M4=$M4 PERL=$PERL PERL_PATH=$PERL_PATH SED=$SED CXX=$CXX CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS LIBS=$LIBS" >>$cache_file_descr
  touch $cache_file
fi

* Environment variable telling configure that you have a cache and want to use it:

Code:
export CONFIG_SITE=$HOME/devtools/configcache/config.site
* Run configure for the package you want (this can include rpmbuild, too)

Be amazed as nothing is sped up - but wait!

* Rerun configure - and now the benefit should start to be a little more obvious.

How this works:

Basically it takes a bunch of environment vars like CFLAGS and LDFLAGS, hashes them and creates a unique configure cache for each of those keys.

On the whole it works pretty well. If you're getting strange behaviour, you can delete the files it creates, or unset the environment variable to avoid it altogether.

Enjoy.
 
  • Like
Reactions: foetz and Elf

Elf

Storybook / Retired, ex-staff
Feb 4, 2019
792
252
63
Mountain West (US)
Nice find :)

It was only when the autoconf cache was mentioned here that I even knew there was such a feature!
 

About us

  • Silicon Graphics User Group (SGUG) is a community for users, developers, and admirers of Silicon Graphics (SGI) products. We aim to be a friendly hobbyist community for discussing all aspects of SGIs, including use, software development, the IRIX Operating System, and troubleshooting, as well as facilitating hardware exchange.

User Menu