commit:     c5f07606968a6363fbc77a2efd25ab90c05f3ab8
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 25 14:58:21 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Dec 26 16:10:20 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c5f07606

dev-lang/python: Detect LTO from CFLAGS

Replace the explicit USE=lto flag with automatic detection from CFLAGS
via tc-is-lto function.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-lang/python/python-3.10.13.ebuild       | 17 ++++++++++-------
 dev-lang/python/python-3.11.7.ebuild        | 18 ++++++++++--------
 dev-lang/python/python-3.12.1_p1.ebuild     | 19 +++++++++++--------
 dev-lang/python/python-3.13.0_alpha2.ebuild | 19 +++++++++++--------
 dev-lang/python/python-3.8.18.ebuild        | 16 ++++++++++------
 dev-lang/python/python-3.9.18.ebuild        | 17 ++++++++++-------
 6 files changed, 62 insertions(+), 44 deletions(-)

diff --git a/dev-lang/python/python-3.10.13.ebuild 
b/dev-lang/python/python-3.10.13.ebuild
index a147169c4d1f..be5cdcb2af4f 100644
--- a/dev-lang/python/python-3.10.13.ebuild
+++ b/dev-lang/python/python-3.10.13.ebuild
@@ -30,7 +30,7 @@ LICENSE="PSF-2"
 SLOT="${PYVER}"
 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 
~riscv ~s390 sparc x86"
 IUSE="
-       bluetooth build debug +ensurepip examples gdbm libedit lto
+       bluetooth build debug +ensurepip examples gdbm libedit
        +ncurses pgo +readline +sqlite +ssl test tk valgrind +xml
 "
 RESTRICT="!test? ( test )"
