cpython: 3103af76f4c4 (original) (raw)
Mercurial > cpython
changeset 101000:3103af76f4c4
Issue #25702: A --with-lto configure option has been added that will enable link time optimizations at build time during a make profile-opt. [#25702]
Gregory P. Smith greg@krypto.org | |
---|---|
date | Fri, 15 Apr 2016 16:58:51 -0700 |
parents | e3c6362cc139(current diff)f16ec63055ad(diff) |
children | 7d61a991f405 |
files | Makefile.pre.in Misc/NEWS configure configure.ac |
diffstat | 4 files changed, 87 insertions(+), 2 deletions(-)[+] [-] Makefile.pre.in 4 Misc/NEWS 6 configure 46 configure.ac 33 |
line wrap: on
line diff
--- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -504,7 +504,7 @@ profile-opt: $(MAKE) profile-removal build_all_generate_profile:
- (MAKE)allCFLAGSNODIST="(MAKE) all CFLAGS_NODIST="(MAKE)allCFLAGSNODIST="(CFLAGS) (PGOPROFGENFLAG)"LDFLAGS="(PGO_PROF_GEN_FLAG)" LDFLAGS="(PGOPROFGENFLAG)"LDFLAGS="(LDFLAGS) (PGOPROFGENFLAG)"LIBS="(PGO_PROF_GEN_FLAG)" LIBS="(PGOPROFGENFLAG)"LIBS="(LIBS)"
- (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)" run_profile_task: : # FIXME: can't run for a cross build @@ -514,7 +514,7 @@ build_all_merge_profile: $(LLVM_PROF_MERGER) build_all_use_profile:
- (MAKE)allCFLAGSNODIST="(MAKE) all CFLAGS_NODIST="(MAKE)allCFLAGSNODIST="(CFLAGS) $(PGO_PROF_USE_FLAG)"
- (MAKE)allCFLAGSNODIST="(MAKE) all CFLAGS_NODIST="(MAKE)allCFLAGSNODIST="(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
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -976,6 +976,12 @@ Tests Build ----- +- Issue #25702: A --with-lto configure option has been added that will
- enable link time optimizations at build time during a make profile-opt.
- Some compilers and toolchains are known to not produce stable code when
- using LTO, be sure to test things thoroughly before relying on it.
- It can provide a few % speed up over profile-opt alone.
--- a/configure +++ b/configure @@ -673,6 +673,7 @@ LLVM_PROF_FILE LLVM_PROF_MERGER PGO_PROF_USE_FLAG PGO_PROF_GEN_FLAG +LTOFLAGS ABIFLAGS LN MKDIR_P @@ -807,6 +808,7 @@ with_suffix enable_shared enable_profiling with_pydebug +with_lto with_hash_algorithm with_address_sanitizer with_libs @@ -1487,6 +1489,8 @@ Optional Packages: compiler --with-suffix=.exe set executable suffix --with-pydebug build with Py_DEBUG defined
- --with-lto Enable Link Time Optimization in PGO builds.
--with-hash-algorithm=[fnv|siphash24] select hash algorithm --with-address-sanitizer @@ -6560,6 +6564,48 @@ else fi +# Enable LTO flags + +{ asecho"as_echo "asecho"as_me:${as_lineno-$LINENO}: checking for --with-lto" >&5 +$as_echo_n "checking for --with-lto... " >&6; } + +# Check whether --with-lto was given. +if test "${with_lto+set}" = set; then :Disabled by default.[](#l3.24)
- withval=$with_lto; +if test "$withval" != no +then
- Py_LTO='true'
- { asecho"as_echo "asecho"as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; +else
- Py_LTO='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_LTO" = 'true' ; then
- case $CC in
- clang)
# Any changes made here should be reflected in the GCC+Darwin case below[](#l3.58)
LTOFLAGS="-flto"[](#l3.59)
;;[](#l3.60)
- gcc)
case $ac_sys_system in[](#l3.62)
Darwin*)[](#l3.63)
LTOFLAGS="-flto"[](#l3.64)
;;[](#l3.65)
*)[](#l3.66)
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"[](#l3.67)
;;[](#l3.68)
esac[](#l3.69)
;;[](#l3.70)
- esac +fi +
Enable PGO flags.
--- a/configure.ac +++ b/configure.ac @@ -1235,6 +1235,39 @@ else AC_MSG_RESULT(no); Py_DEBUG='false' fi], [AC_MSG_RESULT(no)]) +# Enable LTO flags +AC_SUBST(LTOFLAGS) +AC_MSG_CHECKING(for --with-lto) +AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]), +[ +if test "$withval" != no +then
- Py_LTO='true'
- AC_MSG_RESULT(yes); +else
- Py_LTO='false'
- AC_MSG_RESULT(no); +fi], +[AC_MSG_RESULT(no)]) +if test "$Py_LTO" = 'true' ; then
- case $CC in
- clang)
# Any changes made here should be reflected in the GCC+Darwin case below[](#l4.24)
LTOFLAGS="-flto"[](#l4.25)
;;[](#l4.26)
- gcc)
case $ac_sys_system in[](#l4.28)
Darwin*)[](#l4.29)
LTOFLAGS="-flto"[](#l4.30)
;;[](#l4.31)
*)[](#l4.32)
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"[](#l4.33)
;;[](#l4.34)
esac[](#l4.35)
;;[](#l4.36)
- esac +fi +