Fix problem with caching in sub-configure scripts

Since the changes of ef2b015e39 (Export CC and similar variables for
sub-configure scripts, 2018-10-20), using "-C" option with configure
didn't work any longer when also using built-in libtiff or expat, as
their configure scripts aborted due to detecting inconsistent build
environment because the values of exported CC etc variables they saw
differed from the values in the cache file.

Fixing this seems to be difficult, as we'd need to update the cache
before running the sub-configure scripts (which is simple enough), but
also remove the cached entries from it after doing it, as otherwise we'd
get the same inconsistent build environment problem simply by running
"configure -C" without any other options twice in a row, because the
first run would cache CC=gcc etc.

So work around this instead by disabling cache when exporting these
variables. And to make this workaround less annoying, restrict it to
only the cases when it's really needed, i.e. when we do modify these
variables in a non-trivial way.

With these changes, "configure -C" works again, but only uses caching if
possible.
This commit is contained in:
Vadim Zeitlin 2020-07-18 16:54:13 +02:00
parent 15a4375f93
commit b79173943a
2 changed files with 42 additions and 3 deletions

16
configure vendored
View File

@ -18656,6 +18656,8 @@ fi
fi
export_compiler_flags=no
if test "$USE_DARWIN" = 1; then
retest_macosx_linking=no
@ -18708,6 +18710,8 @@ $as_echo "$as_me: WARNING: Disabling precompiled headers due to universal binary
OBJCXXFLAGS="$OSX_ARCH_OPTS $OBJCXXFLAGS"
OBJCFLAGS="$OSX_ARCH_OPTS $OBJCFLAGS"
LDFLAGS="$OSX_ARCH_OPTS $LDFLAGS"
export_compiler_flags=yes
fi
if test "$wxUSE_MAC" = 1; then
@ -18893,6 +18897,8 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
export_compiler_flags=yes
fi
fi
@ -19095,7 +19101,15 @@ if test "$USE_UNIX" = 1 ; then
fi
export CC CFLAGS CPP CPPFLAGS CXX CXXFLAGS LDD LDFLAGS OBJCFLAGS OBJCXXFLAGS
if test "$export_compiler_flags" = "yes"; then
export CC CFLAGS CPP CPPFLAGS CXX CXXFLAGS LDD LDFLAGS OBJCFLAGS OBJCXXFLAGS
if test "$cache_file" != "/dev/null"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Disabling caching due to a change in compiler options." >&5
$as_echo "$as_me: WARNING: Disabling caching due to a change in compiler options." >&2;}
cache_file="/dev/null"
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5

View File

@ -1177,6 +1177,11 @@ dnl ---------------------------------------------------------------------------
dnl Mac-specific SDK/architectures checks
dnl ---------------------------------------------------------------------------
dnl If we modify compiler or compiler flags variables in non-trivial way (e.g.
dnl by specifying the non-default architecture to use), we need to export them
dnl after doing it, so that sub-configure scripts use the same values too.
export_compiler_flags=no
dnl Note that some checks here are OS-specific, and need to be done for any
dnl port, while others are wxOSX-specific and are performed only for it inside
dnl another test below.
@ -1250,6 +1255,8 @@ if test "x$OSX_ARCH_OPTS" != "x"; then
OBJCXXFLAGS="$OSX_ARCH_OPTS $OBJCXXFLAGS"
OBJCFLAGS="$OSX_ARCH_OPTS $OBJCFLAGS"
LDFLAGS="$OSX_ARCH_OPTS $LDFLAGS"
export_compiler_flags=yes
fi
if test "$wxUSE_MAC" = 1; then
@ -1384,6 +1391,12 @@ version or omitting it entirely."
[AC_MSG_FAILURE([$error_message])]
)
AC_LANG_POP()
dnl If we are here, we must have set retest_macosx_linking to yes above,
dnl i.e. we must have modified compiler/linker variables to set
dnl SDK/availability options, and so we must export them to build any
dnl bundled third party libraries with them too.
export_compiler_flags=yes
fi
fi dnl USE_DARWIN
@ -1541,8 +1554,20 @@ if test "$USE_UNIX" = 1 ; then
fi
dnl Values of these variables shouldn't change any longer from now on, we
dnl export them to ensure they're picked up by sub-configure scripts.
export CC CFLAGS CPP CPPFLAGS CXX CXXFLAGS LDD LDFLAGS OBJCFLAGS OBJCXXFLAGS
dnl export them to ensure they're picked up by sub-configure scripts if they
dnl were modified above.
if test "$export_compiler_flags" = "yes"; then
export CC CFLAGS CPP CPPFLAGS CXX CXXFLAGS LDD LDFLAGS OBJCFLAGS OBJCXXFLAGS
if test "$cache_file" != "/dev/null"; then
dnl We must do this to avoid fatal errors due to inconsistent build
dnl environment from sub-configure scripts. We could do it just before
dnl actually running them, but doing it here is simpler and more robust
dnl (e.g. in case we add other sub-configure scripts later).
AC_MSG_WARN([Disabling caching due to a change in compiler options.])
cache_file="/dev/null"
fi
fi
dnl ------------------------------------------------------------------------
dnl Check for headers