Skip to content

Commit a8db873

Browse files
committed
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: #190
1 parent 71c2ede commit a8db873

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/liblzma/check/crc32_arm64.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
// If both versions are going to be built, we need runtime detection
2424
// to check if the instructions are supported.
2525
#if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED)
26-
# if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO)
26+
# if (defined(HAVE_GETAUXVAL) && defined(HWCAP_CRC32)) \
27+
|| defined(HAVE_ELF_AUX_INFO)
2728
# include <sys/auxv.h>
2829
# elif defined(_WIN32)
2930
# include <processthreadsapi.h>
@@ -103,7 +104,7 @@ crc32_arch_optimized(const uint8_t *buf, size_t size, uint32_t crc)
103104
static inline bool
104105
is_arch_extension_supported(void)
105106
{
106-
#if defined(HAVE_GETAUXVAL)
107+
#if defined(HAVE_GETAUXVAL) && defined(HWCAP_CRC32)
107108
return (getauxval(AT_HWCAP) & HWCAP_CRC32) != 0;
108109

109110
#elif defined(HAVE_ELF_AUX_INFO)

src/liblzma/check/crc_common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ extern const uint64_t lzma_crc64_table[4][256];
8989
// ARM64
9090
//
9191
// Keep this in sync with changes to crc32_arm64.h
92-
#if defined(_WIN32) || defined(HAVE_GETAUXVAL) \
92+
#if defined(_WIN32) \
93+
|| (defined(HAVE_GETAUXVAL) && defined(HWCAP_CRC32)) \
9394
|| defined(HAVE_ELF_AUX_INFO) \
9495
|| (defined(__APPLE__) && defined(HAVE_SYSCTLBYNAME))
9596
# define CRC_ARM64_RUNTIME_DETECTION 1

0 commit comments

Comments
 (0)