Issue #25702: A --with-lto configure option has been added that will

enable link time optimizations at build time during a make profile-opt.
This commit is contained in:
Gregory P. Smith 2016-04-15 16:57:04 -07:00
parent 1ff6b6ab12
commit d82da9f7f2
4 changed files with 87 additions and 2 deletions

View File

@ -504,7 +504,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)" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)" $(MAKE) all 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
@ -514,7 +514,7 @@ 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)" $(MAKE) all 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

View File

@ -388,6 +388,12 @@ Tests
Build 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.
- Issue #26624: Adds validation of ucrtbase[d].dll version with warning - Issue #26624: Adds validation of ucrtbase[d].dll version with warning
for old versions. for old versions.

46
configure vendored
View File

@ -673,6 +673,7 @@ LLVM_PROF_FILE
LLVM_PROF_MERGER LLVM_PROF_MERGER
PGO_PROF_USE_FLAG PGO_PROF_USE_FLAG
PGO_PROF_GEN_FLAG PGO_PROF_GEN_FLAG
LTOFLAGS
ABIFLAGS ABIFLAGS
LN LN
MKDIR_P MKDIR_P
@ -807,6 +808,7 @@ with_suffix
enable_shared enable_shared
enable_profiling enable_profiling
with_pydebug with_pydebug
with_lto
with_hash_algorithm with_hash_algorithm
with_address_sanitizer with_address_sanitizer
with_libs with_libs
@ -1487,6 +1489,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-lto Enable Link Time Optimization in PGO builds.
Disabled by default.
--with-hash-algorithm=[fnv|siphash24] --with-hash-algorithm=[fnv|siphash24]
select hash algorithm select hash algorithm
--with-address-sanitizer --with-address-sanitizer
@ -6560,6 +6564,48 @@ $as_echo "no" >&6; }
fi fi
# Enable LTO flags
{ $as_echo "$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 :
withval=$with_lto;
if test "$withval" != no
then
Py_LTO='true'
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; };
else
Py_LTO='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_LTO" = 'true' ; then
case $CC in
*clang*)
# Any changes made here should be reflected in the GCC+Darwin case below
LTOFLAGS="-flto"
;;
*gcc*)
case $ac_sys_system in
Darwin*)
LTOFLAGS="-flto"
;;
*)
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
;;
esac
;;
esac
fi
# Enable PGO flags. # Enable PGO flags.

View File

@ -1235,6 +1235,39 @@ else AC_MSG_RESULT(no); Py_DEBUG='false'
fi], fi],
[AC_MSG_RESULT(no)]) [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
LTOFLAGS="-flto"
;;
*gcc*)
case $ac_sys_system in
Darwin*)
LTOFLAGS="-flto"
;;
*)
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
;;
esac
;;
esac
fi
# Enable PGO flags. # Enable PGO flags.
AC_SUBST(PGO_PROF_GEN_FLAG) AC_SUBST(PGO_PROF_GEN_FLAG)
AC_SUBST(PGO_PROF_USE_FLAG) AC_SUBST(PGO_PROF_USE_FLAG)