# Author: Alecsandru Patrascu diff -r acc453391c5b Makefile.pre.in --- a/Makefile.pre.in Sat Oct 24 17:39:36 2015 +0300 +++ b/Makefile.pre.in Fri Oct 30 09:38:20 2015 +0200 @@ -47,6 +47,7 @@ LLVM_PROF_MERGER=@LLVM_PROF_MERGER@ LLVM_PROF_FILE=@LLVM_PROF_FILE@ LLVM_PROF_ERR=@LLVM_PROF_ERR@ +LTOFLAGS=@LTOFLAGS@ GNULD= @GNULD@ @@ -445,7 +446,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) all CFLAGS="$(CFLAGS) $(PGO_PROF_GEN_FLAG) $(LTOFLAGS)" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) $(LTOFLAGS)" LIBS="$(LIBS)" run_profile_task: : # FIXME: can't run for a cross build @@ -455,7 +456,7 @@ $(LLVM_PROF_MERGER) build_all_use_profile: - $(MAKE) all CFLAGS="$(CFLAGS) $(PGO_PROF_USE_FLAG)" + $(MAKE) all CFLAGS="$(CFLAGS) $(PGO_PROF_USE_FLAG) $(LTOFLAGS)" LDFLAGS="$(LDFLAGS) $(LTOFLAGS)" coverage: @echo "Building with support for coverage checking:" diff -r acc453391c5b configure --- a/configure Sat Oct 24 17:39:36 2015 +0300 +++ b/configure Fri Oct 30 09:38:20 2015 +0200 @@ -661,6 +661,7 @@ SO LIBTOOL_CRUFT OTHER_LIBTOOL_OPT +LTOFLAGS LLVM_PROF_FOUND LLVM_PROF_ERR LLVM_PROF_FILE @@ -6332,8 +6333,7 @@ CFLAGS=$save_CFLAGS fi - -# Enable PGO flags. +# Enable PGO and LTO flags. # Extract the first word of "llvm-profdata", so it can be a program name with args. set dummy llvm-profdata; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -6371,7 +6371,6 @@ $as_echo "no" >&6; } fi - LLVM_PROF_ERR=no case $CC in *clang*) @@ -6380,6 +6379,7 @@ PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd" LLVM_PROF_MERGER="llvm-profdata merge -output=code.profclangd *.profclangr" LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\"" + LTOFLAGS="-flto" if test $LLVM_PROF_FOUND = not-found then LLVM_PROF_ERR=yes @@ -6392,6 +6392,7 @@ PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd" LLVM_PROF_MERGER="llvm-profdata merge -output=code.profclangd *.profclangr" LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\"" + LTOFLAGS="-flto" if test $LLVM_PROF_FOUND = not-found then LLVM_PROF_ERR=yes @@ -6402,6 +6403,7 @@ PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction" LLVM_PROF_MERGER="true" LLVM_PROF_FILE="" + LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none" ;; esac ;; diff -r acc453391c5b configure.ac --- a/configure.ac Sat Oct 24 17:39:36 2015 +0300 +++ b/configure.ac Fri Oct 30 09:38:20 2015 +0200 @@ -1352,14 +1352,14 @@ CFLAGS=$save_CFLAGS fi - -# Enable PGO flags. +# Enable PGO and LTO flags. AC_SUBST(PGO_PROF_GEN_FLAG) AC_SUBST(PGO_PROF_USE_FLAG) AC_SUBST(LLVM_PROF_MERGER) AC_SUBST(LLVM_PROF_FILE) AC_SUBST(LLVM_PROF_ERR) AC_SUBST(LLVM_PROF_FOUND) +AC_SUBST(LTOFLAGS) AC_CHECK_PROG(LLVM_PROF_FOUND, llvm-profdata, found, not-found) LLVM_PROF_ERR=no case $CC in @@ -1369,6 +1369,7 @@ PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd" LLVM_PROF_MERGER="llvm-profdata merge -output=code.profclangd *.profclangr" LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\"" + LTOFLAGS="-flto" if test $LLVM_PROF_FOUND = not-found then LLVM_PROF_ERR=yes @@ -1381,6 +1382,7 @@ PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd" LLVM_PROF_MERGER="llvm-profdata merge -output=code.profclangd *.profclangr" LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\"" + LTOFLAGS="-flto" if test $LLVM_PROF_FOUND = not-found then LLVM_PROF_ERR=yes @@ -1391,6 +1393,7 @@ PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction" LLVM_PROF_MERGER="true" LLVM_PROF_FILE="" + LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none" ;; esac ;;