1
0
mirror of https://git.tukaani.org/xz.git synced 2025-11-02 06:22:54 +00:00

liblzma: Fix build on old Linux/glibc on ARM64

getauxval() can be available even if HWCAP_CRC32 isn't #defined, so
both have to be checked. HWCAP_CRC32 was added in glibc 2.24 (2016).

Fixes: https://github.com/tukaani-project/xz/issues/190
This commit is contained in:
Lasse Collin 2025-09-28 18:32:05 +03:00
parent 71c2ede383
commit ef67e051d7
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
4 changed files with 17 additions and 4 deletions

View File

@ -1379,6 +1379,13 @@ if(XZ_ARM64_CRC32)
check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL)
tuklib_add_definition_if(liblzma HAVE_GETAUXVAL)
# With getauxval() we also need HWCAP_CRC32 which was
# added in glibc 2.24.
if(HAVE_GETAUXVAL)
check_symbol_exists(HWCAP_CRC32 sys/auxv.h HAVE_HWCAP_CRC32)
tuklib_add_definition_if(liblzma HAVE_HWCAP_CRC32)
endif()
# elf_aux_info() is supported on FreeBSD and OpenBSD >= 7.6.
check_symbol_exists(elf_aux_info sys/auxv.h HAVE_ELF_AUX_INFO)
tuklib_add_definition_if(liblzma HAVE_ELF_AUX_INFO)

View File

@ -1168,7 +1168,8 @@ int main(void)
# Check for ARM64 CRC32 instruction runtime detection.
#
# - getauxval() is supported on Linux.
# - getauxval() is supported on Linux. We also need HWCAP_CRC32 which was
# added in glibc 2.24.
#
# - elf_aux_info() is supported on FreeBSD and OpenBSD >= 7.6.
#
@ -1180,6 +1181,9 @@ int main(void)
#
AS_IF([test "x$enable_arm64_crc32" = xyes], [
AC_CHECK_FUNCS([getauxval elf_aux_info sysctlbyname], [break])
AC_CHECK_DECL([HWCAP_CRC32], [AC_DEFINE([HAVE_HWCAP_CRC32], [1],
[Define to 1 if 'HWCAP_CRC32' is declared in <sys/auxv.h>.])],
[], [[#include <sys/auxv.h>]])
])

View File

@ -23,7 +23,8 @@
// If both versions are going to be built, we need runtime detection
// to check if the instructions are supported.
#if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED)
# if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO)
# if (defined(HAVE_GETAUXVAL) && defined(HAVE_HWCAP_CRC32)) \
|| defined(HAVE_ELF_AUX_INFO)
# include <sys/auxv.h>
# elif defined(_WIN32)
# include <processthreadsapi.h>
@ -103,7 +104,7 @@ crc32_arch_optimized(const uint8_t *buf, size_t size, uint32_t crc)
static inline bool
is_arch_extension_supported(void)
{
#if defined(HAVE_GETAUXVAL)
#if defined(HAVE_GETAUXVAL) && defined(HAVE_HWCAP_CRC32)
return (getauxval(AT_HWCAP) & HWCAP_CRC32) != 0;
#elif defined(HAVE_ELF_AUX_INFO)

View File

@ -89,7 +89,8 @@ extern const uint64_t lzma_crc64_table[4][256];
// ARM64
//
// Keep this in sync with changes to crc32_arm64.h
#if defined(_WIN32) || defined(HAVE_GETAUXVAL) \
#if defined(_WIN32) \
|| (defined(HAVE_GETAUXVAL) && defined(HAVE_HWCAP_CRC32)) \
|| defined(HAVE_ELF_AUX_INFO) \
|| (defined(__APPLE__) && defined(HAVE_SYSCTLBYNAME))
# define CRC_ARM64_RUNTIME_DETECTION 1