# Author: Alecsandru Patrascu diff -r 59f33f4249ec Makefile.pre.in --- a/Makefile.pre.in Sun Nov 22 23:46:02 2015 -0800 +++ b/Makefile.pre.in Mon Nov 23 16:19:31 2015 +0200 @@ -48,6 +48,7 @@ LLVM_PROF_MERGER=@LLVM_PROF_MERGER@ LLVM_PROF_FILE=@LLVM_PROF_FILE@ LLVM_PROF_ERR=@LLVM_PROF_ERR@ +LTOFLAGS=@LTOFLAGS@ GNULD= @GNULD@ @@ -75,13 +76,13 @@ OPT= @OPT@ BASECFLAGS= @BASECFLAGS@ BASECPPFLAGS= @BASECPPFLAGS@ -CONFIGURE_CFLAGS= @CFLAGS@ +CONFIGURE_CFLAGS= @CFLAGS@ $(LTOFLAGS) # CFLAGS_NODIST is used for building the interpreter and stdlib C extensions. # Use it when a compiler flag should _not_ be part of the distutils CFLAGS # once Python is installed (Issue #21121). -CONFIGURE_CFLAGS_NODIST=@CFLAGS_NODIST@ -CONFIGURE_CPPFLAGS= @CPPFLAGS@ -CONFIGURE_LDFLAGS= @LDFLAGS@ +CONFIGURE_CFLAGS_NODIST=@CFLAGS_NODIST@ $(LTOFLAGS) +CONFIGURE_CPPFLAGS= @CPPFLAGS@ $(LTOFLAGS) +CONFIGURE_LDFLAGS= @LDFLAGS@ $(LTOFLAGS) # Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the # command line to append to these values without stomping the pre-set # values. diff -r 59f33f4249ec configure --- a/configure Sun Nov 22 23:46:02 2015 -0800 +++ b/configure Mon Nov 23 16:19:31 2015 +0200 @@ -673,6 +673,7 @@ LLVM_PROF_MERGER PGO_PROF_USE_FLAG PGO_PROF_GEN_FLAG +LTOFLAGS ABIFLAGS LN MKDIR_P @@ -806,6 +807,7 @@ enable_shared enable_profiling with_pydebug +with_lto with_hash_algorithm with_address_sanitizer with_libs @@ -1485,6 +1487,7 @@ compiler --with-suffix=.exe set executable suffix --with-pydebug build with Py_DEBUG defined + --with-lto Enable Link Time Optimizations. Disabled by default. --with-hash-algorithm=[fnv|siphash24] select hash algorithm --with-address-sanitizer @@ -6437,6 +6440,39 @@ 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 + 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 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; +fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + # Enable PGO flags. # Extract the first word of "llvm-profdata", so it can be a program name with args. set dummy llvm-profdata; ac_word=$2 diff -r 59f33f4249ec configure.ac --- a/configure.ac Sun Nov 22 23:46:02 2015 -0800 +++ b/configure.ac Mon Nov 23 16:19:31 2015 +0200 @@ -1218,6 +1218,34 @@ 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 Optimizations. Disabled by default.]), +[ +if test "$withval" != no +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 + AC_MSG_RESULT(yes); +fi], +[AC_MSG_RESULT(no)]) + + # Enable PGO flags. AC_SUBST(PGO_PROF_GEN_FLAG) AC_SUBST(PGO_PROF_USE_FLAG)