@@ -223,11 +223,6 @@ src_configure() {
        append-flags -fwrapv
        filter-flags -malign-double
 
-       # https://bugs.gentoo.org/700012
-       if is-flagq -flto || is-flagq '-flto=*'; then
-               append-cflags $(test-flags-CC -ffat-lto-objects)
-       fi
-
        # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
        # PKG_CONFIG needed for cross.
        tc-export CXX PKG_CONFIG
@@ -291,12 +286,12 @@ src_configure() {
                --with-libc=
                --enable-loadable-sqlite-extensions
                --without-ensurepip
+               --without-lto
                --with-system-expat
                --with-system-ffi
                --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip
 
                $(use_with debug assertions)
-               $(use_with lto)
                $(use_enable pgo optimizations)
                $(use_with readline readline "$(usex libedit editline 
readline)")
                $(use_with valgrind)
@@ -305,6 +300,14 @@ src_configure() {
        # disable implicit optimization/debugging flags
        local -x OPT=
 
+       # https://bugs.gentoo.org/700012
+       if tc-is-lto; then
+               append-cflags $(test-flags-CC -ffat-lto-objects)
+               myeconfargs+=(
+                       --with-lto
+               )
+       fi
+
        if tc-is-cross-compiler ; then
                build_cbuild_python
                # Point the imminent CHOST build to the Python we just

diff --git a/dev-lang/python/python-3.11.7.ebuild 
b/dev-lang/python/python-3.11.7.ebuild
index 7b984e8e2242..5bfd3472f572 100644
--- a/dev-lang/python/python-3.11.7.ebuild
+++ b/dev-lang/python/python-3.11.7.ebuild
@@ -30,7 +30,7 @@ LICENSE="PSF-2"
 SLOT="${PYVER}"
 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 
~riscv ~s390 sparc x86"
 IUSE="
-       bluetooth build debug +ensurepip examples gdbm libedit lto
+       bluetooth build debug +ensurepip examples gdbm libedit
        +ncurses pgo +readline +sqlite +ssl test tk valgrind
 "
 RESTRICT="!test? ( test )"
@@ -202,7 +202,6 @@ build_cbuild_python() {
 }
 
 src_configure() {
-       local disable
        # disable automagic bluetooth headers detection
        if ! use bluetooth; then
                local -x ac_cv_header_bluetooth_bluetooth_h=no
@@ -211,11 +210,6 @@ src_configure() {
        append-flags -fwrapv
        filter-flags -malign-double
 
-       # https://bugs.gentoo.org/700012
-       if is-flagq -flto || is-flagq '-flto=*'; then
-               append-cflags $(test-flags-CC -ffat-lto-objects)
-       fi
-
        # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
        # PKG_CONFIG needed for cross.
        tc-export CXX PKG_CONFIG
@@ -279,6 +273,7 @@ src_configure() {
                --with-libc=
                --enable-loadable-sqlite-extensions
                --without-ensurepip
+               --without-lto
                --with-system-expat
                --with-system-ffi
                --with-platlibdir=lib
@@ -286,7 +281,6 @@ src_configure() {
                --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip
 
                $(use_with debug assertions)
-               $(use_with lto)
                $(use_enable pgo optimizations)
                $(use_with readline readline "$(usex libedit editline 
readline)")
                $(use_with valgrind)
@@ -295,6 +289,14 @@ src_configure() {
        # disable implicit optimization/debugging flags
        local -x OPT=
 
+       # https://bugs.gentoo.org/700012
+       if tc-is-lto; then
+               append-cflags $(test-flags-CC -ffat-lto-objects)
+               myeconfargs+=(
+                       --with-lto
+               )
+       fi
+
        if tc-is-cross-compiler ; then
                build_cbuild_python
                myeconfargs+=(

diff --git a/dev-lang/python/python-3.12.1_p1.ebuild 
b/dev-lang/python/python-3.12.1_p1.ebuild
index df871bbf0ed2..56041a87d6cc 100644
--- a/dev-lang/python/python-3.12.1_p1.ebuild
+++ b/dev-lang/python/python-3.12.1_p1.ebuild
@@ -30,7 +30,7 @@ LICENSE="PSF-2"
 SLOT="${PYVER}"
 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 
~riscv ~s390 ~sparc ~x86"
 IUSE="
-       bluetooth build debug +ensurepip examples gdbm libedit lto
+       bluetooth build debug +ensurepip examples gdbm libedit
        +ncurses pgo +readline +sqlite +ssl test tk valgrind
 "
 RESTRICT="!test? ( test )"
@@ -202,7 +202,6 @@ build_cbuild_python() {
 }
 
 src_configure() {
-       local disable
        # disable automagic bluetooth headers detection
        if ! use bluetooth; then
                local -x ac_cv_header_bluetooth_bluetooth_h=no
@@ -211,11 +210,6 @@ src_configure() {
        append-flags -fwrapv
        filter-flags -malign-double
 
-       # https://bugs.gentoo.org/700012
-       if is-flagq -flto || is-flagq '-flto=*'; then
-               append-cflags $(test-flags-CC -ffat-lto-objects)
-       fi
-
        # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
        # PKG_CONFIG needed for cross.
        tc-export CXX PKG_CONFIG
@@ -279,17 +273,26 @@ src_configure() {
                --with-libc=
                --enable-loadable-sqlite-extensions
                --without-ensurepip
+               --without-lto
                --with-system-expat
                --with-platlibdir=lib
                --with-pkg-config=yes
                --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip
 
                $(use_with debug assertions)
-               $(use_with lto)
                $(use_enable pgo optimizations)
                $(use_with readline readline "$(usex libedit editline 
readline)")
                $(use_with valgrind)
        )
+
+       # https://bugs.gentoo.org/700012
+       if tc-is-lto; then
+               append-cflags $(test-flags-CC -ffat-lto-objects)
+               myeconfargs+=(
+                       --with-lto
+               )
+       fi
+
        # Force-disable modules we don't want built.
        # See Modules/Setup for docs on how this works. Setup.local contains 
our local deviations.
        cat > Modules/Setup.local <<-EOF || die

diff --git a/dev-lang/python/python-3.13.0_alpha2.ebuild 
b/dev-lang/python/python-3.13.0_alpha2.ebuild
index b2364be2514c..e38ba4022735 100644
--- a/dev-lang/python/python-3.13.0_alpha2.ebuild
+++ b/dev-lang/python/python-3.13.0_alpha2.ebuild
@@ -29,7 +29,7 @@ S="${WORKDIR}/${MY_P}"
 LICENSE="PSF-2"
 SLOT="${PYVER}"
 IUSE="
-       bluetooth build debug +ensurepip examples gdbm libedit lto
+       bluetooth build debug +ensurepip examples gdbm libedit
        +ncurses pgo +readline +sqlite +ssl test tk valgrind
 "
 RESTRICT="!test? ( test )"
@@ -201,7 +201,6 @@ build_cbuild_python() {
 }
 
 src_configure() {
-       local disable
        # disable automagic bluetooth headers detection
        if ! use bluetooth; then
                local -x ac_cv_header_bluetooth_bluetooth_h=no
@@ -210,11 +209,6 @@ src_configure() {
        append-flags -fwrapv
        filter-flags -malign-double
 
-       # https://bugs.gentoo.org/700012
-       if is-flagq -flto || is-flagq '-flto=*'; then
-               append-cflags $(test-flags-CC -ffat-lto-objects)
-       fi
-
        # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
        # PKG_CONFIG needed for cross.
        tc-export CXX PKG_CONFIG
@@ -278,17 +272,26 @@ src_configure() {
                --with-libc=
                --enable-loadable-sqlite-extensions
                --without-ensurepip
+               --without-lto
                --with-system-expat
                --with-platlibdir=lib
                --with-pkg-config=yes
                --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip
 
                $(use_with debug assertions)
-               $(use_with lto)
                $(use_enable pgo optimizations)
                $(use_with readline readline "$(usex libedit editline 
readline)")
                $(use_with valgrind)
        )
+
+       # https://bugs.gentoo.org/700012
+       if tc-is-lto; then
+               append-cflags $(test-flags-CC -ffat-lto-objects)
+               myeconfargs+=(
+                       --with-lto
+               )
+       fi
+
        # Force-disable modules we don't want built.
        # See Modules/Setup for docs on how this works. Setup.local contains 
our local deviations.
        cat > Modules/Setup.local <<-EOF || die

diff --git a/dev-lang/python/python-3.8.18.ebuild 
b/dev-lang/python/python-3.8.18.ebuild
index 1e4a02c073dd..80d2c90ecc14 100644
--- a/dev-lang/python/python-3.8.18.ebuild
+++ b/dev-lang/python/python-3.8.18.ebuild
@@ -30,7 +30,7 @@ LICENSE="PSF-2"
 SLOT="${PYVER}"
 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 
~riscv ~s390 sparc x86"
 IUSE="
-       bluetooth build debug +ensurepip examples gdbm lto +ncurses pgo
+       bluetooth build debug +ensurepip examples gdbm +ncurses pgo
        +readline +sqlite +ssl test tk valgrind wininst +xml
 "
 RESTRICT="!test? ( test )"
@@ -149,11 +149,6 @@ src_configure() {
 
        filter-flags -malign-double
 
-       # https://bugs.gentoo.org/700012
-       if is-flagq -flto || is-flagq '-flto=*'; then
-               append-cflags $(test-flags-CC -ffat-lto-objects)
-       fi
-
        # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
        # PKG_CONFIG needed for cross.
        tc-export CXX PKG_CONFIG
@@ -178,6 +173,7 @@ src_configure() {
                --with-libc=
                --enable-loadable-sqlite-extensions
                --without-ensurepip
+               --without-lto
                --with-system-expat
                --with-system-ffi
                --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip
@@ -189,6 +185,14 @@ src_configure() {
        # disable implicit optimization/debugging flags
        local -x OPT=
 
+       # https://bugs.gentoo.org/700012
+       if tc-is-lto; then
+               append-cflags $(test-flags-CC -ffat-lto-objects)
+               myeconfargs+=(
+                       --with-lto
+               )
+       fi
+
        if tc-is-cross-compiler ; then
                # Hack to workaround get_libdir not being able to handle 
CBUILD, bug #794181
                local cbuild_libdir=$(unset PKG_CONFIG_PATH ; 
$(tc-getBUILD_PKG_CONFIG) --keep-system-libs --libs-only-L libffi)

diff --git a/dev-lang/python/python-3.9.18.ebuild 
b/dev-lang/python/python-3.9.18.ebuild
index fcc54a9be7e6..9edf94c8ead2 100644
--- a/dev-lang/python/python-3.9.18.ebuild
+++ b/dev-lang/python/python-3.9.18.ebuild
@@ -30,7 +30,7 @@ LICENSE="PSF-2"
 SLOT="${PYVER}"
 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 
~riscv ~s390 sparc x86"
 IUSE="
-       bluetooth build debug +ensurepip examples gdbm lto +ncurses pgo
+       bluetooth build debug +ensurepip examples gdbm +ncurses pgo
        +readline +sqlite +ssl test tk valgrind +xml
 "
 RESTRICT="!test? ( test )"
@@ -156,11 +156,6 @@ src_configure() {
        append-flags -fwrapv
        filter-flags -malign-double
 
-       # https://bugs.gentoo.org/700012
-       if is-flagq -flto || is-flagq '-flto=*'; then
-               append-cflags $(test-flags-CC -ffat-lto-objects)
-       fi
-
        # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
        # PKG_CONFIG needed for cross.
        tc-export CXX PKG_CONFIG
@@ -218,12 +213,12 @@ src_configure() {
                --with-libc=
                --enable-loadable-sqlite-extensions
                --without-ensurepip
+               --without-lto
                --with-system-expat
                --with-system-ffi
                --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip
 
                $(use_with debug assertions)
-               $(use_with lto)
                $(use_enable pgo optimizations)
                $(use_with valgrind)
        )
@@ -231,6 +226,14 @@ src_configure() {
        # disable implicit optimization/debugging flags
        local -x OPT=
 
+       # https://bugs.gentoo.org/700012
+       if tc-is-lto; then
+               append-cflags $(test-flags-CC -ffat-lto-objects)
+               myeconfargs+=(
+                       --with-lto
+               )
+       fi
+
        if tc-is-cross-compiler ; then
                # Hack to workaround get_libdir not being able to handle 
CBUILD, bug #794181
                local cbuild_libdir=$(unset PKG_CONFIG_PATH ; 
$(tc-getBUILD_PKG_CONFIG) --keep-system-libs --libs-only-L libffi)

Reply via email to