summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2018-09-06 12:15:18 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-09-10 12:13:06 +0100
commitfd3a47eceba942c21fa6294e81cf5dd3336d44b6 (patch)
tree82d666c90070bafe81cad853b209dee150d91a65 /meta/recipes-devtools/python
parent7d04ae16f63d45467ee0154725d2ba6e8244f2d4 (diff)
downloadpoky-fd3a47eceba942c21fa6294e81cf5dd3336d44b6.tar.gz
python3: add toggle for profile-guided-optimisation
Add a PACKAGECONFIG for profile-guided-optimisation, and default to whether qemu-usermode is available. Move --enable-optimizations to the pgo optimisation as all this currently does is use the PGO rules, causing a performance hit if PGO isn't actually used. (From OE-Core rev: 231e13c76d3ca7beebfbc8d8a856f72fa3780601) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python')
-rw-r--r--meta/recipes-devtools/python/python3_3.5.5.bb54
1 files changed, 31 insertions, 23 deletions
diff --git a/meta/recipes-devtools/python/python3_3.5.5.bb b/meta/recipes-devtools/python/python3_3.5.5.bb
index 8e94e38a2d..aad2e3abe6 100644
--- a/meta/recipes-devtools/python/python3_3.5.5.bb
+++ b/meta/recipes-devtools/python/python3_3.5.5.bb
@@ -73,7 +73,8 @@ CACHED_CONFIGUREVARS = "ac_cv_have_chflags=no \
73TARGET_CC_ARCH += "-DNDEBUG -fno-inline" 73TARGET_CC_ARCH += "-DNDEBUG -fno-inline"
74SDK_CC_ARCH += "-DNDEBUG -fno-inline" 74SDK_CC_ARCH += "-DNDEBUG -fno-inline"
75EXTRA_OEMAKE += "CROSS_COMPILE=yes" 75EXTRA_OEMAKE += "CROSS_COMPILE=yes"
76EXTRA_OECONF += "CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ --without-ensurepip --enable-optimizations" 76EXTRA_OECONF += "CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ --without-ensurepip"
77
77PYTHON3_PROFILE_TASK ?= "${S}/Tools/pybench/pybench.py -n 1" 78PYTHON3_PROFILE_TASK ?= "${S}/Tools/pybench/pybench.py -n 1"
78 79
79export CROSS_COMPILE = "${TARGET_PREFIX}" 80export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -87,8 +88,10 @@ export CROSSPYTHONPATH = "${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dy
87# No ctypes option for python 3 88# No ctypes option for python 3
88PYTHONLSBOPTS = "" 89PYTHONLSBOPTS = ""
89 90
90PACKAGECONFIG ??= "readline" 91PACKAGECONFIG ??= "readline ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'pgo', '', d)}"
91PACKAGECONFIG[readline] = ",,readline" 92PACKAGECONFIG[readline] = ",,readline"
93# Use profile guided optimisation by running PyBench inside qemu-user
94PACKAGECONFIG[pgo] = "--enable-optimizations"
92 95
93do_configure_append() { 96do_configure_append() {
94 rm -f ${S}/Makefile.orig 97 rm -f ${S}/Makefile.orig
@@ -108,16 +111,16 @@ run_make() {
108} 111}
109 112
110do_compile() { 113do_compile() {
111 # regenerate platform specific files, because they depend on system headers 114 # regenerate platform specific files, because they depend on system headers
112 cd ${S}/Lib/plat-linux* 115 cd ${S}/Lib/plat-linux*
113 include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ 116 include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
114 ${S}/Tools/scripts/h2py.py -i '(u_long)' \ 117 ${S}/Tools/scripts/h2py.py -i '(u_long)' \
115 ${STAGING_INCDIR}/dlfcn.h \ 118 ${STAGING_INCDIR}/dlfcn.h \
116 ${STAGING_INCDIR}/linux/cdrom.h \ 119 ${STAGING_INCDIR}/linux/cdrom.h \
117 ${STAGING_INCDIR}/netinet/in.h \ 120 ${STAGING_INCDIR}/netinet/in.h \
118 ${STAGING_INCDIR}/sys/types.h 121 ${STAGING_INCDIR}/sys/types.h
119 sed -e 's,${STAGING_DIR_HOST},,g' -i *.py 122 sed -e 's,${STAGING_DIR_HOST},,g' -i *.py
120 cd - 123 cd -
121 124
122 # remove any bogus LD_LIBRARY_PATH 125 # remove any bogus LD_LIBRARY_PATH
123 sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile 126 sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile
@@ -137,20 +140,21 @@ do_compile() {
137 # then call do_install twice we get Makefile.orig == Makefile.sysroot 140 # then call do_install twice we get Makefile.orig == Makefile.sysroot
138 install -m 0644 Makefile Makefile.sysroot 141 install -m 0644 Makefile Makefile.sysroot
139 142
140 run_make profile-opt 143 if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then
141 144 run_make profile-opt
142 if ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'true', 'false', d)}; then 145 qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}"
143 qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}" 146 cat > pgo-image-qemuwrapper << EOF
144 cat > pgo-image-qemuwrapper << EOF
145#!/bin/sh 147#!/bin/sh
146set -x 148set -x
147$qemu_binary "\$@" 149$qemu_binary "\$@"
148EOF 150EOF
149 chmod +x pgo-image-qemuwrapper 151 chmod +x pgo-image-qemuwrapper
150 ./pgo-image-qemuwrapper ${B}/python ${PYTHON3_PROFILE_TASK} || true 152 ./pgo-image-qemuwrapper ${B}/python ${PYTHON3_PROFILE_TASK} || true
153 run_make clean_and_use_profile
154 else
155 run_make libpython3.so
156 run_make
151 fi 157 fi
152
153 run_make clean_and_use_profile
154} 158}
155 159
156do_install() { 160do_install() {
@@ -163,8 +167,12 @@ do_install() {
163 167
164 # rerun the build once again with original makefile this time 168 # rerun the build once again with original makefile this time
165 # run install in a separate step to avoid compile/install race 169 # run install in a separate step to avoid compile/install race
166 run_make DESTDIR=${D} LIBDIR=${libdir} build_all_use_profile 170 if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then
167 171 run_make DESTDIR=${D} LIBDIR=${libdir} build_all_use_profile
172 else
173 run_make DESTDIR=${D} LIBDIR=${libdir}
174 fi
175
168 run_make DESTDIR=${D} LIBDIR=${libdir} install 176 run_make DESTDIR=${D} LIBDIR=${libdir} install
169 177
170 # avoid conflict with 2to3 from Python 2 178 # avoid conflict with 2to3 from Python 2