Issue #26359: Add the --with-optimizations flag.
This commit is contained in:
parent
653c850919
commit
8c94f97465
|
@ -481,7 +481,7 @@ LIBRARY_OBJS= \
|
||||||
# Rules
|
# Rules
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
all: build_all
|
all: @DEF_MAKE_ALL_RULE@
|
||||||
build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config
|
build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config
|
||||||
|
|
||||||
# Compile a binary with profile guided optimization.
|
# Compile a binary with profile guided optimization.
|
||||||
|
@ -505,7 +505,7 @@ profile-opt:
|
||||||
$(MAKE) profile-removal
|
$(MAKE) profile-removal
|
||||||
|
|
||||||
build_all_generate_profile:
|
build_all_generate_profile:
|
||||||
$(MAKE) all CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
|
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
|
||||||
|
|
||||||
run_profile_task:
|
run_profile_task:
|
||||||
: # FIXME: can't run for a cross build
|
: # FIXME: can't run for a cross build
|
||||||
|
@ -515,14 +515,14 @@ build_all_merge_profile:
|
||||||
$(LLVM_PROF_MERGER)
|
$(LLVM_PROF_MERGER)
|
||||||
|
|
||||||
build_all_use_profile:
|
build_all_use_profile:
|
||||||
$(MAKE) all CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@"
|
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@"
|
||||||
|
|
||||||
# Compile and run with gcov
|
# Compile and run with gcov
|
||||||
.PHONY=coverage coverage-lcov coverage-report
|
.PHONY=coverage coverage-lcov coverage-report
|
||||||
coverage:
|
coverage:
|
||||||
@echo "Building with support for coverage checking:"
|
@echo "Building with support for coverage checking:"
|
||||||
$(MAKE) clean profile-removal
|
$(MAKE) clean profile-removal
|
||||||
$(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
|
$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
|
||||||
|
|
||||||
coverage-lcov:
|
coverage-lcov:
|
||||||
@echo "Creating Coverage HTML report with LCOV:"
|
@echo "Creating Coverage HTML report with LCOV:"
|
||||||
|
|
|
@ -256,6 +256,8 @@ Windows
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Issue #26359: Add the --with-optimizations configure flag.
|
||||||
|
|
||||||
- Issue #27713: Suppress spurious build warnings when updating importlib's
|
- Issue #27713: Suppress spurious build warnings when updating importlib's
|
||||||
bootstrap files. Patch by Xiang Zhang
|
bootstrap files. Patch by Xiang Zhang
|
||||||
|
|
||||||
|
|
|
@ -674,6 +674,8 @@ LLVM_PROF_MERGER
|
||||||
PGO_PROF_USE_FLAG
|
PGO_PROF_USE_FLAG
|
||||||
PGO_PROF_GEN_FLAG
|
PGO_PROF_GEN_FLAG
|
||||||
LTOFLAGS
|
LTOFLAGS
|
||||||
|
DEF_MAKE_RULE
|
||||||
|
DEF_MAKE_ALL_RULE
|
||||||
ABIFLAGS
|
ABIFLAGS
|
||||||
LN
|
LN
|
||||||
MKDIR_P
|
MKDIR_P
|
||||||
|
@ -774,7 +776,6 @@ infodir
|
||||||
docdir
|
docdir
|
||||||
oldincludedir
|
oldincludedir
|
||||||
includedir
|
includedir
|
||||||
runstatedir
|
|
||||||
localstatedir
|
localstatedir
|
||||||
sharedstatedir
|
sharedstatedir
|
||||||
sysconfdir
|
sysconfdir
|
||||||
|
@ -808,6 +809,7 @@ with_suffix
|
||||||
enable_shared
|
enable_shared
|
||||||
enable_profiling
|
enable_profiling
|
||||||
with_pydebug
|
with_pydebug
|
||||||
|
with_optimizations
|
||||||
with_lto
|
with_lto
|
||||||
with_hash_algorithm
|
with_hash_algorithm
|
||||||
with_address_sanitizer
|
with_address_sanitizer
|
||||||
|
@ -885,7 +887,6 @@ datadir='${datarootdir}'
|
||||||
sysconfdir='${prefix}/etc'
|
sysconfdir='${prefix}/etc'
|
||||||
sharedstatedir='${prefix}/com'
|
sharedstatedir='${prefix}/com'
|
||||||
localstatedir='${prefix}/var'
|
localstatedir='${prefix}/var'
|
||||||
runstatedir='${localstatedir}/run'
|
|
||||||
includedir='${prefix}/include'
|
includedir='${prefix}/include'
|
||||||
oldincludedir='/usr/include'
|
oldincludedir='/usr/include'
|
||||||
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
||||||
|
@ -1138,15 +1139,6 @@ do
|
||||||
| -silent | --silent | --silen | --sile | --sil)
|
| -silent | --silent | --silen | --sile | --sil)
|
||||||
silent=yes ;;
|
silent=yes ;;
|
||||||
|
|
||||||
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
|
||||||
| --runstate | --runstat | --runsta | --runst | --runs \
|
|
||||||
| --run | --ru | --r)
|
|
||||||
ac_prev=runstatedir ;;
|
|
||||||
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
|
||||||
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
|
||||||
| --run=* | --ru=* | --r=*)
|
|
||||||
runstatedir=$ac_optarg ;;
|
|
||||||
|
|
||||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||||
ac_prev=sbindir ;;
|
ac_prev=sbindir ;;
|
||||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||||
|
@ -1284,7 +1276,7 @@ fi
|
||||||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||||
libdir localedir mandir runstatedir
|
libdir localedir mandir
|
||||||
do
|
do
|
||||||
eval ac_val=\$$ac_var
|
eval ac_val=\$$ac_var
|
||||||
# Remove trailing slashes.
|
# Remove trailing slashes.
|
||||||
|
@ -1437,7 +1429,6 @@ Fine tuning of the installation directories:
|
||||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||||
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
|
||||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||||
--includedir=DIR C header files [PREFIX/include]
|
--includedir=DIR C header files [PREFIX/include]
|
||||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||||
|
@ -1500,6 +1491,8 @@ Optional Packages:
|
||||||
compiler
|
compiler
|
||||||
--with-suffix=.exe set executable suffix
|
--with-suffix=.exe set executable suffix
|
||||||
--with-pydebug build with Py_DEBUG defined
|
--with-pydebug build with Py_DEBUG defined
|
||||||
|
--with-optimizations Enable all optimizations when available (LTO, PGO,
|
||||||
|
etc). Disabled by default.
|
||||||
--with-lto Enable Link Time Optimization in PGO builds.
|
--with-lto Enable Link Time Optimization in PGO builds.
|
||||||
Disabled by default.
|
Disabled by default.
|
||||||
--with-hash-algorithm=[fnv|siphash24]
|
--with-hash-algorithm=[fnv|siphash24]
|
||||||
|
@ -6528,6 +6521,46 @@ $as_echo "no" >&6; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Enable optimization flags
|
||||||
|
|
||||||
|
|
||||||
|
Py_OPT='false'
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-optimizations" >&5
|
||||||
|
$as_echo_n "checking for --with-optimizations... " >&6; }
|
||||||
|
|
||||||
|
# Check whether --with-optimizations was given.
|
||||||
|
if test "${with_optimizations+set}" = set; then :
|
||||||
|
withval=$with_optimizations;
|
||||||
|
if test "$withval" != no
|
||||||
|
then
|
||||||
|
Py_OPT='true'
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||||
|
$as_echo "yes" >&6; };
|
||||||
|
else
|
||||||
|
Py_OPT='false'
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||||
|
$as_echo "no" >&6; };
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||||
|
$as_echo "no" >&6; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$Py_OPT" = 'true' ; then
|
||||||
|
Py_LTO='true'
|
||||||
|
case $ac_sys_system in
|
||||||
|
Darwin*)
|
||||||
|
# At least on macOS El Capitan, LTO does not work with PGO.
|
||||||
|
Py_LTO='false'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
DEF_MAKE_ALL_RULE="profile-opt"
|
||||||
|
DEF_MAKE_RULE="build_all"
|
||||||
|
else
|
||||||
|
DEF_MAKE_ALL_RULE="build_all"
|
||||||
|
DEF_MAKE_RULE="all"
|
||||||
|
fi
|
||||||
|
|
||||||
# Enable LTO flags
|
# Enable LTO flags
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-lto" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-lto" >&5
|
||||||
|
@ -17636,3 +17669,13 @@ $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
|
||||||
-s Modules Modules/Setup.config \
|
-s Modules Modules/Setup.config \
|
||||||
Modules/Setup.local Modules/Setup
|
Modules/Setup.local Modules/Setup
|
||||||
mv config.c Modules
|
mv config.c Modules
|
||||||
|
|
||||||
|
if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
|
||||||
|
echo "" >&6
|
||||||
|
echo "" >&6
|
||||||
|
echo "If you want a release build with all optimizations active (LTO, PGO, etc),"
|
||||||
|
echo "please run ./configure --with-optimizations" >&6
|
||||||
|
echo "" >&6
|
||||||
|
echo "" >&6
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
41
configure.ac
41
configure.ac
|
@ -1230,6 +1230,37 @@ else AC_MSG_RESULT(no); Py_DEBUG='false'
|
||||||
fi],
|
fi],
|
||||||
[AC_MSG_RESULT(no)])
|
[AC_MSG_RESULT(no)])
|
||||||
|
|
||||||
|
# Enable optimization flags
|
||||||
|
AC_SUBST(DEF_MAKE_ALL_RULE)
|
||||||
|
AC_SUBST(DEF_MAKE_RULE)
|
||||||
|
Py_OPT='false'
|
||||||
|
AC_MSG_CHECKING(for --with-optimizations)
|
||||||
|
AC_ARG_WITH(optimizations, AS_HELP_STRING([--with-optimizations], [Enable all optimizations when available (LTO, PGO, etc). Disabled by default.]),
|
||||||
|
[
|
||||||
|
if test "$withval" != no
|
||||||
|
then
|
||||||
|
Py_OPT='true'
|
||||||
|
AC_MSG_RESULT(yes);
|
||||||
|
else
|
||||||
|
Py_OPT='false'
|
||||||
|
AC_MSG_RESULT(no);
|
||||||
|
fi],
|
||||||
|
[AC_MSG_RESULT(no)])
|
||||||
|
if test "$Py_OPT" = 'true' ; then
|
||||||
|
Py_LTO='true'
|
||||||
|
case $ac_sys_system in
|
||||||
|
Darwin*)
|
||||||
|
# At least on macOS El Capitan, LTO does not work with PGO.
|
||||||
|
Py_LTO='false'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
DEF_MAKE_ALL_RULE="profile-opt"
|
||||||
|
DEF_MAKE_RULE="build_all"
|
||||||
|
else
|
||||||
|
DEF_MAKE_ALL_RULE="build_all"
|
||||||
|
DEF_MAKE_RULE="all"
|
||||||
|
fi
|
||||||
|
|
||||||
# Enable LTO flags
|
# Enable LTO flags
|
||||||
AC_SUBST(LTOFLAGS)
|
AC_SUBST(LTOFLAGS)
|
||||||
AC_MSG_CHECKING(for --with-lto)
|
AC_MSG_CHECKING(for --with-lto)
|
||||||
|
@ -5299,3 +5330,13 @@ $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
|
||||||
-s Modules Modules/Setup.config \
|
-s Modules Modules/Setup.config \
|
||||||
Modules/Setup.local Modules/Setup
|
Modules/Setup.local Modules/Setup
|
||||||
mv config.c Modules
|
mv config.c Modules
|
||||||
|
|
||||||
|
if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
|
||||||
|
echo "" >&AS_MESSAGE_FD
|
||||||
|
echo "" >&AS_MESSAGE_FD
|
||||||
|
echo "If you want a release build with all optimizations active (LTO, PGO, etc),"
|
||||||
|
echo "please run ./configure --with-optimizations" >&AS_MESSAGE_FD
|
||||||
|
echo "" >&AS_MESSAGE_FD
|
||||||
|
echo "" >&AS_MESSAGE_FD
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue