From df2c69a26ad5efaf024fdd081e874c55786a4988 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Thu, 26 Dec 2024 07:15:50 -0500 Subject: [PATCH] Fixes for elf_aux_info support - Remove the unnecessary use of the sys/elf.h header - Add RISC-V support --- configure.ac | 4 ++-- src/arch/simddetect.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index cb853e6665..2fb33f8d5c 100644 --- a/configure.ac +++ b/configure.ac @@ -221,9 +221,9 @@ fi # additional checks for RVV targets if test x$check_for_rvv = x1; then AC_MSG_NOTICE([checking how to detect RVV availability]) - AC_CHECK_FUNCS([getauxval]) + AC_CHECK_FUNCS([getauxval elf_aux_info]) - if test $ac_cv_func_getauxval = no; then + if test $ac_cv_func_getauxval = no && test $ac_cv_func_elf_aux_info = no; then AC_MSG_WARN([RVV is available, but we don't know how to check for it. Will not be able to use RVV.]) fi fi diff --git a/src/arch/simddetect.cpp b/src/arch/simddetect.cpp index 9acd78a886..0031556163 100644 --- a/src/arch/simddetect.cpp +++ b/src/arch/simddetect.cpp @@ -61,12 +61,11 @@ # include # elif defined(HAVE_ELF_AUX_INFO) # include -# include # endif #endif #if defined(HAVE_RVV) -# if defined(HAVE_GETAUXVAL) +# if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO) # include # define HWCAP_RV(letter) (1ul << ((letter) - 'A')) # endif @@ -244,6 +243,10 @@ SIMDDetect::SIMDDetect() { # if defined(HAVE_GETAUXVAL) const unsigned long hwcap = getauxval(AT_HWCAP); rvv_available_ = hwcap & HWCAP_RV('V'); +# elif defined(HAVE_ELF_AUX_INFO) + unsigned long hwcap = 0; + elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap); + rvv_available_ = hwcap & HWCAP_RV('V'); # endif #endif