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-3.5.2/Makefile.pre.in.~2~ 2016-07-08 06:44:25.728534993 -0700
+++ Python-3.5.2/Makefile.pre.in 2016-07-08 06:53:21.459625807 -0700
@@ -241,7 +241,7 @@
# The task to run while instrumented when building the profile-opt target.
# We exclude unittests with -x that take a rediculious amount of time to
# run in the instrumented training build or do not provide much value.
-PROFILE_TASK=-m test.regrtest --pgo -x test_asyncore test_gdb test_multiprocessing_fork test_multiprocessing_forkserver test_multiprocessing_main_handling test_multiprocessing_spawn test_subprocess
+PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
# report files for gcov / lcov coverage report
COVERAGE_INFO= $(abs_builddir)/coverage.info
@@ -512,24 +512,33 @@
$(MAKE) profile-removal
build_all_generate_profile:
- $(MAKE) all CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
+ $(MAKE) all CC="$(CC) -xprofile=collect:$(XPROFILE_DIR)" \
+ CFLAGS_NODIST="$(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
- $(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true
+ LD_LIBRARY_PATH=. $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK)
build_all_merge_profile:
$(LLVM_PROF_MERGER)
build_all_use_profile:
- $(MAKE) all CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@"
+ $(MAKE) all CC="$(CC) -xprofile=use:$(XPROFILE_DIR)" \
+ CFLAGS_NODIST="$(CFLAGS) -xprofile=use:$(XPROFILE_DIR)" \
+ LDFLAGS="$(LDFLAGS) -xprofile=use:$(XPROFILE_DIR)" \
+ BLDSHARED="$(BLDSHARED) -xprofile=use:$(XPROFILE_DIR)"
# Compile and run with gcov
.PHONY=coverage coverage-lcov coverage-report
coverage:
@echo "Building with support for coverage checking:"
$(MAKE) clean profile-removal
- $(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"
coverage-lcov:
@echo "Creating Coverage HTML report with LCOV:"
@@ -605,13 +614,9 @@
# -s, --silent or --quiet is always the first char.
# Under BSD make, MAKEFLAGS might be " -s -v x=y".
sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
- @case "$$MAKEFLAGS" in \
- *\ -s*|s*) quiet="-q";; \
- *) quiet="";; \
- esac; \
$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
- $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
+ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py build
# Build static library
# avoid long command lines, same as LIBRARY_OBJS
@@ -1669,9 +1674,7 @@
-rm -rf build
profile-removal:
- find . -name '*.gc??' -exec rm -f {} ';'
- find . -name '*.profclang?' -exec rm -f {} ';'
- find . -name '*.dyn' -exec rm -f {} ';'
+ find . -name '*profile' -exec rm -f {} ';'
rm -f $(COVERAGE_INFO)
rm -rf $(COVERAGE_REPORT)