diff options
author | Jia Tan <jiat0218@gmail.com> | 2024-02-23 16:12:32 +0800 |
---|---|---|
committer | Jia Tan <jiat0218@gmail.com> | 2024-02-23 16:12:32 +0800 |
commit | 32b0a3ce19224f9074d01a4ffbc1655b05fcb82d (patch) | |
tree | 680f23f05fab7415f834e1359c93ac2bb0c0f100 | |
parent | CMake: Add LOCALEDIR to the windres workaround. (diff) | |
download | xz-32b0a3ce19224f9074d01a4ffbc1655b05fcb82d.tar.xz |
Build: Fix ARM64 CRC32 instruction feature test.
Old versions of Clang reported the unsupported function attribute and
__crc32d() function as warnings instead of errors, so the feature test
passed when it shouldn't have, causing a compile error at build time.
-Werror was added to this feature test to fix this. The change is not
needed for CMake because check_c_source_compiles() also performs
linking and the error is caught then.
Thanks to Sebastian Andrzej Siewior for reporting this.
-rw-r--r-- | configure.ac | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 36ceeef3..4476c8b4 100644 --- a/configure.ac +++ b/configure.ac @@ -1104,6 +1104,14 @@ AC_MSG_CHECKING([if ARM64 CRC32 instruction is usable]) AS_IF([test "x$enable_arm64_crc32" = xno], [ AC_MSG_RESULT([no, --disable-arm64-crc32 was used]) ], [ + # Set -Werror here because some versions of Clang (14 and older) + # do not report the unsupported __attribute__((__target__("+crc"))) + # or __crc32d() as an error, only as a warning. This does not need + # to be done with CMake because tests will attempt to link and the + # error will be reported then. + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include <arm_acle.h> #include <stdint.h> @@ -1124,6 +1132,8 @@ uint32_t my_crc(uint32_t a, uint64_t b) enable_arm64_crc32=no ]) AC_MSG_RESULT([$enable_arm64_crc32]) + + CFLAGS="$OLD_CFLAGS" ]) # Check for ARM64 CRC32 instruction runtime detection. |