Skip to content

Instantly share code, notes, and snippets.

@stefantalpalaru
Created May 28, 2018 11:48
Show Gist options
  • Save stefantalpalaru/3035b87a48cc273585ee69f95e8343bf to your computer and use it in GitHub Desktop.
Save stefantalpalaru/3035b87a48cc273585ee69f95e8343bf to your computer and use it in GitHub Desktop.
python-2.7.15-PGO-ICE.patch
diff -ur cpython-2.7.15.orig/Makefile.pre.in cpython-2.7.15/Makefile.pre.in
--- cpython-2.7.15.orig/Makefile.pre.in 2018-04-30 00:47:33.000000000 +0200
+++ cpython-2.7.15/Makefile.pre.in 2018-05-28 13:43:45.872309762 +0200
@@ -210,8 +210,9 @@
# The task to run while instrument 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 test_subprocess
+# run in the instrumented training build or do not provide much value
+# or fail randomly when run in parallel (test_epoll, test_selectors).
+PROFILE_TASK=-m test.regrtest --pgo -w $(EXTRATESTOPTS) -x test_asyncore test_gdb test_multiprocessing test_subprocess test_epoll test_selectors
# report files for gcov / lcov coverage report
COVERAGE_INFO= $(abs_builddir)/coverage.info
@@ -430,14 +431,13 @@
@echo "Rebuilding with profile guided optimizations:"
$(MAKE) clean
$(MAKE) build_all_use_profile
- $(MAKE) profile-removal
build_all_generate_profile:
$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
run_profile_task:
: # FIXME: can't run for a cross build
- $(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true
+ $(LLVM_PROF_FILE) _PYTHONNOSITEPACKAGES=1 $(RUNSHARED) ./$(BUILDPYTHON) -E $(PROFILE_TASK)
build_all_merge_profile:
$(LLVM_PROF_MERGER)
diff -ur cpython-2.7.15.orig/setup.py cpython-2.7.15/setup.py
--- cpython-2.7.15.orig/setup.py 2018-04-30 00:47:33.000000000 +0200
+++ cpython-2.7.15/setup.py 2018-05-28 13:43:05.235674329 +0200
@@ -256,11 +256,13 @@
# those environment variables passed into the setup.py phase. Here's
# a small set of useful ones.
compiler = os.environ.get('CC')
+ # it's important to get CFLAGS from the environment for proper extension PGO support
+ cflags = os.environ.get('CFLAGS')
args = {}
# unfortunately, distutils doesn't let us provide separate C and C++
# compilers
if compiler is not None:
- (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
+ (ccshared,) = sysconfig.get_config_vars('CCSHARED')
args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
self.compiler.set_executables(**args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment