Bug#754623: percona-xtradb-cluster-galera-2.x: FTBFS on many archs

2014-08-15 Thread Dejan Latinovic

Hi,

The reason for this failure is a difference
in alignment of long long for MIPS ISA and IA32.
This results that size of gu_rse structure on mips is 24,
instead of expected 20 (on ia32).

As long long is first attribute in structure,
so it is safe to use pack(4).

 struct gu_rse
 {
 long long   time;
 const void* heap_ptr;
 const void* stack_ptr;
 longpid;
 };


I assume that this fix could be used for other architectures like:
armel, armhf, powerpc, sparc.
I did not have a chance to test it on those architectures,
so my changes affects only mips and mipsel.



Solving this issue, fallowing error appears:

 gcs/src/gcs.c:1161: undefined reference to `__sync_fetch_and_add_8'


Mips platform does not have 64-bit __sync_* operations.
To avoid this behaviuor it is needed to use
corresponding __atomic_* from libatomic library.


Patch that solves both issues for mips/mipsel is attached.

Could you please consider including this patch?


Best Regards,
Dejan




diff -uNr percona-xtradb-cluster-galera-2.x-175.orig/SConstruct percona-xtradb-cluster-galera-2.x-175/SConstruct
--- percona-xtradb-cluster-galera-2.x-175.orig/SConstruct	2014-08-13 12:17:02.0 +
+++ percona-xtradb-cluster-galera-2.x-175/SConstruct	2014-08-13 17:07:21.0 +
@@ -368,7 +368,7 @@
 print 'Not using boost'
 
 # Check to see if -latomic is need for GCC atomic built-ins.
-if conf.CheckLib(library='atomic', symbol='__sync_fetch_and_add_8'):
+if conf.CheckLib(library='atomic', symbol='__sync_fetch_and_add_8') or conf.CheckLib(library='atomic', symbol='__atomic_fetch_add_8'):
 conf.env.Append(LIBS=['atomic'])
 
 # asio
diff -uNr percona-xtradb-cluster-galera-2.x-175.orig/galerautils/src/gu_atomic.h percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_atomic.h
--- percona-xtradb-cluster-galera-2.x-175.orig/galerautils/src/gu_atomic.h	2014-05-08 01:08:52.0 +
+++ percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_atomic.h	2014-08-13 17:07:46.0 +
@@ -11,6 +11,8 @@
 
 #ifdef __GNUC__
 
+#if !defined(__mips__) || defined(__mips64)
+
 #define gu_sync_fetch_and_add  __sync_fetch_and_add
 #define gu_sync_fetch_and_sub  __sync_fetch_and_sub
 #define gu_sync_fetch_and_or   __sync_fetch_and_or
@@ -26,6 +28,28 @@
 #define gu_sync_xor_and_fetch  __sync_xor_and_fetch
 #define gu_sync_nand_and_fetch __gu_sync_nand_and_fetch
 
+#else  /* __mips__ */
+
+/* Mips platform does not have 64-bit __sync_* operations.
+ * so it is needed to use corresponding __atomic_* operations from libatomic library. */
+
+#define gu_sync_fetch_and_add(value_, x)  __atomic_fetch_add(value_, x, __ATOMIC_SEQ_CST)
+#define gu_sync_fetch_and_sub(value_, x)  __atomic_fetch_sub(value_, x, __ATOMIC_SEQ_CST)  
+#define gu_sync_fetch_and_or(value_, x)   __atomic_fetch_or(value_, x, __ATOMIC_SEQ_CST) 
+#define gu_sync_fetch_and_and(value_, x)  __atomic_fetch_and(value_, x, __ATOMIC_SEQ_CST)
+#define gu_sync_fetch_and_xor(value_, x)  __atomic_fetch_xor(value_, x, __ATOMIC_SEQ_CST)
+#define gu_sync_fetch_and_nand(value_, x) __atomic_fetch_nand(value_, x, __ATOMIC_SEQ_CST)
+
+
+#define gu_sync_add_and_fetch(value_, x)  __atomic_add_fetch(value_, x, __ATOMIC_SEQ_CST)
+#define gu_sync_sub_and_fetch(value_, x)  __atomic_sub_fetch(value_, x, __ATOMIC_SEQ_CST)
+#define gu_sync_or_and_fetch(value_, x)   __atomic_or_fetch(value_, x, __ATOMIC_SEQ_CST)   
+#define gu_sync_and_and_fetch(value_, x)  __atomic_and_fetch(value_, x, __ATOMIC_SEQ_CST)
+#define gu_sync_xor_and_fetch(value_, x)  __atomic_xor_fetch(value_, x, __ATOMIC_SEQ_CST)
+#define gu_sync_nand_and_fetch(value_, x) __atomic_nand_fetch(value_, x, __ATOMIC_SEQ_CST)
+
+#endif
+
 #else /* __GNUC__ */
 #error Compiler not supported
 #endif
diff -uNr percona-xtradb-cluster-galera-2.x-175.orig/galerautils/src/gu_rand.c percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_rand.c
--- percona-xtradb-cluster-galera-2.x-175.orig/galerautils/src/gu_rand.c	2014-05-08 01:08:52.0 +
+++ percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_rand.c	2014-08-13 17:07:25.0 +
@@ -16,6 +16,16 @@
 
 /*! Structure to hold entropy data.
  *  Should be at least 20 bytes on 32-bit systems and 28 bytes on 64-bit */
+
+/*  Unlike ia32, aligment of long long for MIPS ISA is 8, and size of gu_rse is 24.
+ *  As long long atribute is first in gu_rse structure there is no harm in use pack(4) to avoid
+ *  undexpected behavior while using gu_rse structure. */
+
+#if defined(__mips__)  !defined(__mips64__)
+#pragma pack(push)
+#pragma pack(4)
+#endif
+
 struct gu_rse
 {
 long long   time;
@@ -24,6 +34,10 @@
 longpid;
 };
 
+#if defined(__mips__)  !defined(__mips64__)
+#pragma pack(pop)
+#endif
+
 typedef struct gu_rse gu_rse_t;
 
 long int


Bug#754623: percona-xtradb-cluster-galera-2.x: FTBFS on many archs

2014-07-12 Thread Cyril Brulebois
Source: percona-xtradb-cluster-galera-2.x
Version: 175-2
Severity: serious
Justification: FTBFS

Hi,

your package no longer builds on many archs. Build excerpt from powerpc:
| gcc -o galerautils/src/gu_rand.o -c -std=c99 -fno-strict-aliasing -pipe -g 
-O3 -DNDEBUG -Wall -Wextra -Wno-unused-parameter -pedantic -pthread 
-D_XOPEN_SOURCE=600 -DHAVE_COMMON_H -DGALERA_USE_GU_NETWORK -DHAVE_BYTESWAP_H 
-DHAVE_ENDIAN_H -DHAVE_BOOST_SHARED_PTR_HPP -DHAVE_TR1_UNORDERED_MAP 
-DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG=1 -DHAVE_ASIO_HPP -DHAVE_ASIO_SSL_HPP 
-Werror -Icommon -Iasio -Igalerautils/src -Igcomm/src -Igcomm/src/gcomm 
-Igcache/src -Igcs/src -Iwsdb/src -Igalera/src galerautils/src/gu_rand.c
| In file included from galerautils/src/gu_hash.h:30:0,
|  from galerautils/src/gu_rand.c:15:
| galerautils/src/gu_rand.c: In function 'gu_rand_seed_long':
| galerautils/src/gu_mmh3.h:195:21: error: '*((void *)rse+23)' is used 
uninitialized in this function [-Werror=uninitialized]
|  case  8: k1 ^= ((uint64_t)tail[ 7])  56;
|  ^
| galerautils/src/gu_rand.c:32:14: note: '*((void *)rse+23)' was declared here
|  gu_rse_t rse = { time, heap_ptr, time, pid };
|   ^
| In file included from galerautils/src/gu_hash.h:30:0,
|  from galerautils/src/gu_rand.c:15:
| galerautils/src/gu_mmh3.h:196:21: error: '*((void *)rse+22)' is used 
uninitialized in this function [-Werror=uninitialized]
|  case  7: k1 ^= ((uint64_t)tail[ 6])  48;
|  ^
| galerautils/src/gu_rand.c:32:14: note: '*((void *)rse+22)' was declared here
|  gu_rse_t rse = { time, heap_ptr, time, pid };
|   ^
| In file included from galerautils/src/gu_hash.h:30:0,
|  from galerautils/src/gu_rand.c:15:
| galerautils/src/gu_mmh3.h:197:21: error: '*((void *)rse+21)' is used 
uninitialized in this function [-Werror=uninitialized]
|  case  6: k1 ^= ((uint64_t)tail[ 5])  40;
|  ^
| galerautils/src/gu_rand.c:32:14: note: '*((void *)rse+21)' was declared here
|  gu_rse_t rse = { time, heap_ptr, time, pid };
|   ^
| In file included from galerautils/src/gu_hash.h:30:0,
|  from galerautils/src/gu_rand.c:15:
| galerautils/src/gu_mmh3.h:198:21: error: '*((void *)rse+20)' is used 
uninitialized in this function [-Werror=uninitialized]
|  case  5: k1 ^= ((uint64_t)tail[ 4])  32;
|  ^
| galerautils/src/gu_rand.c:32:14: note: '*((void *)rse+20)' was declared here
|  gu_rse_t rse = { time, heap_ptr, time, pid };
|   ^
| cc1: all warnings being treated as errors
| scons: *** [galerautils/src/gu_rand.o] Error 1

Full build log:
  
https://buildd.debian.org/status/fetch.php?pkg=percona-xtradb-cluster-galera-2.xarch=powerpcver=175-2stamp=1404609797

Build log summary:
  
https://buildd.debian.org/status/package.php?p=percona-xtradb-cluster-galera-2.xsuite=sid

Mraw,
KiBi.


-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org