]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Adds a profile-opt target for easy compilation of a python binary using
authorGregory P. Smith <greg@mad-scientist.com>
Sun, 13 Apr 2008 00:03:25 +0000 (00:03 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Sun, 13 Apr 2008 00:03:25 +0000 (00:03 +0000)
gcc's profile guided optimization.

Makefile.pre.in

index bb703015b42d75798728269d159d226ff0e93372..02cc59cc5f9073fd7e20b065053f19399d3a904f 100644 (file)
@@ -176,6 +176,10 @@ UNICODE_OBJS=   @UNICODE_OBJS@
 PYTHON=                python$(EXE)
 BUILDPYTHON=   python$(BUILDEXE)
 
+# The task to run while instrument when building the profile-opt target
+PROFILE_TASK=  Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
+#PROFILE_TASK= Lib/test/regrtest.py
+
 # === Definitions added by makesetup ===
 
 
@@ -349,6 +353,27 @@ LIBRARY_OBJS=      \
 all:           build_all
 build_all:     $(BUILDPYTHON) oldsharedmods sharedmods
 
+# Compile a binary with gcc profile guided optimization.
+profile-opt:
+       @echo "Building with support for profile generation:"
+       $(MAKE) clean
+       $(MAKE) build_all_generate_profile
+       @echo "Running benchmark to generate profile data:"
+       $(MAKE) profile-removal
+       $(MAKE) run_profile_task
+       @echo "Rebuilding with profile guided optimizations:"
+       $(MAKE) clean
+       $(MAKE) build_all_use_profile
+
+build_all_generate_profile:
+       $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"
+
+run_profile_task:
+       ./$(BUILDPYTHON) $(PROFILE_TASK)
+
+build_all_use_profile:
+       $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"
+
 # Build the interpreter
 $(BUILDPYTHON):        Modules/python.o $(LIBRARY) $(LDLIBRARY)
                $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
@@ -1099,7 +1124,10 @@ clean: pycremoval
        find $(srcdir)/build -name 'fficonfig.h' -exec rm -f {} ';' || true
        find $(srcdir)/build -name 'fficonfig.py' -exec rm -f {} ';' || true
 
-clobber: clean
+profile-removal:
+       find . -name '*.gc??' -exec rm -f {} ';'
+
+clobber: clean profile-removal
        -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
                tags TAGS \
                config.cache config.log pyconfig.h Modules/config.c