From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1409495-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 3EFC9158091
	for <garchives@archives.gentoo.org>; Fri, 17 Jun 2022 21:04:13 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 621F8E09CD;
	Fri, 17 Jun 2022 21:04:12 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 45359E09CD
	for <gentoo-commits@lists.gentoo.org>; Fri, 17 Jun 2022 21:04:12 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 20332341A2A
	for <gentoo-commits@lists.gentoo.org>; Fri, 17 Jun 2022 21:04:11 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 7DF82475
	for <gentoo-commits@lists.gentoo.org>; Fri, 17 Jun 2022 21:04:09 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1655499805.72fc7c1bbcf983d4778811e5d68bfc8a85873a74.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/python/
X-VCS-Repository: repo/gentoo
X-VCS-Files: dev-lang/python/python-3.11.0_beta3.ebuild
X-VCS-Directories: dev-lang/python/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 72fc7c1bbcf983d4778811e5d68bfc8a85873a74
X-VCS-Branch: master
Date: Fri, 17 Jun 2022 21:04:09 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 7a939db2-339e-42ea-867d-db815715523f
X-Archives-Hash: dc44fe454289b57b765084b7b512992c

commit:     72fc7c1bbcf983d4778811e5d68bfc8a85873a74
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  7 09:29:59 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun 17 21:03:25 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=72fc7c1b

dev-lang/python: use --with-build-python for cross builds for 3.11

Tested with sparc64-unknown-linux-gnu.

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

 dev-lang/python/python-3.11.0_beta3.ebuild | 51 +++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/dev-lang/python/python-3.11.0_beta3.ebuild b/dev-lang/python/python-3.11.0_beta3.ebuild
index 155e017bf32a..628ac16dde42 100644
--- a/dev-lang/python/python-3.11.0_beta3.ebuild
+++ b/dev-lang/python/python-3.11.0_beta3.ebuild
@@ -144,7 +144,8 @@ src_configure() {
 	fi
 
 	# Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
-	tc-export CXX
+	# PKG_CONFIG needed for cross.
+	tc-export CXX PKG_CONFIG
 
 	# Fix implicit declarations on cross and prefix builds. Bug #674070.
 	use ncurses && append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw
@@ -203,6 +204,54 @@ 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
+		local myeconfargs_cbuild=(
+			"${myeconfargs[@]}"
+
+			# As minimal as possible for the mini CBUILD Python
+			# we build just for cross, to satisfy --with-build-python.
+			--without-lto
+			--without-readline
+			--disable-optimizations
+		)
+
+		myeconfargs+=(
+			# Point the imminent CHOST build to the Python we just
+			# built for CBUILD.
+			--with-build-python="${WORKDIR}"/${P}-${CBUILD}/python
+		)
+
+		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 --with-build-python value
+		# immediately.
+		emake
+		popd &> /dev/null || die
+	fi
+
 	econf "${myeconfargs[@]}"
 
 	if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then