public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: James Le Cuirot <chewi@gentoo.org>
To: gentoo-dev <gentoo-dev@lists.gentoo.org>
Cc: William Hubbs <williamh@gentoo.org>, James Le Cuirot <chewi@gentoo.org>
Subject: [gentoo-dev] [PATCH 6/8] go-env.eclass: Rewrite the go-env_goarch() logic
Date: Tue,  9 Jul 2024 22:07:38 +0100	[thread overview]
Message-ID: <20240709210749.14002-6-chewi@gentoo.org> (raw)
In-Reply-To: <20240709210749.14002-1-chewi@gentoo.org>

The previous logic was flawed, incomplete, and needlessly made use of
USE flags. We can rely on the tuple instead. Tested against all the
tuples we have in our profiles.

Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---
 eclass/go-env.eclass | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass
index c34c634bb6003..c839c41be0d7e 100644
--- a/eclass/go-env.eclass
+++ b/eclass/go-env.eclass
@@ -53,21 +53,23 @@ go-env_set_compile_environment() {
 # @DESCRIPTION:
 # Returns the appropriate GOARCH setting for the target architecture.
 go-env_goarch() {
-	# By chance most portage arch names match Go
-	local tc_arch=$(tc-arch $@)
-	case "${tc_arch}" in
-		x86)	echo 386;;
-		x64-*)	echo amd64;;
-		loong)	echo loong64;;
-		mips) if use abi_mips_o32; then
-				[[ $(tc-endian $@) = big ]] && echo mips || echo mipsle
-			elif use abi_mips_n64; then
-				[[ $(tc-endian $@) = big ]] && echo mips64 || echo mips64le
-			fi ;;
-		ppc64) [[ $(tc-endian $@) = big ]] && echo ppc64 || echo ppc64le ;;
-		riscv) echo riscv64 ;;
-		s390) echo s390x ;;
-		*)		echo "${tc_arch}";;
+	local target=${1:-${CHOST}}
+	# Some Portage arch names match Go.
+	local arch=$(tc-arch "${target}") cpu=${target%%-*}
+	case "${arch}" in
+		x86)	echo 386 ;;
+		loong)	echo loong64 ;;
+		*)		case "${cpu}" in
+					aarch64*be) echo arm64be ;;
+					arm64) echo arm64 ;;
+					arm*b*) echo armbe ;;
+					mips64*l*) echo mips64le ;;
+					mips*l*) echo mipsle ;;
+					powerpc64le*) echo ppc64le ;;
+					arm64|s390x) echo "${cpu}" ;;
+					mips64*|riscv64*|sparc64*) echo "${arch}64" ;;
+					*) echo "${arch}" ;;
+				esac ;;
 	esac
 }
 
-- 
2.45.2



  parent reply	other threads:[~2024-07-09 21:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 21:07 [gentoo-dev] [PATCH 1/8] golang-vcs.eclass: Drop support for EAPI 6 James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 2/8] golang-vcs-snapshot.eclass: " James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 3/8] golang-build.eclass: " James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 4/8] golang-base.eclass: Drop support for EAPI 5 and 6 James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 5/8] go-env.eclass: Establish EAPI 7 and 8 as supported James Le Cuirot
2024-07-09 21:07 ` James Le Cuirot [this message]
2024-07-09 21:07 ` [gentoo-dev] [PATCH 7/8] go-env.eclass: Add the go-env_goos() helper function James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 8/8] dev-lang/go: Use go-env.eclass in 1.22.5 and 9999 James Le Cuirot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240709210749.14002-6-chewi@gentoo.org \
    --to=chewi@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=williamh@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox