[PATCH] Add configure cache checkpoints before fatal checks

Started by Joel Jacobsonover 4 years ago1 messages
#1Joel Jacobson
joel@compiler.org
1 attachment(s)

Hi,

Enabling optional ./configure features/packages using --enable-* / --with-*
will and should cause fatal errors aborting the configure process
if some dependencies are missing, letting the user install such packages,
before proceeding and resuming ./configure.

However, ./configure currently only saves config.cache at the very end upon success.

This means the manual loop below can take quite a few iterations,
until the user have encountered all errors for their distribution,
and installed all required packages:

loop
./configure --with-... --enable-...
if error occured then
figure out which distro package should be installed using apt-file or google
install the package
else
break
end
end loop

To speed-up the resuming of ./configure, I propose adding AC_CACHE_SAVE entires
at a few positions *before* possibly executing some fatal checks (AC_MSG_ERROR).

It's important not to run AC_CACHE_SAVE in between the actual check and AC_MSG_ERROR,
as that would cache the "no" value, causing the package later installed by the user to go undetected.

Attached is a patch adding AC_CACHE_SAVE at places where I think it makes most sense.
Since it's a macro that expanded causes configure to grow quite a bit,
I only added it at the 10 places where we get most bang for the bucks, in terms of speed-up.

Just for fun, I also created a little helper-tool, magicmake [1]https://github.com/truthly/magicmake, to automate the pseudo-code loop above,
to verify all packages could be found, after installation, so that no undesired "no" values were cached.
The gif animation [2]https://github.com/truthly/magicmake/raw/master/magicmake.gif shows the building of PostgreSQL with these configure flags:

magicmake ./configure --config-cache --prefix="$HOME/pg-head" --enable-nls --with-perl --with-python --with-tcl --with-icu --with-llvm --with-ssl=openssl --with-gssapi --with-ldap --with-pam --with-systemd --with-libxml --with-libxslt --with-lz4 --with-pgport=54321 --enable-debug --enable-cassert --enable-tap-tests --enable-depend --enable-coverage --enable-profiling --enable-dtrace

The following packages were detected and installed by magicmake to make it possible to build PostgreSQL with all those options:

liblog-agent-perl lcov systemtap-sdt-dev llvm clang pkg-config libicu-dev libxml2-dev liblz4-dev libreadline-dev bison flex python-is-python3 zlib1g-dev libkrb5-dev libssl-dev libgss-dev libpam0g-dev libxslt1-dev libldap2-dev libsystemd-dev gettext tcl tcl-dev libperl-dev libpython3.8-dev libipc-run-perl dbtoepub fop libxml2-utils xsltproc libterm-table-perl libterm-readkey-perl libterm-size-any-perl

(I only attached the patch for configure.ac, you have to run autoconf to also update configure.)

Thoughts?

/Joel

[1]: https://github.com/truthly/magicmake
[2]: https://github.com/truthly/magicmake/raw/master/magicmake.gif

Attachments:

add-configure-cache-checkpoints.patchapplication/octet-stream; name=add-configure-cache-checkpoints.patchDownload
diff --git a/configure.ac b/configure.ac
index ba67c95bcc..fa71101e16 100644
--- a/configure.ac
+++ b/configure.ac
@@ -248,6 +248,8 @@ PGAC_ARG_BOOL(enable, tap-tests, no,
               [enable TAP tests (requires Perl and IPC::Run)])
 AC_SUBST(enable_tap_tests)
 
+AC_CACHE_SAVE
+
 #
 # Block size
 #
@@ -713,6 +715,7 @@ done
 IFS=$ac_save_IFS
 AC_SUBST(INCLUDES)
 
+AC_CACHE_SAVE
 
 #
 # Library directories
@@ -1011,6 +1014,8 @@ if test "$with_lz4" = yes; then
   done
 fi
 
+AC_CACHE_SAVE
+
 #
 # Assignments
 #
@@ -1194,6 +1199,8 @@ Use --without-readline to disable readline support.])
   fi
 fi
 
+AC_CACHE_SAVE
+
 if test "$with_zlib" = yes; then
   AC_CHECK_LIB(z, inflate, [],
                [AC_MSG_ERROR([zlib library not found
@@ -1225,6 +1232,8 @@ if test "$with_gssapi" = yes ; then
   fi
 fi
 
+AC_CACHE_SAVE
+
 #
 # SSL Library
 #
@@ -1285,6 +1294,8 @@ if test "$with_lz4" = yes ; then
   AC_CHECK_LIB(lz4, LZ4_compress_default, [], [AC_MSG_ERROR([library 'lz4' is required for LZ4 support])])
 fi
 
+AC_CACHE_SAVE
+
 # Note: We can test for libldap_r only after we know PTHREAD_LIBS
 if test "$with_ldap" = yes ; then
   _LIBS="$LIBS"
@@ -1432,6 +1443,8 @@ Use --without-readline to disable libedit support.])])])])
                 [AC_CHECK_HEADERS(readline/history.h)])])
 fi
 
+AC_CACHE_SAVE
+
 if test "$with_zlib" = yes; then
   AC_CHECK_HEADER(zlib.h, [], [AC_MSG_ERROR([zlib header not found
 If you have zlib already installed, see config.log for details on the
@@ -1499,6 +1512,8 @@ dnl If you want to use Apple's own Bonjour code on another platform,
 dnl just add -ldns_sd to LIBS manually.
 fi
 
+AC_CACHE_SAVE
+
 # for contrib/uuid-ossp
 if test "$with_uuid" = bsd ; then
   AC_CHECK_HEADERS(uuid.h,
@@ -2231,6 +2246,7 @@ if test x"$MEMSET_LOOP_LIMIT" = x"" ; then
 fi
 AC_DEFINE_UNQUOTED(MEMSET_LOOP_LIMIT, ${MEMSET_LOOP_LIMIT}, [Define bytes to use libc memset().])
 
+AC_CACHE_SAVE
 
 if test "$enable_nls" = yes ; then
   PGAC_CHECK_GETTEXT
@@ -2253,6 +2269,8 @@ Use --without-tcl to disable building PL/Tcl.])
     CPPFLAGS=$ac_save_CPPFLAGS
 fi
 
+AC_CACHE_SAVE
+
 # check for <perl.h>
 if test "$with_perl" = yes; then
   ac_save_CPPFLAGS=$CPPFLAGS