From: Shawn Hoffman Date: Tue, 6 Sep 2022 20:11:16 +0000 (-0700) Subject: msvc/armv7: disable crc32_acle X-Git-Tag: 2.1.0-beta1~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ece74eec32cbd1da4fddf772757ece3844b49c94;p=thirdparty%2Fzlib-ng.git msvc/armv7: disable crc32_acle msvc compiler targeting 32bit arm supports only armv7 and lacks these intrinsics --- diff --git a/cmake/detect-intrinsics.cmake b/cmake/detect-intrinsics.cmake index 743af4e87..e1b410337 100644 --- a/cmake/detect-intrinsics.cmake +++ b/cmake/detect-intrinsics.cmake @@ -2,29 +2,35 @@ # Licensed under the Zlib license, see LICENSE.md for details macro(check_acle_compiler_flag) - if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") - if(NOT NATIVEFLAG AND NOT HAVE_ACLE_FLAG) - set(ACLEFLAG "-march=armv8-a+crc" CACHE INTERNAL "Compiler option to enable ACLE support") + if(MSVC) + # Both ARM and ARM64-targeting msvc support intrinsics, but + # ARM msvc is missing some intrinsics introduced with ARMv8, e.g. crc32 + if(MSVC_C_ARCHITECTURE_ID STREQUAL "ARM64") + set(HAVE_ACLE_FLAG TRUE) + endif() + else() + if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") + if(NOT NATIVEFLAG AND NOT HAVE_ACLE_FLAG) + set(ACLEFLAG "-march=armv8-a+crc" CACHE INTERNAL "Compiler option to enable ACLE support") + endif() endif() - elseif(MSVC) - set(HAVE_ACLE_FLAG TRUE) - endif() - # Check whether compiler supports ACLE flag - set(CMAKE_REQUIRED_FLAGS "${ACLEFLAG} ${NATIVEFLAG}") - check_c_source_compiles( - "int main() { return 0; }" - HAVE_ACLE_FLAG FAIL_REGEX "not supported") - if(NOT NATIVEFLAG AND NOT HAVE_ACLE_FLAG) - set(ACLEFLAG "-march=armv8-a+crc+simd" CACHE INTERNAL "Compiler option to enable ACLE support" FORCE) # Check whether compiler supports ACLE flag - set(CMAKE_REQUIRED_FLAGS "${ACLEFLAG}") + set(CMAKE_REQUIRED_FLAGS "${ACLEFLAG} ${NATIVEFLAG}") check_c_source_compiles( "int main() { return 0; }" - HAVE_ACLE_FLAG2 FAIL_REGEX "not supported") - set(HAVE_ACLE_FLAG ${HAVE_ACLE_FLAG2} CACHE INTERNAL "Have compiler option to enable ACLE intrinsics" FORCE) - unset(HAVE_ACLE_FLAG2 CACHE) # Don't cache this internal variable + HAVE_ACLE_FLAG FAIL_REGEX "not supported") + if(NOT NATIVEFLAG AND NOT HAVE_ACLE_FLAG) + set(ACLEFLAG "-march=armv8-a+crc+simd" CACHE INTERNAL "Compiler option to enable ACLE support" FORCE) + # Check whether compiler supports ACLE flag + set(CMAKE_REQUIRED_FLAGS "${ACLEFLAG}") + check_c_source_compiles( + "int main() { return 0; }" + HAVE_ACLE_FLAG2 FAIL_REGEX "not supported") + set(HAVE_ACLE_FLAG ${HAVE_ACLE_FLAG2} CACHE INTERNAL "Have compiler option to enable ACLE intrinsics" FORCE) + unset(HAVE_ACLE_FLAG2 CACHE) # Don't cache this internal variable + endif() + set(CMAKE_REQUIRED_FLAGS) endif() - set(CMAKE_REQUIRED_FLAGS) endmacro() macro(check_avx512_intrinsics)