# Author: Alecsandru Patrascu diff -r 8d2889a935b2 Makefile.pre.in --- a/Makefile.pre.in Thu Oct 29 08:19:59 2015 +0200 +++ b/Makefile.pre.in Fri Oct 30 09:42:55 2015 +0200 @@ -30,7 +30,6 @@ abs_srcdir= @abs_srcdir@ abs_builddir= @abs_builddir@ - CC= @CC@ CXX= @CXX@ MAINCC= @MAINCC@ @@ -48,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@ @@ -502,7 +502,7 @@ $(MAKE) profile-removal 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: : # FIXME: can't run for a cross build @@ -512,7 +512,7 @@ $(LLVM_PROF_MERGER) 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 .PHONY=coverage coverage-lcov coverage-report diff -r 8d2889a935b2 configure --- a/configure Thu Oct 29 08:19:59 2015 +0200 +++ b/configure Fri Oct 30 09:42:55 2015 +0200 @@ -667,6 +667,7 @@ CFLAGS_NODIST BASECFLAGS OPT +LTOFLAGS LLVM_PROF_FOUND LLVM_PROF_ERR LLVM_PROF_FILE @@ -6437,7 +6438,7 @@ 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 @@ -6475,7 +6476,6 @@ $as_echo "no" >&6; } fi - LLVM_PROF_ERR=no case $CC in *clang*) @@ -6484,6 +6484,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 @@ -6496,6 +6497,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 @@ -6506,6 +6508,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 8d2889a935b2 configure.ac --- a/configure.ac Thu Oct 29 08:19:59 2015 +0200 +++ b/configure.ac Fri Oct 30 09:42:55 2015 +0200 @@ -1218,13 +1218,14 @@ fi], [AC_MSG_RESULT(no)]) -# 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 @@ -1234,6 +1235,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 @@ -1246,6 +1248,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 @@ -1256,6 +1259,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 ;;