components/python/python27/patches/12-studio-profile.patch
author John Beck <John.Beck@Oracle.COM>
Tue, 29 Jul 2014 08:41:01 -0700
changeset 2028 6fa8f5812e20
parent 1954 32663e59626d
child 3555 76f4672c5e4b
permissions -rw-r--r--
19308541 update Python 2.7 line to version 2.7.8 19284990 python 2.7.7 segfaults while under memory stress

This changes Python's standard profile-guided build target to work with
Studio instead of gcc.  The unfortunate repetition of options seen below
is a workaround for build peculiarities and to meet Studio's requirement
that the profiling options be used at all steps of the build -- not just
compilation.  As it is Solaris-specific, it is not suitable for upstream.

--- Python-2.7.8/Makefile.pre.in.~2~	2014-07-17 20:46:10.626664937 -0700
+++ Python-2.7.8/Makefile.pre.in	2014-07-17 20:46:10.736821411 -0700
@@ -413,28 +413,37 @@
 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
 	@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"
+	$(MAKE) all CC="$(CC) -xprofile=collect:$(XPROFILE_DIR)" \
+	    CFLAGS="$(CFLAGS) -xprofile=collect:$(XPROFILE_DIR)" \
+	    LDFLAGS="$(LDFLAGS) -xprofile=collect:$(XPROFILE_DIR)" \
+	    BLDSHARED="$(BLDSHARED) -xprofile=collect:$(XPROFILE_DIR)"
 
 run_profile_task:
 	: # FIXME: can't run for a cross build
-	./$(BUILDPYTHON) $(PROFILE_TASK)
+	LD_LIBRARY_PATH=. ./$(BUILDPYTHON) $(PROFILE_TASK)
 
 build_all_use_profile:
-	$(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"
+	$(MAKE) all CC="$(CC) -xprofile=use:$(XPROFILE_DIR)" \
+	    CFLAGS="$(CFLAGS) -xprofile=use:$(XPROFILE_DIR)" \
+	    LDFLAGS="$(LDFLAGS) -xprofile=use:$(XPROFILE_DIR)" \
+	    BLDSHARED="$(BLDSHARED) -xprofile=use:$(XPROFILE_DIR)"
 
 coverage:
 	@echo "Building with support for coverage checking:"
 	$(MAKE) clean
-	$(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
+	$(MAKE) all CC="$(CC) -xprofile=tcov" \
+	    CFLAGS="$(CFLAGS) -xO1 -xprofile=tcov" \
+	    LDFLAGS="$(LDFLAGS) -xprofile=tcov" \
+	    BLDSHARED="$(BLDSHARED) -xprofile=tcov"
 
 
 # Build the interpreter
@@ -1298,7 +1307,7 @@
 	-rm -f Lib/lib2to3/*Grammar*.pickle
 
 profile-removal:
-	find . -name '*.gc??' -exec rm -f {} ';'
+	find . -name '.profile' -exec rm -rf {} ';'
 
 clobber: clean profile-removal
 	-rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \