From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 EF1ED1581C1 for ; Tue, 9 Jul 2024 21:11:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AC2112BC0A7; Tue, 9 Jul 2024 21:10:25 +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)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 56BD52BC09F for ; Tue, 9 Jul 2024 21:10:25 +0000 (UTC) From: James Le Cuirot To: gentoo-dev Cc: William Hubbs , James Le Cuirot Subject: [gentoo-dev] [PATCH 6/8] go-env.eclass: Rewrite the go-env_goarch() logic Date: Tue, 9 Jul 2024 22:07:38 +0100 Message-ID: <20240709210749.14002-6-chewi@gentoo.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709210749.14002-1-chewi@gentoo.org> References: <20240709210749.14002-1-chewi@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: f43813cd-cd1b-4316-b1e0-df9317ae5d14 X-Archives-Hash: 38991f12f2c97c7973e7de61f2a210ec 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 --- 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