diff -r f5c40ab9e233 Makefile.pre.in --- a/Makefile.pre.in Tue Aug 18 22:25:16 2015 -0700 +++ b/Makefile.pre.in Mon Aug 24 16:53:59 2015 +0300 @@ -226,8 +226,7 @@ TCLTK_LIBS= @TCLTK_LIBS@ # The task to run while instrument when building the profile-opt target -PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck -#PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py +PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py # report files for gcov / lcov coverage report COVERAGE_INFO= $(abs_builddir)/coverage.info @@ -481,23 +480,29 @@ profile-opt: @echo "Building with support for profile generation:" $(MAKE) clean + $(MAKE) profile-removal $(MAKE) build_all_generate_profile @echo "Running benchmark to generate profile data:" $(MAKE) profile-removal $(MAKE) run_profile_task + $(MAKE) build_all_aggregate_profile @echo "Rebuilding with profile guided optimizations:" $(MAKE) clean $(MAKE) build_all_use_profile + $(MAKE) profile-removal build_all_generate_profile: - $(MAKE) all CFLAGS_NODIST="$(CFLAGS) -fprofile-generate" LDFLAGS="-fprofile-generate" LIBS="$(LIBS) -lgcov" + $(MAKE) all CFLAGS_NODIST="$(CFLAGS) -fprofile-instr-generate" LDFLAGS="$(LDFLAGS) -fprofile-instr-generate" LIBS="$(LIBS)" run_profile_task: : # FIXME: can't run for a cross build - $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) + LLVM_PROFILE_FILE="code-%p.profclangr" $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true + +build_all_aggregate_profile: + llvm-profdata merge -output=code.profclangd *.profclangr build_all_use_profile: - $(MAKE) all CFLAGS_NODIST="$(CFLAGS) -fprofile-use -fprofile-correction" + $(MAKE) all CFLAGS_NODIST="$(CFLAGS) -fprofile-instr-use=code.profclangd" # Compile and run with gcov .PHONY=coverage coverage-lcov coverage-report @@ -1568,6 +1573,7 @@ -rm -f pybuilddir.txt -rm -f Lib/lib2to3/*Grammar*.pickle -rm -f Programs/_testembed Programs/_freeze_importlib + rm -rf build || true profile-removal: find . -name '*.gc??' -exec rm -f {} ';'