From: Nathan Moinvaziri Date: Wed, 30 Aug 2023 14:29:46 +0000 (-0700) Subject: Merge 32-bit arm hardware flag detection sections in configure and cmake X-Git-Tag: 2.1.4~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4838f0e9677eedfba4e1eafbc63141b001429cfc;p=thirdparty%2Fzlib-ng.git Merge 32-bit arm hardware flag detection sections in configure and cmake --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3679f9d6c..f74c0e454 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -548,7 +548,20 @@ if(WITH_OPTIM) if(BASEARCH_ARM_FOUND) add_definitions(-DARM_FEATURES) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - if(NOT "${ARCH}" MATCHES "aarch64") + if("${ARCH}" MATCHES "aarch64") + check_c_source_compiles( + "#include + int main() { + return (getauxval(AT_HWCAP) & HWCAP_CRC32); + }" + ARM_AUXV_HAS_CRC32 + ) + if(ARM_AUXV_HAS_CRC32) + add_definitions(-DARM_AUXV_HAS_CRC32) + else() + message(STATUS "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime.") + endif() + else() check_c_source_compiles( "#include int main() { @@ -573,21 +586,6 @@ if(WITH_OPTIM) message(STATUS "HWCAP2_CRC32 not present in sys/auxv.h; cannot detect support at runtime.") endif() endif() - else() - check_c_source_compiles( - "#include - int main() { - return (getauxval(AT_HWCAP) & HWCAP_CRC32); - }" - ARM_AUXV_HAS_CRC32 - ) - if(ARM_AUXV_HAS_CRC32) - add_definitions(-DARM_AUXV_HAS_CRC32) - else() - message(STATUS "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime.") - endif() - endif() - if(NOT "${ARCH}" MATCHES "aarch64") check_c_source_compiles( "#include int main() { diff --git a/configure b/configure index b6339fbcc..461805487 100755 --- a/configure +++ b/configure @@ -1593,7 +1593,20 @@ EOF ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} arm_features.lo" if test $LINUX -eq 1; then - if test "$ARCH" != "aarch64"; then + if test "$ARCH" = "aarch64"; then + cat > $test.c < +int main() { + return (getauxval(AT_HWCAP) & HWCAP_CRC32); +} +EOF + if try $CC -c $CFLAGS $test.c; then + CFLAGS="${CFLAGS} -DARM_AUXV_HAS_CRC32" + SFLAGS="${SFLAGS} -DARM_AUXV_HAS_CRC32" + else + echo "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log + fi + else cat > $test.c < int main() { @@ -1618,22 +1631,7 @@ EOF echo "HWCAP2_CRC32 not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log fi fi - else - cat > $test.c < -int main() { - return (getauxval(AT_HWCAP) & HWCAP_CRC32); -} -EOF - if try $CC -c $CFLAGS $test.c; then - CFLAGS="${CFLAGS} -DARM_AUXV_HAS_CRC32" - SFLAGS="${SFLAGS} -DARM_AUXV_HAS_CRC32" - else - echo "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log - fi - fi - if test "$ARCH" != "aarch64"; then cat > $test.c < int main() {