Skip to content

Commit c6bbcd2

Browse files
naschemeDinoV
authored andcommitted
bpo-37725: have "make clean" remove PGO task data (#15033)
Change "clean" makefile target to also clean the program guided optimization (PGO) data. Previously you would have to use "make clean" and "make profile-removal", or "make clobber".
1 parent 1ad0c77 commit c6bbcd2

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Makefile.pre.in

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ check-clean-src:
461461

462462
# Profile generation build must start from a clean tree.
463463
profile-clean-stamp:
464-
$(MAKE) clean profile-removal
464+
$(MAKE) clean
465465
touch $@
466466

467467
# Compile with profile generation enabled.
@@ -485,7 +485,7 @@ profile-run-stamp:
485485
$(MAKE) run_profile_task
486486
$(MAKE) build_all_merge_profile
487487
# Remove profile generation binary since we are done with it.
488-
$(MAKE) clean
488+
$(MAKE) clean-retain-profile
489489
# This is an expensive target to build and it does not have proper
490490
# makefile dependency information. So, we create a "stamp" file
491491
# to record its completion and avoid re-running it.
@@ -512,7 +512,7 @@ profile-opt: profile-run-stamp
512512
.PHONY=coverage coverage-lcov coverage-report
513513
coverage:
514514
@echo "Building with support for coverage checking:"
515-
$(MAKE) clean profile-removal
515+
$(MAKE) clean
516516
$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
517517

518518
coverage-lcov:
@@ -1752,7 +1752,9 @@ docclean:
17521752
-rm -rf Doc/build
17531753
-rm -rf Doc/tools/sphinx Doc/tools/pygments Doc/tools/docutils
17541754

1755-
clean: pycremoval
1755+
# like the 'clean' target but retain the profile guided optimization (PGO)
1756+
# data. The PGO data is only valid if source code remains unchanged.
1757+
clean-retain-profile: pycremoval
17561758
find . -name '*.[oa]' -exec rm -f {} ';'
17571759
find . -name '*.s[ol]' -exec rm -f {} ';'
17581760
find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
@@ -1774,14 +1776,19 @@ profile-removal:
17741776
rm -rf $(COVERAGE_REPORT)
17751777
rm -f profile-run-stamp
17761778

1777-
clobber: clean profile-removal
1779+
clean: clean-retain-profile
1780+
@if test @DEF_MAKE_ALL_RULE@ = profile-opt; then \
1781+
rm -f profile-gen-stamp profile-clean-stamp; \
1782+
$(MAKE) profile-removal; \
1783+
fi
1784+
1785+
clobber: clean
17781786
-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
17791787
tags TAGS \
17801788
config.cache config.log pyconfig.h Modules/config.c
17811789
-rm -rf build platform
17821790
-rm -rf $(PYTHONFRAMEWORKDIR)
17831791
-rm -f python-config.py python-config
1784-
-rm -f profile-gen-stamp profile-clean-stamp
17851792

17861793
# Make things extra clean, before making a distribution:
17871794
# remove all generated files, even Makefile[.pre]
@@ -1855,6 +1862,8 @@ Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
18551862
.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
18561863
.PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
18571864
.PHONY: smelly funny patchcheck touch altmaninstall commoninstall
1865+
.PHONY: clean-retain-profile profile-removal run_profile_task
1866+
.PHONY: build_all_generate_profile build_all_merge_profile
18581867
.PHONY: gdbhooks
18591868

18601869
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Change "clean" makefile target to also clean the program guided optimization
2+
(PGO) data. Previously you would have to use "make clean" and "make
3+
profile-removal", or "make clobber".

0 commit comments

Comments
 (0)