commit:     29d2314810bd8e1de73df5c3ebe30c826281c253
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 11 14:18:03 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Oct 11 17:53:26 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=29d23148

dev-lang/python: build CBUILD Python for cross in older versions

See bug 864911 for details.

Bug: https://bugs.gentoo.org/847910
Closes: https://bugs.gentoo.org/864911
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/python/python-3.10.7.ebuild | 45 ++++++++++++++++++++++++++++++++++++
 dev-lang/python/python-3.8.14.ebuild | 45 ++++++++++++++++++++++++++++++++++++
 dev-lang/python/python-3.9.14.ebuild | 45 ++++++++++++++++++++++++++++++++++++
 3 files changed, 135 insertions(+)

diff --git a/dev-lang/python/python-3.10.7.ebuild 
b/dev-lang/python/python-3.10.7.ebuild
index 5670e81124d4..921468637a1a 100644
--- a/dev-lang/python/python-3.10.7.ebuild
+++ b/dev-lang/python/python-3.10.7.ebuild
@@ -237,6 +237,51 @@ src_configure() {
        local -x LDFLAGS_NODIST=${LDFLAGS}
        local -x CFLAGS= LDFLAGS=
 
+       if tc-is-cross-compiler ; then
+               # We need to build our own Python on CBUILD first, and feed it 
in.
+               # bug #847910 and bug #864911.
+               local myeconfargs_cbuild=(
+                       "${myeconfargs[@]}"
+
+                       # As minimal as possible for the mini CBUILD Python
+                       # we build just for cross.
+                       --without-lto
+                       --disable-optimizations
+               )
+
+               # Point the imminent CHOST build to the Python we just
+               # built for CBUILD.
+               export PATH="${WORKDIR}/${P}-${CBUILD}:${PATH}"
+
+               mkdir "${WORKDIR}"/${P}-${CBUILD} || die
+               pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
+               ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
+
+               # Avoid as many dependencies as possible for the cross build.
+               cat >> Makefile <<-EOF || die
+                       MODULE_NIS=disabled
+                       MODULE__DBM=disabled
+                       MODULE__GDBM=disabled
+                       MODULE__DBM=disabled
+                       MODULE__SQLITE3=disabled
+                       MODULE__HASHLIB=disabled
+                       MODULE__SSL=disabled
+                       MODULE__CURSES=disabled
+                       MODULE__CURSES_PANEL=disabled
+                       MODULE_READLINE=disabled
+                       MODULE__TKINTER=disabled
+                       MODULE_PYEXPAT=disabled
+                       MODULE_ZLIB=disabled
+               EOF
+
+               # Unfortunately, we do have to build this immediately, and
+               # not in src_compile, because CHOST configure for Python
+               # will check the existence of the Python it was pointed to
+               # immediately.
+               emake
+               popd &> /dev/null || die
+       fi
+
        econf "${myeconfargs[@]}"
 
        if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then

diff --git a/dev-lang/python/python-3.8.14.ebuild 
b/dev-lang/python/python-3.8.14.ebuild
index 034a3f2c94f2..a38985990051 100644
--- a/dev-lang/python/python-3.8.14.ebuild
+++ b/dev-lang/python/python-3.8.14.ebuild
@@ -190,6 +190,51 @@ src_configure() {
        local -x LDFLAGS_NODIST=${LDFLAGS}
        local -x CFLAGS= LDFLAGS=
 
+       if tc-is-cross-compiler ; then
+               # We need to build our own Python on CBUILD first, and feed it 
in.
+               # bug #847910 and bug #864911.
+               local myeconfargs_cbuild=(
+                       "${myeconfargs[@]}"
+
+                       # As minimal as possible for the mini CBUILD Python
+                       # we build just for cross.
+                       --without-lto
+                       --disable-optimizations
+               )
+
+               # Point the imminent CHOST build to the Python we just
+               # built for CBUILD.
+               export PATH="${WORKDIR}/${P}-${CBUILD}:${PATH}"
+
+               mkdir "${WORKDIR}"/${P}-${CBUILD} || die
+               pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
+               ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
+
+               # Avoid as many dependencies as possible for the cross build.
+               cat >> Makefile <<-EOF || die
+                       MODULE_NIS=disabled
+                       MODULE__DBM=disabled
+                       MODULE__GDBM=disabled
+                       MODULE__DBM=disabled
+                       MODULE__SQLITE3=disabled
+                       MODULE__HASHLIB=disabled
+                       MODULE__SSL=disabled
+                       MODULE__CURSES=disabled
+                       MODULE__CURSES_PANEL=disabled
+                       MODULE_READLINE=disabled
+                       MODULE__TKINTER=disabled
+                       MODULE_PYEXPAT=disabled
+                       MODULE_ZLIB=disabled
+               EOF
+
+               # Unfortunately, we do have to build this immediately, and
+               # not in src_compile, because CHOST configure for Python
+               # will check the existence of the Python it was pointed to
+               # immediately.
+               emake
+               popd &> /dev/null || die
+       fi
+
        econf "${myeconfargs[@]}"
 
        if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then

diff --git a/dev-lang/python/python-3.9.14.ebuild 
b/dev-lang/python/python-3.9.14.ebuild
index 34c4173385b1..0ceb169b200f 100644
--- a/dev-lang/python/python-3.9.14.ebuild
+++ b/dev-lang/python/python-3.9.14.ebuild
@@ -231,6 +231,51 @@ src_configure() {
        local -x LDFLAGS_NODIST=${LDFLAGS}
        local -x CFLAGS= LDFLAGS=
 
+       if tc-is-cross-compiler ; then
+               # We need to build our own Python on CBUILD first, and feed it 
in.
+               # bug #847910 and bug #864911.
+               local myeconfargs_cbuild=(
+                       "${myeconfargs[@]}"
+
+                       # As minimal as possible for the mini CBUILD Python
+                       # we build just for cross.
+                       --without-lto
+                       --disable-optimizations
+               )
+
+               # Point the imminent CHOST build to the Python we just
+               # built for CBUILD.
+               export PATH="${WORKDIR}/${P}-${CBUILD}:${PATH}"
+
+               mkdir "${WORKDIR}"/${P}-${CBUILD} || die
+               pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
+               ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
+
+               # Avoid as many dependencies as possible for the cross build.
+               cat >> Makefile <<-EOF || die
+                       MODULE_NIS=disabled
+                       MODULE__DBM=disabled
+                       MODULE__GDBM=disabled
+                       MODULE__DBM=disabled
+                       MODULE__SQLITE3=disabled
+                       MODULE__HASHLIB=disabled
+                       MODULE__SSL=disabled
+                       MODULE__CURSES=disabled
+                       MODULE__CURSES_PANEL=disabled
+                       MODULE_READLINE=disabled
+                       MODULE__TKINTER=disabled
+                       MODULE_PYEXPAT=disabled
+                       MODULE_ZLIB=disabled
+               EOF
+
+               # Unfortunately, we do have to build this immediately, and
+               # not in src_compile, because CHOST configure for Python
+               # will check the existence of the Python it was pointed to
+               # immediately.
+               emake
+               popd &> /dev/null || die
+       fi
+
        econf "${myeconfargs[@]}"
 
        if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then

Reply via email to