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 A0A0C158099 for ; Thu, 23 Nov 2023 09:32:44 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 695C52BC03F; Thu, 23 Nov 2023 09:32: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) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C28172BC038 for ; Thu, 23 Nov 2023 09:32:21 +0000 (UTC) From: WANG Xuerui To: gentoo-dev@lists.gentoo.org Cc: WANG Xuerui , Thilo Fromm , Flatcar Linux Maintainers Subject: [gentoo-dev] [PATCH 1/2] go-env.eclass: unify GOARCH mapping logic with dev-lang/go Date: Thu, 23 Nov 2023 17:31:58 +0800 Message-ID: <20231123093159.1228864-2-xen0n@gentoo.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231123093159.1228864-1-xen0n@gentoo.org> References: <20231123093159.1228864-1-xen0n@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: 8622f447-83f9-44ac-b652-b4d3455ed04e X-Archives-Hash: 6d5afd81daa5a1d9935dc00e067bc5f1 Previously the eclass featured its own GOARCH mapping, that took care of less cases than the dev-lang/go ebuild did, and broke Go packages on arches like loong (GOARCH=loong64), mips (4 GOARCHes supported in total) or riscv (GOARCH=riscv64). This patch adds a copy of the go_arch() helper from dev-lang/go to the eclass and switches the go-env_set_compile_environment() function to use that, to fix the problem at hand. Fixes: 878d04daaf34765e6224e58139a9c45921d7a0c3 Closes: https://bugs.gentoo.org/917750 Signed-off-by: WANG Xuerui --- eclass/go-env.eclass | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass index ba4f6c3fbb59..08e3cf498a70 100644 --- a/eclass/go-env.eclass +++ b/eclass/go-env.eclass @@ -8,7 +8,7 @@ # Flatcar Linux Maintainers # @BLURB: Helper eclass for setting the Go compile environment. Required for cross-compiling. # @DESCRIPTION: -# This eclass includes a helper function for setting the compile environment for Go ebuilds. +# This eclass includes helper functions for setting the compile environment for Go ebuilds. # Intended to be called by other Go eclasses in an early build stage, e.g. src_unpack. if [[ -z ${_GO_ENV_ECLASS} ]]; then @@ -25,24 +25,36 @@ inherit toolchain-funcs # (e.g. "emerge-aarch64-cross-linux-gnu foo" run on x86_64 will emerge "foo" for x86_64 # instead of aarch64) go-env_set_compile_environment() { - local arch="$(tc-arch)" - case "${arch}" in - x86) GOARCH="386" ;; - x64-*) GOARCH="amd64" ;; - ppc64) if [[ "$(tc-endian)" == "big" ]] ; then - GOARCH="ppc64" - else - GOARCH="ppc64le" - fi ;; - *) GOARCH="${arch}" ;; - esac - tc-export CC CXX - export GOARCH + + export GOARCH="$(go-env_goarch)" export CGO_CFLAGS="${CGO_CFLAGS:-$CFLAGS}" export CGO_CPPFLAGS="${CGO_CPPFLAGS:-$CPPFLAGS}" export CGO_CXXFLAGS="${CGO_CXXFLAGS:-$CXXFLAGS}" export CGO_LDFLAGS="${CGO_LDFLAGS:-$LDFLAGS}" } +# @FUNCTION: go-env_goarch +# @USAGE: [toolchain prefix] +# @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}";; + esac +} + fi -- 2.42.1