diff -r 789a3f87bde1 Makefile.pre.in --- a/Makefile.pre.in Mon May 16 01:07:13 2016 +0000 +++ b/Makefile.pre.in Mon May 16 15:36:39 2016 +0300 @@ -427,7 +427,7 @@ # Rules # Default target -all: build_all +all: @DEF_MAKE_ALL_RULE@ build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks # Compile a binary with profile guided optimization. @@ -451,7 +451,7 @@ $(MAKE) profile-removal build_all_generate_profile: - $(MAKE) all CFLAGS="$(CFLAGS) $(PGO_PROF_GEN_FLAG)" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)" + $(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) $(PGO_PROF_GEN_FLAG)" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)" run_profile_task: : # FIXME: can't run for a cross build @@ -461,14 +461,14 @@ $(LLVM_PROF_MERGER) build_all_use_profile: - $(MAKE) all CFLAGS="$(CFLAGS) $(PGO_PROF_USE_FLAG)" + $(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) $(PGO_PROF_USE_FLAG)" # Compile and run with gcov .PHONY=coverage coverage-lcov coverage-report coverage: @echo "Building with support for coverage checking:" $(MAKE) clean profile-removal - $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov" + $(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov" coverage-lcov: @echo "Creating Coverage HTML report with LCOV:" diff -r 789a3f87bde1 configure --- a/configure Mon May 16 01:07:13 2016 +0000 +++ b/configure Mon May 16 15:36:39 2016 +0300 @@ -667,6 +667,8 @@ LLVM_PROF_MERGER PGO_PROF_USE_FLAG PGO_PROF_GEN_FLAG +DEF_MAKE_RULE +DEF_MAKE_ALL_RULE UNIVERSAL_ARCH_FLAGS BASECFLAGS OPT @@ -763,6 +765,7 @@ docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -796,6 +799,7 @@ enable_shared enable_profiling with_pydebug +with_optimizations enable_toolbox_glue with_libs with_system_expat @@ -872,6 +876,7 @@ sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1124,6 +1129,15 @@ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1261,7 +1275,7 @@ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1414,6 +1428,7 @@ --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] @@ -1477,6 +1492,8 @@ compiler --with-suffix=.exe set executable suffix --with-pydebug build with Py_DEBUG defined + --with-optimizations Enable all optimizations (LTO, PGO, etc). Disabled + by default. --with-libs='lib1 ...' link against additional libs --with-system-expat build pyexpat module using an installed expat library @@ -2783,6 +2800,7 @@ ac_config_headers="$ac_config_headers pyconfig.h" + ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then @@ -6366,6 +6384,41 @@ fi +# Enable optimization flags + + +Py_OPT='false' +{ $as_echo "$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 : + withval=$with_optimizations; +if test "$withval" != no +then + Py_OPT='true' + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; +else + Py_OPT='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_OPT" = 'true' ; then + Py_LTO='true' + DEF_MAKE_ALL_RULE="profile-opt" + DEF_MAKE_RULE="build_all" +else + DEF_MAKE_ALL_RULE="build_all" + DEF_MAKE_RULE="all" +fi + + # Enable PGO flags. @@ -16297,3 +16350,12 @@ esac mv config.c Modules + +if test "$Py_OPT" = 'false'; 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 +fi diff -r 789a3f87bde1 configure.ac --- a/configure.ac Mon May 16 01:07:13 2016 +0000 +++ b/configure.ac Mon May 16 15:36:39 2016 +0300 @@ -1377,6 +1377,32 @@ fi +# 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 (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' + DEF_MAKE_ALL_RULE="profile-opt" + DEF_MAKE_RULE="build_all" +else + DEF_MAKE_ALL_RULE="build_all" + DEF_MAKE_RULE="all" +fi + + # Enable PGO flags. AC_SUBST(PGO_PROF_GEN_FLAG) AC_SUBST(PGO_PROF_USE_FLAG) @@ -4739,3 +4765,12 @@ esac mv config.c Modules + +if test "$Py_OPT" = 'false'; then + echo "" >&AS_MESSAGE_FD + echo "" >&AS_MESSAGE_FD + echo "If you want a release build with all optimizations active (LTO, PGO, etc)," + echo "please run ./configure --with-optimizations" >&AS_MESSAGE_FD + echo "" >&AS_MESSAGE_FD + echo "" >&AS_MESSAGE_FD +fi