]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Support llvm-mingw toolchain
authorHajin Jang <jb6804@naver.com>
Sun, 10 Sep 2023 09:28:28 +0000 (18:28 +0900)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 27 Sep 2023 22:15:12 +0000 (00:15 +0200)
zlib-ng requires some patches to make it compilable on LLVM-mingw.
1. Add -Wno-pedantic-ms-format only if a toolchain is MinGW GCC.
- llvm-mingw does not support it, causing build to break.
2. Include arm_neon.h instead of arm64_neon.h (aarch64 only).
- arm64_neon.h is MSVC only.
- GCC, Clang does not have arm64_neon.h but arm_neon.h on aarch64.
- Also applied to configure and detect-instrinsics.cmake

CMakeLists.txt
arch/arm/neon_intrins.h
cmake/detect-intrinsics.cmake
configure

index b7dc46be06642c9f3fae67b56e2b9e07bfe93189..6b53e8c8974026097543815b7758aae7f010f7e2 100644 (file)
@@ -239,7 +239,11 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
         endif()
     endif()
     if(MINGW)
-        list(APPEND WARNFLAGS_DISABLE -Wno-pedantic-ms-format)
+        # Add `-Wno-pedantic-ms-format` only if the toolchain is GCC MinGW-w64
+        # llvm-mingw does not support '-Wno-pedantic-ms-format'
+        if(CMAKE_C_COMPILER_ID MATCHES "GNU")
+            list(APPEND WARNFLAGS_DISABLE -Wno-pedantic-ms-format)
+        endif()
     endif()
 endif()
 
index 478697a6de9f21c6575b65eea6a622cf1feb3dca..51df77dbe6855dc565f94a5520f8aaaf3b7d87ef 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef ARM_NEON_INTRINS_H
 #define ARM_NEON_INTRINS_H
 
-#if defined(_M_ARM64) || defined(_M_ARM64EC)
+#if defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
+/* arm64_neon.h is MSVC specific */
 #  include <arm64_neon.h>
 #else
 #  include <arm_neon.h>
index fe1848e62cd3adac9a0d0d8896411b6ce6207c0a..250ee44e5d50ce90f7b2c951f2f486cb7e4e9b40 100644 (file)
@@ -222,7 +222,7 @@ macro(check_neon_ld4_intrinsics)
     # Check whether compiler supports loading 4 neon vecs into a register range
     set(CMAKE_REQUIRED_FLAGS "${NEONFLAG}")
     check_c_source_compiles(
-        "#if defined(_M_ARM64) || defined(_M_ARM64EC)
+        "#if defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
         #  include <arm64_neon.h>
         #else
         #  include <arm_neon.h>
index 29de72cecf007ca4c1b8c4dde866dfa7a6e98480..a660a17e870c01410b358bda6cd9faf569945cdc 100755 (executable)
--- a/configure
+++ b/configure
@@ -1164,7 +1164,7 @@ EOF
 
 check_neon_ld4_intrinsics() {
     cat > $test.c << EOF
-#if defined(_M_ARM64) || defined(_M_ARM64EC)
+#if defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
 #  include <arm64_neon.h>
 #else
 #  include <arm_neon.h>