diff options
author | Sam James <sam@gentoo.org> | 2023-11-24 17:42:25 +0000 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2023-11-24 18:35:04 +0000 |
commit | 6f6e58bd266a7e82f2eff29703a5a819b20ce8f7 (patch) | |
tree | 7af9d22fb978d663abce5e39802be01e1cd743cc /eclass/go-env.eclass | |
parent | go-env.eclass: Reapply "also set GOARM & GO386 when applicable" (diff) | |
download | gentoo-6f6e58bd266a7e82f2eff29703a5a819b20ce8f7.tar.gz gentoo-6f6e58bd266a7e82f2eff29703a5a819b20ce8f7.tar.bz2 gentoo-6f6e58bd266a7e82f2eff29703a5a819b20ce8f7.zip |
go-env.eclass: fix GO386 handling
Go 1.16 dropped explicit support for 386 FP and relies on software
emulation instead in the absence of SSE2.
* First, check if cpu_flags_x86_sse2 is used in the ebuild. If it is and it's
enabled, then act in SSE2 mode.
* If not, fall back to checking whether the compiler has __SSE2__ defined via
e.g. -march in CFLAGS.
* Failing that, use softfloat mode.
Fixes the issue mentioned in 5718f8440197298e0aa1df2a88a66057d2cdaf83 (where
we tried to use a USE flag which isn't implicit).
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'eclass/go-env.eclass')
-rw-r--r-- | eclass/go-env.eclass | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass index 4bc8c4b15c65..1f950db06930 100644 --- a/eclass/go-env.eclass +++ b/eclass/go-env.eclass @@ -31,7 +31,7 @@ go-env_set_compile_environment() { export GOARCH="$(go-env_goarch)" use arm && export GOARM=$(go-env_goarm) - use x86 && export GO386=$(usex cpu_flags_x86_sse2 '' 'softfloat') + use x86 && export GO386=$(go-env_go386) export CGO_CFLAGS="${CGO_CFLAGS:-$CFLAGS}" export CGO_CPPFLAGS="${CGO_CPPFLAGS:-$CPPFLAGS}" @@ -62,6 +62,27 @@ go-env_goarch() { esac } +# @FUNCTION: go-env_go386 +# @DESCRIPTION: +# Returns the appropriate GO386 setting for the CFLAGS in use. +go-env_go386() { + # Piggy-back off any existing CPU_FLAGS_X86 usage in the ebuild if + # it's there. + if in_iuse cpu_flags_x86_sse2 && use cpu_flags_x86_sse2 ; then + echo 'sse2' + return + fi + + if tc-cpp-is-true "defined(__SSE2__)" ${CFLAGS} ${CXXFLAGS} ; then + echo 'sse2' + return + fi + + # Go 1.16 dropped explicit support for 386 FP and relies on software + # emulation instead in the absence of SSE2. + echo 'softfloat' +} + # @FUNCTION: go-env_goarm # @USAGE: [CHOST-value] # @DESCRIPTION: |