cpython: 1e61cc86df03 (original) (raw)
Mercurial > cpython
changeset 103182:1e61cc86df03 3.5
Issue #26359: Add the --with-optimizations flag. [#26359]
Brett Cannon brett@python.org | |
---|---|
date | Tue, 06 Sep 2016 17:15:21 -0700 |
parents | 7d9cd4a0d488 |
children | f9b52b31f1b4 5f3f6f1fb73a |
files | Makefile.pre.in Misc/NEWS configure configure.ac |
diffstat | 4 files changed, 103 insertions(+), 17 deletions(-)[+] [-] Makefile.pre.in 8 Misc/NEWS 2 configure 69 configure.ac 41 |
line wrap: on
line diff
--- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -481,7 +481,7 @@ LIBRARY_OBJS= [](#l1.3)
Rules
Default target
-all: build_all +all: @DEF_MAKE_ALL_RULE@ build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config
Compile a binary with profile guided optimization.
@@ -505,7 +505,7 @@ profile-opt: $(MAKE) profile-removal build_all_generate_profile:
- (MAKE)allCFLAGSNODIST="(MAKE) all CFLAGS_NODIST="(MAKE)allCFLAGSNODIST="(CFLAGS) (PGOPROFGENFLAG)@LTOFLAGS@"LDFLAGS="(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="(PGOPROFGENFLAG)@LTOFLAGS@"LDFLAGS="(LDFLAGS) (PGOPROFGENFLAG)@LTOFLAGS@"LIBS="(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="(PGOPROFGENFLAG)@LTOFLAGS@"LIBS="(LIBS)"
- (MAKE)@DEFMAKERULE@CFLAGSNODIST="(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="(MAKE)@DEFMAKERULE@CFLAGSNODIST="(CFLAGS) (PGOPROFGENFLAG)@LTOFLAGS@"LDFLAGS="(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="(PGOPROFGENFLAG)@LTOFLAGS@"LDFLAGS="(LDFLAGS) (PGOPROFGENFLAG)@LTOFLAGS@"LIBS="(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="(PGOPROFGENFLAG)@LTOFLAGS@"LIBS="(LIBS)" run_profile_task: : # FIXME: can't run for a cross build @@ -515,14 +515,14 @@ build_all_merge_profile: $(LLVM_PROF_MERGER) build_all_use_profile:
- (MAKE)allCFLAGSNODIST="(MAKE) all CFLAGS_NODIST="(MAKE)allCFLAGSNODIST="(CFLAGS) (PGOPROFUSEFLAG)@LTOFLAGS@"LDFLAGS="(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="(PGOPROFUSEFLAG)@LTOFLAGS@"LDFLAGS="(LDFLAGS) @LTOFLAGS@"
- (MAKE)@DEFMAKERULE@CFLAGSNODIST="(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="(MAKE)@DEFMAKERULE@CFLAGSNODIST="(CFLAGS) (PGOPROFUSEFLAG)@LTOFLAGS@"LDFLAGS="(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="(PGOPROFUSEFLAG)@LTOFLAGS@"LDFLAGS="(LDFLAGS) @LTOFLAGS@"
Compile and run with gcov
.PHONY=coverage coverage-lcov coverage-report coverage: @echo "Building with support for coverage checking:" $(MAKE) clean profile-removal
- (MAKE)allCFLAGS="(MAKE) all CFLAGS="(MAKE)allCFLAGS="(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
- (MAKE)@DEFMAKERULE@CFLAGS="(MAKE) @DEF_MAKE_RULE@ CFLAGS="(MAKE)@DEFMAKERULE@CFLAGS="(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov" coverage-lcov: @echo "Creating Coverage HTML report with LCOV:"
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -256,6 +256,8 @@ Windows Build ----- +- Issue #26359: Add the --with-optimizations configure flag. +
- Issue #27713: Suppress spurious build warnings when updating importlib's bootstrap files. Patch by Xiang Zhang
--- a/configure +++ b/configure @@ -674,6 +674,8 @@ LLVM_PROF_MERGER PGO_PROF_USE_FLAG PGO_PROF_GEN_FLAG LTOFLAGS +DEF_MAKE_RULE +DEF_MAKE_ALL_RULE ABIFLAGS LN MKDIR_P @@ -774,7 +776,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -808,6 +809,7 @@ with_suffix enable_shared enable_profiling with_pydebug +with_optimizations with_lto with_hash_algorithm with_address_sanitizer @@ -885,7 +887,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1138,15 +1139,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated [](#l3.40)
- | --runstate | --runstat | --runsta | --runst | --runs [](#l3.41)
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* [](#l3.44)
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* [](#l3.45)
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* [](#l3.51) @@ -1284,7 +1276,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir [](#l3.53) datadir sysconfdir sharedstatedir localstatedir includedir [](#l3.54) oldincludedir docdir infodir htmldir dvidir pdfdir psdir [](#l3.55) - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=$$ac_var
Remove trailing slashes.
@@ -1437,7 +1429,6 @@ Fine tuning of the installation director --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1500,6 +1491,8 @@ Optional Packages: compiler --with-suffix=.exe set executable suffix --with-pydebug build with Py_DEBUG defined
- --with-optimizations Enable all optimizations when available (LTO, PGO,
--with-lto Enable Link Time Optimization in PGO builds. Disabled by default. --with-hash-algorithm=[fnv|siphash24] @@ -6528,6 +6521,46 @@ else fi +# Enable optimization flags + + +Py_OPT='false' +{ asecho"as_echo "asecho"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 :etc). Disabled by default.[](#l3.74)
- withval=$with_optimizations; +if test "$withval" != no +then
- Py_OPT='true'
- { asecho"as_echo "asecho"as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; +else
- Py_OPT='false'
- { asecho"as_echo "asecho"as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; +fi +else
- { asecho"as_echo "asecho"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.[](#l3.111)
Py_LTO='false'[](#l3.112)
;;[](#l3.113)
- 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
{ asecho"as_echo "asecho"as_me:${as_lineno-$LINENO}: checking for --with-lto" >&5 @@ -17636,3 +17669,13 @@ echo "creating Makefile" >&6 -s Modules Modules/Setup.config [](#l3.126) Modules/Setup.local Modules/Setup 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
--- a/configure.ac +++ b/configure.ac @@ -1230,6 +1230,37 @@ else AC_MSG_RESULT(no); Py_DEBUG='false' fi], [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.[](#l4.27)
Py_LTO='false'[](#l4.28)
;;[](#l4.29)
- 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
AC_SUBST(LTOFLAGS) AC_MSG_CHECKING(for --with-lto) @@ -5299,3 +5330,13 @@ echo "creating Makefile" >&AS_MESSAGE_FD -s Modules Modules/Setup.config [](#l4.42) Modules/Setup.local Modules/Setup mv config.c Modules + +if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then