diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2016-09-05 11:57:52 +0300 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2018-04-16 09:54:20 +0300 |
commit | 1a25eeca7f202ac043fcfb1572709cf2e1af1b77 (patch) | |
tree | e7cfdf56a9d9d248f01e1e37cd1d47c71b008028 | |
parent | 292b3533ea2dde92ba8a6c1ea0bf03bc774954d9 (diff) | |
download | openembedded-core-contrib-1a25eeca7f202ac043fcfb1572709cf2e1af1b77.tar.gz |
python3: support profile optimized build
This patch makes it possible to build python3 with profile directed
optimization. That is, feed python build process with profile data to
guide optimization. This is the third (and the last) step in profile
directed optimization for Python 3.x.
In order to do a profile-optimized build you need to specify
PYTHON3_PROFILE_OPT = "1" in your local.conf, and, have profile data available
in the location pointed to by PYTHON3_PROFILE_DIR. Profile data can be
obtainen e.g. by running bitbake python-pgo-image -c profile3.
[YOCTO #9338]
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | meta/recipes-devtools/python/python3_3.5.5.bb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3_3.5.5.bb b/meta/recipes-devtools/python/python3_3.5.5.bb index beb9651e58..97499ff1a7 100644 --- a/meta/recipes-devtools/python/python3_3.5.5.bb +++ b/meta/recipes-devtools/python/python3_3.5.5.bb @@ -79,6 +79,17 @@ PYTHONLSBOPTS = "" PACKAGECONFIG ??= "readline" PACKAGECONFIG[readline] = ",,readline" +# Automatic profile guided optimization +PYTHON3_MAKE_TARGET ?= "${@'build_all_use_profile' if d.getVar('PYTHON3_PROFILE_OPT', True) == '1' else ''}" +PYTHON3_PROFILE_DIR ?= "${@'${TMPDIR}/work-shared/${MACHINE}/python3/pgo-data' if d.getVar('PYTHON3_PROFILE_OPT', True) == '1' else ''}" +python () { + if (d.getVar('PYTHON3_PROFILE_OPT', True) == '1' and + d.getVar('PYTHON3_MAKE_TARGET', True) == 'build_all_use_profile'): + profile_dir = d.getVar('PYTHON3_PROFILE_DIR', True) + bb.utils.mkdirhier(profile_dir) + d.setVarFlag('do_compile', 'file-checksums', '%s:True' % profile_dir) +} + do_configure_append() { rm -f ${S}/Makefile.orig autoreconf -Wcross --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi @@ -118,6 +129,10 @@ do_compile() { if [ "${PYTHON3_MAKE_TARGET}" = "build_all_generate_profile" ]; then # This is only used in PGO profiling by python3-profile-opt package export EXTRA_CFLAGS="-fprofile-dir=./python3-pgo-profiles/" + elif [ -n "${PYTHON3_PROFILE_DIR}" ]; then + export EXTRA_CFLAGS="-fprofile-dir=${PYTHON3_PROFILE_DIR}" + # Remove non-optimized build artefacts + oe_runmake clean fi oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \ @@ -138,6 +153,11 @@ do_install() { install -d ${D}${libdir}/pkgconfig install -d ${D}${libdir}/python${PYTHON_MAJMIN}/config + # This only has effect if we build with -fprofile-use, e.g. when make + # target is build_all_use_profile + if [ -n "${PYTHON3_PROFILE_DIR}" ]; then + export EXTRA_CFLAGS="-fprofile-dir=${PYTHON3_PROFILE_DIR}" + fi # rerun the build once again with original makefile this time # run install in a separate step to avoid compile/install race oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \ |