components/python/python26/patches/Python26-25-studio-profile.patch
changeset 634 bd9c94f9f6e0
child 841 1a62cefa636d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/python/python26/patches/Python26-25-studio-profile.patch	Tue Dec 20 17:19:09 2011 -0800
@@ -0,0 +1,77 @@
+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.
+--- Python-2.6.4/Makefile.pre.in.old	Thu Nov  3 15:14:03 2011
++++ Python-2.6.4/Makefile.pre.in	Thu Nov  3 15:14:11 2011
+@@ -360,9 +360,9 @@
+ 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
+@@ -369,18 +369,27 @@
+ 	$(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:
+-	./$(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
+@@ -395,10 +404,7 @@
+ 
+ # Build the shared modules
+ sharedmods: $(BUILDPYTHON)
+-	@case $$MAKEFLAGS in \
+-	*s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
+-	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
+-	esac
++	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build
+ 
+ # Build static library
+ # avoid long command lines, same as LIBRARY_OBJS
+@@ -1168,12 +1174,13 @@
+ clean: pycremoval
+ 	find . -name '*.o' -exec rm -f {} ';'
+ 	find . -name '*.s[ol]' -exec rm -f {} ';'
++	find . -name '*.s[ol].*' -exec rm -f {} ';'
+ 	find $(srcdir)/build -name 'fficonfig.h' -exec rm -f {} ';' || true
+ 	find $(srcdir)/build -name 'fficonfig.py' -exec rm -f {} ';' || true
+ 	-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) \