Disable the use of precompiled headers under Unix by default

The speed advantage from using them is very variable, rarely big and
sometimes even negative, while the space penalty is consistently huge,
so it doesn't seem like a good trade-off to enable them by default.
This commit is contained in:
Vadim Zeitlin 2017-10-21 22:34:45 +02:00
parent afdfc02a49
commit 9f4f075034
2 changed files with 61 additions and 121 deletions

98
configure vendored
View File

@ -1132,6 +1132,7 @@ enable_rpath
enable_visibility
enable_tls
enable_repro_build
enable_pch
enable_intl
enable_xlocale
enable_config
@ -2072,6 +2073,7 @@ Optional Features:
--disable-visibility disable use of ELF symbols visibility even if supported
--disable-tls disable use of compiler TLS support
--enable-repro-build enable reproducible build mode
--enable-pch use precompiled headers if possible (off by default)
--enable-intl use internationalization system
--enable-xlocale use x-locale support (requires wxLocale)
--enable-config use wxConfig (and derived) classes
@ -6074,6 +6076,35 @@ fi
eval "$wx_cv_use_repro_build"
enablestring=
defaultval=
if test -z "$defaultval"; then
if test x"$enablestring" = xdisable; then
defaultval=yes
else
defaultval=no
fi
fi
# Check whether --enable-pch was given.
if test "${enable_pch+set}" = set; then :
enableval=$enable_pch;
if test "$enableval" = yes; then
wx_cv_use_pch='wxUSE_PCH=yes'
else
wx_cv_use_pch='wxUSE_PCH=no'
fi
else
wx_cv_use_pch='wxUSE_PCH=${'DEFAULT_wxUSE_PCH":-$defaultval}"
fi
eval "$wx_cv_use_pch"
enablestring=
@ -17390,9 +17421,11 @@ if test "x$OSX_ARCH_OPTS" != "x"; then
$as_echo "$as_me: WARNING: Disabling dependency tracking due to universal binary build." >&2;}
disable_macosx_deps=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Disabling precompiled headers due to universal binary build." >&5
if test "x$wxUSE_PCH" = "xyes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Disabling precompiled headers due to universal binary build." >&5
$as_echo "$as_me: WARNING: Disabling precompiled headers due to universal binary build." >&2;}
bk_use_pch=no
wxUSE_PCH=no
fi
fi
OSX_ARCH_OPTS=`echo $OSX_ARCH_OPTS | sed -e 's/^/-arch /' -e 's/,/ -arch /g'`
@ -35894,57 +35927,15 @@ case "$TOOLKIT" in
;;
esac
if test "$wxUSE_PCH" != "yes"; then
bk_use_pch=no
fi
if test "$wxUSE_WINE" = "yes"; then
BAKEFILE_FORCE_PLATFORM=win32
fi
if test "$wxUSE_UNICODE" = yes -a "$GCC" = yes -a "$bk_use_pch" != no
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc precompiled header bug" >&5
$as_echo_n "checking for gcc precompiled header bug... " >&6; }
if ${wx_cv_gcc_pch_bug+:} false; then :
$as_echo_n "(cached) " >&6
else
echo '#include <stdio.h>
const wchar_t test_var[] = L"awidetest";' > conftest.h
echo '#include "conftest.h"
int main()
{
printf("%ls", test_var);
return 0;
}' > conftest.cpp
wx_cv_gcc_pch_bug="pch not supported"
if $CXX conftest.h >/dev/null 2>&1
then
wx_cv_gcc_pch_bug=
if $CXX -o conftest$PROGRAM_EXT conftest.cpp >/dev/null 2>&1
then
if tr -dc '[a-z]' < conftest$PROGRAM_EXT |
grep awidetest >/dev/null
then
wx_cv_gcc_pch_bug=no
else
wx_cv_gcc_pch_bug=yes
fi
fi
fi
rm -f conftest.h conftest.gch conftest.cpp conftest$PROGRAM_EXT
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wx_cv_gcc_pch_bug" >&5
$as_echo "$wx_cv_gcc_pch_bug" >&6; }
if test "$wx_cv_gcc_pch_bug" = yes; then
bk_use_pch=no
fi
fi
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
@ -38374,15 +38365,6 @@ fi
if test $GCC_PCH = 1
then
if test "$wx_cv_gcc_pch_bug" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Precompiled header support is broken on this compiler" >&5
$as_echo "$as_me: WARNING: *** Precompiled header support is broken on this compiler" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** --enable-precomp-headers is not recommended" >&5
$as_echo "$as_me: WARNING: *** --enable-precomp-headers is not recommended" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13361" >&5
$as_echo "$as_me: WARNING: *** see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13361" >&2;}
fi
# Our WX_PRECOMP flag does not make sense for any language except C++ because
# the headers that benefit from precompilation are mostly C++ headers.
CXXFLAGS="-DWX_PRECOMP $CXXFLAGS"

View File

@ -673,7 +673,8 @@ WX_ARG_DISABLE(rpath, [ --disable-rpath disable use of rpath for
WX_ARG_DISABLE(visibility, [ --disable-visibility disable use of ELF symbols visibility even if supported], wxUSE_VISIBILITY)
WX_ARG_DISABLE(tls, [ --disable-tls disable use of compiler TLS support], wxUSE_COMPILER_TLS)
WX_ARG_ENABLE(repro_build, [ --enable-repro-build enable reproducible build mode], wxUSE_REPRODUCIBLE_BUILD)
WX_ARG_ENABLE(repro_build, [ --enable-repro-build enable reproducible build mode], wxUSE_REPRODUCIBLE_BUILD)
WX_ARG_ENABLE(pch, [ --enable-pch use precompiled headers if possible (off by default)], wxUSE_PCH)
dnl ---------------------------------------------------------------------------
dnl optional non GUI features
@ -1181,12 +1182,14 @@ if test "x$OSX_ARCH_OPTS" != "x"; then
AC_MSG_WARN([Disabling dependency tracking due to universal binary build.])
disable_macosx_deps=yes
dnl HACK: PCH could be made to work by precompiling for each architecture into separate directories
dnl and including all architecture directories with each compiler invocation.
dnl That would require a major rework of Bakefile and at the same time it would be nice to have
dnl Objective-C++ precompiled headers.
AC_MSG_WARN([Disabling precompiled headers due to universal binary build.])
bk_use_pch=no
if test "x$wxUSE_PCH" = "xyes"; then
dnl HACK: PCH could be made to work by precompiling for each architecture into separate directories
dnl and including all architecture directories with each compiler invocation.
dnl That would require a major rework of Bakefile and at the same time it would be nice to have
dnl Objective-C++ precompiled headers.
AC_MSG_WARN([Disabling precompiled headers due to universal binary build.])
wxUSE_PCH=no
fi
fi
OSX_ARCH_OPTS=`echo $OSX_ARCH_OPTS | sed -e 's/^/-arch /' -e 's/,/ -arch /g'`
@ -7937,55 +7940,18 @@ case "$TOOLKIT" in
;;
esac
if test "$wxUSE_WINE" = "yes"; then
BAKEFILE_FORCE_PLATFORM=win32
dnl Override some bakefile defaults before including autoconf_inc.m4
dnl Bakefile-generated makefiles use PCH by default, but we require explicitly
dnl enabling it with --enable-pch as in many cases the speed gain from using it
dnl is tiny, while the space penalty is enormous, and in some cases this can
dnl even make PCH build slower than the build without PCH.
if test "$wxUSE_PCH" != "yes"; then
bk_use_pch=no
fi
dnl gcc 3.4 has a pch bug which truncates wide character constants in headers.
dnl Hopefully for a non-unicode build there aren't any wide constants in
dnl headers, but for a unicode build it's best to disable pch.
if test "$wxUSE_UNICODE" = yes -a "$GCC" = yes -a "$bk_use_pch" != no
then
AC_CACHE_CHECK(
[for gcc precompiled header bug],
[wx_cv_gcc_pch_bug],
[[
echo '#include <stdio.h>
const wchar_t test_var[] = L"awidetest";' > conftest.h
echo '#include "conftest.h"
int main()
{
printf("%ls", test_var);
return 0;
}' > conftest.cpp
wx_cv_gcc_pch_bug="pch not supported"
if $CXX conftest.h >/dev/null 2>&1
then
wx_cv_gcc_pch_bug=
if $CXX -o conftest$PROGRAM_EXT conftest.cpp >/dev/null 2>&1
then
if tr -dc '[a-z]' < conftest$PROGRAM_EXT |
grep awidetest >/dev/null
then
wx_cv_gcc_pch_bug=no
else
wx_cv_gcc_pch_bug=yes
fi
fi
fi
rm -f conftest.h conftest.gch conftest.cpp conftest$PROGRAM_EXT
]])
if test "$wx_cv_gcc_pch_bug" = yes; then
dnl make the default for pch 'no'
dnl further below check whether the user overrode and warn them
bk_use_pch=no
fi
if test "$wxUSE_WINE" = "yes"; then
BAKEFILE_FORCE_PLATFORM=win32
fi
AC_BAKEFILE([m4_include(autoconf_inc.m4)])
@ -8015,17 +7981,9 @@ fi
dnl wxUSE_GUI = 1
dnl find out if the compiler supports PCH
dnl
dnl TODO: this should be in bakefile
dnl Use gcc precompiled headers if supported.
if test $GCC_PCH = 1
then
if test "$wx_cv_gcc_pch_bug" = yes; then
AC_MSG_WARN([*** Precompiled header support is broken on this compiler])
AC_MSG_WARN([*** --enable-precomp-headers is not recommended])
AC_MSG_WARN([*** see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13361])
fi
# Our WX_PRECOMP flag does not make sense for any language except C++ because
# the headers that benefit from precompilation are mostly C++ headers.
CXXFLAGS="-DWX_PRECOMP $CXXFLAGS"