commit:     2c862d1f086bb8a9ce70631dfce1f2d7b5676b4c
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 17 10:05:45 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 17 10:46:27 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2c862d1f

dev-lang/python: add PGO

Closes: https://bugs.gentoo.org/615412
Closes: https://github.com/gentoo/gentoo/pull/20077
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/python/metadata.xml                |  1 +
 dev-lang/python/python-3.11.0_alpha2.ebuild | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dev-lang/python/metadata.xml b/dev-lang/python/metadata.xml
index 3427feb17c7d..996b563e4b05 100644
--- a/dev-lang/python/metadata.xml
+++ b/dev-lang/python/metadata.xml
@@ -7,6 +7,7 @@
 </maintainer>
 <use>
        <flag name="bluetooth">Build Bluetooth protocol support in socket 
module</flag>
+       <flag name="pgo">Optimize the build using Profile Guided Optimization 
(PGO)</flag>
        <flag name="wininst">Install Windows executables required to create an 
executable installer for MS Windows.</flag>
 </use>
 </pkgmetadata>

diff --git a/dev-lang/python/python-3.11.0_alpha2.ebuild 
b/dev-lang/python/python-3.11.0_alpha2.ebuild
index e97de8d4ccec..30e34160ff57 100644
--- a/dev-lang/python/python-3.11.0_alpha2.ebuild
+++ b/dev-lang/python/python-3.11.0_alpha2.ebuild
@@ -25,7 +25,7 @@ S="${WORKDIR}/${MY_P}"
 LICENSE="PSF-2"
 SLOT="${PYVER}"
 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv 
~s390 ~sparc ~x86"
-IUSE="bluetooth build examples gdbm hardened +ncurses +readline +sqlite +ssl 
test tk wininst +xml"
+IUSE="bluetooth build examples gdbm hardened +ncurses pgo +readline +sqlite 
+ssl test tk wininst +xml"
 RESTRICT="!test? ( test )"
 
 # Do not add a dependency on dev-lang/python to this ebuild.
@@ -161,6 +161,11 @@ src_configure() {
                dbmliborder+="${dbmliborder:+:}gdbm"
        fi
 
+       if use pgo; then
+               local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
+               export PROFILE_TASK="-m test -j${jobs} --pgo-extended -x 
test_gdb"
+       fi
+
        local myeconfargs=(
                # glibc-2.30 removes it; since we can't cleanly force-rebuild
                # Python on glibc upgrade, remove it proactively to give
@@ -179,6 +184,8 @@ src_configure() {
                --without-ensurepip
                --with-system-expat
                --with-system-ffi
+
+               $(use_enable pgo optimizations)
        )
 
        OPT="" econf "${myeconfargs[@]}"
@@ -198,6 +205,14 @@ src_compile() {
        # https://bugs.gentoo.org/823728
        export SETUPTOOLS_USE_DISTUTILS=stdlib
 
+       if use pgo ; then
+               # bug 660358
+               local -x COLUMNS=80
+               local -x PYTHONDONTWRITEBYTECODE=
+
+               addpredict /usr/lib/python3.11/site-packages
+       fi
+
        emake CPPFLAGS= CFLAGS= LDFLAGS=
 
        # Work around bug 329499. See also bug 413751 and 457194.

Reply via email to