]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
Build: Use AC_LINK_IFELSE instead of -Werror
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 24 Jun 2024 20:35:59 +0000 (23:35 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 26 Jun 2024 12:48:56 +0000 (15:48 +0300)
AC_COMPILE_IFELSE needed -Werror because Clang <= 14 would merely
warn about the unsupported attribute and implicit function declaration.
Changing to AC_LINK_IFELSE handles the implicit declaration because
the symbol __crc32d is unlikely to exist in libc.

Note that the other part of the check is that #include <arm_acle.h>
must work. If the header is missing, most compilers give an error
and the linking step won't be attempted.

Avoiding -Werror makes the check more robust in case CFLAGS contains
warning flags that break -Werror anyway (but this isn't the only check
in configure.ac that has this problem). Using AC_LINK_IFELSE also makes
the check more similar to how it is done in CMakeLists.txt.

configure.ac

index 830be049604abe0c0d11e736ad4d938da582e81d..aa08c37ef3f0448d22c2b0d5bdfea94f95a87341 100644 (file)
@@ -1059,15 +1059,7 @@ 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([[
+       AC_LINK_IFELSE([AC_LANG_SOURCE([[
 #include <arm_acle.h>
 #include <stdint.h>
 
@@ -1087,8 +1079,6 @@ int main(void)
                enable_arm64_crc32=no
        ])
        AC_MSG_RESULT([$enable_arm64_crc32])
-
-       CFLAGS="$OLD_CFLAGS"
 ])
 
 # Check for ARM64 CRC32 instruction runtime detection.