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 C0521158099 for ; Thu, 23 Nov 2023 09:33:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CE00D2BC051; Thu, 23 Nov 2023 09:32:24 +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 951E82BC04C for ; Thu, 23 Nov 2023 09:32:24 +0000 (UTC) From: WANG Xuerui To: gentoo-dev@lists.gentoo.org Cc: WANG Xuerui , Thilo Fromm , Flatcar Linux Maintainers Subject: [gentoo-dev] [PATCH 2/2] go-env.eclass: also set GOARM & GO386 when applicable Date: Thu, 23 Nov 2023 17:31:59 +0800 Message-ID: <20231123093159.1228864-3-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: 3028044f-3dcb-47a0-8c37-0462c785feec X-Archives-Hash: 145e18f340a3fa763a1ef5e7c07ebbc9 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 --- 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 -- 2.42.1