commit:     9d5cefbcb6fdcfe5deb2f679b27f8b510c18c7c9
Author:     Sv. Lockal <lockalsash <AT> gmail <DOT> com>
AuthorDate: Sun Jun  2 11:03:33 2024 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Mon Jun  3 13:27:02 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9d5cefbc

sci-libs/blis: don't autodetect CPU, build according to cpu_flags_*

This PR closes multiple issues:
* binary packaging had flaws, because even on x86-64 target machine won't 
always match host cpu
* crossdev compilation did not work, because correct compilers were not passed
* tests did not work, because LD_LIBRARY_PATH had hardcoded `haswell` target
* PYTHON_COMPAT: drop 3.9, add 3.12 and 3.13

This also adds few checks for aarch64 architecture, but aarch64 was not added
to KEYWORDS, as few tests failed (in 0.9, not in 1.0).

Note that while cpu_flags_*-based configuration resembles automatic one,
it is not fully the same. For example, there are 2 types of Skylake CPUs:
with 1 or 2 FMA units. Attempt to enable cpu_flags_x86_avx512vl on CPUs with
1 FMA unit will result in reduced performance. Previously this was handled by
automatic detection of 1FMA Skylake as Haswell; now user should not specify
cpu_flags_x86_avx512vl if CPU has degraded AVX-512 support.

Closes: https://bugs.gentoo.org/928018
Closes: https://bugs.gentoo.org/765805
Closes: https://bugs.gentoo.org/929769
Signed-off-by: Sv. Lockal <lockalsash <AT> gmail.com>
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 .../{blis-0.9.0.ebuild => blis-0.9.0-r1.ebuild}    | 59 +++++++++++++++-------
 1 file changed, 41 insertions(+), 18 deletions(-)

diff --git a/sci-libs/blis/blis-0.9.0.ebuild 
b/sci-libs/blis/blis-0.9.0-r1.ebuild
similarity index 64%
rename from sci-libs/blis/blis-0.9.0.ebuild
rename to sci-libs/blis/blis-0.9.0-r1.ebuild
index 171a0e9dacbe..1bf6e1ea736e 100644
--- a/sci-libs/blis/blis-0.9.0.ebuild
+++ b/sci-libs/blis/blis-0.9.0-r1.ebuild
@@ -1,10 +1,10 @@
-# Copyright 2019-2023 Gentoo Authors
+# Copyright 2019-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-PYTHON_COMPAT=( python3_{9..11} )
-inherit python-any-r1
+PYTHON_COMPAT=( python3_{10..13} )
+inherit python-any-r1 toolchain-funcs
 
 DESCRIPTION="BLAS-like Library Instantiation Software Framework"
 HOMEPAGE="https://github.com/flame/blis";
@@ -13,7 +13,12 @@ SRC_URI="https://github.com/flame/${PN}/archive/${PV}.tar.gz 
-> ${P}.tar.gz"
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64 ~ppc64 ~x86"
-IUSE="doc eselect-ldso openmp pthread serial static-libs 64bit-index"
+CPU_USE=(
+       cpu_flags_ppc_{vsx,vsx3}
+       cpu_flags_arm_{neon,v7,v8,sve}
+       cpu_flags_x86_{ssse3,avx,fma3,fma4,avx2,avx512vl}
+)
+IUSE="doc eselect-ldso openmp pthread serial static-libs 64bit-index 
${CPU_USE[@]}"
 REQUIRED_USE="
        ?? ( openmp pthread serial )
        ?? ( eselect-ldso 64bit-index )"
@@ -25,7 +30,10 @@ DEPEND="
        )"
 
 RDEPEND="${DEPEND}"
-BDEPEND="${PYTHON_DEPS}"
+BDEPEND="
+       ${PYTHON_DEPS}
+       dev-lang/perl
+"
 
 PATCHES=(
        "${FILESDIR}"/${PN}-0.6.0-blas-provider.patch
@@ -34,9 +42,31 @@ PATCHES=(
        "${FILESDIR}"/${PN}-0.9.0-rpath.patch
 )
 
+get_confname() {
+       local confname=generic
+       if use x86 || use amd64; then
+               use cpu_flags_x86_ssse3 && confname=penryn
+               use cpu_flags_x86_avx && use cpu_flags_x86_fma3 && 
confname=sandybridge
+               use cpu_flags_x86_avx && use cpu_flags_x86_fma4 && 
confname=bulldozer
+               use cpu_flags_x86_avx && use cpu_flags_x86_fma4 && use 
cpu_flags_x86_fma3 && confname=piledriver
+               use cpu_flags_x86_avx2 && confname=haswell
+               use cpu_flags_x86_avx512vl && confname=skx
+       elif use arm || use arm64; then
+               use arm && confname=arm32
+               use arm64 && confname=arm64
+               use cpu_flags_arm_neon && use cpu_flags_arm_v7 && 
confname=cortexa9
+               use cpu_flags_arm_v8 && confname=cortexa53
+               use cpu_flags_arm_sve && confname=armsve
+       elif use ppc || use ppc64; then
+               confname=power
+               use cpu_flags_ppc_vsx && confname=power7
+               use cpu_flags_ppc_vsx3 && confname=power9
+       fi
+       echo ${confname}
+}
+
 src_configure() {
        local BLIS_FLAGS=()
-       local confname
        # determine flags
        if use openmp; then
                BLIS_FLAGS+=( -t openmp )
@@ -46,17 +76,9 @@ src_configure() {
                BLIS_FLAGS+=( -t no )
        fi
        use 64bit-index && BLIS_FLAGS+=( -b 64 -i 64 )
-       # determine config name
-       case "${ARCH}" in
-               "x86" | "amd64")
-                       confname=auto ;;
-               "ppc64")
-                       confname=generic ;;
-               *)
-                       confname=generic ;;
-       esac
+
        # This is not an autotools configure file. We don't use econf here.
-       ./configure \
+       CC="$(tc-getCC)" AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" ./configure \
                --enable-verbose-make \
                --prefix="${BROOT}"/usr \
                --libdir="${BROOT}"/usr/$(get_libdir) \
@@ -65,7 +87,7 @@ src_configure() {
                --enable-cblas \
                "${BLIS_FLAGS[@]}" \
                --enable-shared \
-               $confname || die
+               $(get_confname) || die
 }
 
 src_compile() {
@@ -75,7 +97,8 @@ src_compile() {
 }
 
 src_test() {
-       LD_LIBRARY_PATH="${S}/lib/haswell" emake check
+       LD_LIBRARY_PATH=lib/$(get_confname) emake testblis-fast
+       ./testsuite/check-blistest.sh ./output.testsuite || die
 }
 
 src_install() {

Reply via email to