From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1573158-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))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 783041580D3
	for <garchives@archives.gentoo.org>; Fri, 24 Nov 2023 16:26:23 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id B6D1A2BC0C2;
	Fri, 24 Nov 2023 16:26:22 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id A2BEF2BC0C2
	for <gentoo-commits@lists.gentoo.org>; Fri, 24 Nov 2023 16:26:22 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id EE5C033BEEE
	for <gentoo-commits@lists.gentoo.org>; Fri, 24 Nov 2023 16:26:21 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 838B513BB
	for <gentoo-commits@lists.gentoo.org>; Fri, 24 Nov 2023 16:26:20 +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: <1700843175.64224abbe06824d47c554dced4149b51f3cebe91.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
X-VCS-Repository: repo/gentoo
X-VCS-Files: eclass/go-env.eclass
X-VCS-Directories: eclass/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 64224abbe06824d47c554dced4149b51f3cebe91
X-VCS-Branch: master
Date: Fri, 24 Nov 2023 16:26:20 +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: 87d5b5de-7d25-4863-a31b-d8619898b9e7
X-Archives-Hash: e5903a841248044b4ef422c2c59c8e58

commit:     64224abbe06824d47c554dced4149b51f3cebe91
Author:     WANG Xuerui <xen0n <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 23 08:28:54 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Nov 24 16:26:15 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=64224abb

go-env.eclass: also set GOARM & GO386 when applicable

This is necessary for the build artifact to conform to the configured
ISA level and features on those arches. The logic is also taken from
the dev-lang/go ebuild.

Signed-off-by: WANG Xuerui <xen0n <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/33941
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/go-env.eclass | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass
index 08e3cf498a70..4bc8c4b15c65 100644
--- a/eclass/go-env.eclass
+++ b/eclass/go-env.eclass
@@ -19,6 +19,8 @@ inherit toolchain-funcs
 # @FUNCTION: go-env_set_compile_environment
 # @DESCRIPTION:
 # Set up basic compile environment: CC, CXX, and GOARCH.
+# Necessary platform-specific settings such as GOARM or GO386 are also set
+# according to the Portage configuration when building for those architectures.
 # Also carry over CFLAGS, LDFLAGS and friends.
 # Required for cross-compiling with crossdev.
 # If not set, host defaults will be used and the resulting binaries are host arch.
@@ -28,6 +30,9 @@ go-env_set_compile_environment() {
 	tc-export CC CXX
 
 	export GOARCH="$(go-env_goarch)"
+	use arm && export GOARM=$(go-env_goarm)
+	use x86 && export GO386=$(usex cpu_flags_x86_sse2 '' 'softfloat')
+
 	export CGO_CFLAGS="${CGO_CFLAGS:-$CFLAGS}"
 	export CGO_CPPFLAGS="${CGO_CPPFLAGS:-$CPPFLAGS}"
 	export CGO_CXXFLAGS="${CGO_CXXFLAGS:-$CXXFLAGS}"
@@ -57,4 +62,20 @@ go-env_goarch() {
 	esac
 }
 
+# @FUNCTION: go-env_goarm
+# @USAGE: [CHOST-value]
+# @DESCRIPTION:
+# Returns the appropriate GOARM setting for the CHOST given, or the default
+# CHOST.
+go-env_goarm() {
+	case "${1:-${CHOST}}" in
+		armv5*)	echo 5;;
+		armv6*)	echo 6;;
+		armv7*)	echo 7;;
+		*)
+			die "unknown GOARM for ${1:-${CHOST}}"
+			;;
+	esac
+}
+
 fi