summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-06-02 23:44:40 +0000
committerGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-06-02 23:44:40 +0000
commitc543a0fc3b2052c35fced09e1f96613625723508 (patch)
treef551ebf654a813212517ab06f94ca3908e67d5ea /configure.ac
parente725777eaf430c67db5f4c9cc1f5ee77bc5ad3b5 (diff)
downloadcpython-git-c543a0fc3b2052c35fced09e1f96613625723508.tar.gz
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.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac34
1 files changed, 34 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index f0082fdfb6..06c877b854 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1377,6 +1377,40 @@ then
fi
+# 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.
AC_SUBST(PGO_PROF_GEN_FLAG)
AC_SUBST(PGO_PROF_USE_FLAG)