codership / galera

Synchronous multi-master replication library
GNU General Public License v2.0
448 stars 176 forks source link

Build failure on Ubuntu Xenial aarch64 #579

Closed temeo closed 3 years ago

temeo commented 4 years ago

Galera build fails on Ubuntu Xenial aarch with the following error:

galerautils/src/gu_crc32c_arm64.c: In function 'gu_crc32c_hardware':
galerautils/src/gu_crc32c_arm64.c:78:18: error: 'HWCAP_CRC32' undeclared (first use in this function)
     if (hwcaps & HWCAP_CRC32)
                  ^
galerautils/src/gu_crc32c_arm64.c:78:18: note: each undeclared identifier is reported only once for each function it appears in
galerautils/src/gu_crc32c_arm64.c:87:1: error: control reaches end of non-void function [-Werror=return-type]
 }
ayurchen commented 4 years ago

Seems like Xenial GCC does not have support for hardware CRC32. A workaround would be building with

scons crc32c_no_hardware=1
temeo commented 4 years ago

The following patch makes the build pass:

diff --git a/galerautils/src/gu_crc32c_arm64.c b/galerautils/src/gu_crc32c_arm64.c
index 25acf14d..62c0a0fa 100644
--- a/galerautils/src/gu_crc32c_arm64.c
+++ b/galerautils/src/gu_crc32c_arm64.c
@@ -25,7 +25,7 @@
 static inline gu_crc32c_t
 crc32c_arm64_tail7(gu_crc32c_t state, const uint8_t* ptr, size_t len)
 {
-    assert(len < 7);
+    assert(len < 8);

     if (len >= 4)
     {
@@ -71,6 +71,10 @@ gu_crc32c_arm64(gu_crc32c_t state, const void* data, size_t len)

 #include <sys/auxv.h>

+#ifndef HWCAP_CRC32
+#define HWCAP_CRC32 (1 << 7)
+#endif /* HWCAP_CRC32 */
+
 gu_crc32c_func_t
 gu_crc32c_hardware()
 {