]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
msvc/armv7: disable crc32_acle
authorShawn Hoffman <godisgovernment@gmail.com>
Tue, 6 Sep 2022 20:11:16 +0000 (13:11 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 26 Sep 2022 18:09:53 +0000 (20:09 +0200)
msvc compiler targeting 32bit arm supports
only armv7 and lacks these intrinsics

cmake/detect-intrinsics.cmake

index 743af4e87c5cdd6b2eedb76b50d10af628aecb7c..e1b410337f396636c4b586f8f799c3cf887b687d 100644 (file)
@@ -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)