Source: x265
Version: 4.2-3
Severity: normal
Tags: ftbfs patch
X-Debbugs-Cc: [email protected], [email protected], 
[email protected]
User: [email protected]
Usertags: m68k
User: [email protected]
Usertags: sh4
User: [email protected]
Usertags: powerpc

Hi,

x265 FTBFS on m68k, powerpc and sh4 because it uses the old __sync atomic
builtins for which no 64-bit variant exists [1]:

/usr/bin/sh4-linux-gnu-ld.bfd: libx265.so.216: undefined reference to 
`__sync_fetch_and_add_8'
collect2: error: ld returned 1 exit status

This can be fixed by switching over to the new __atomic builtins which are
standard in GCC since version 4.7 [2].

I have also sent a pull-request upstream with a modified patch which accounts
for additional load and store macros added to threading.h [3].

Please consider including this patch for the next upload.

Thanks,
Adrian

> [1] 
> https://buildd.debian.org/status/fetch.php?pkg=x265&arch=sh4&ver=4.2-2&stamp=1782593765&raw=0
> [2] 
> https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc/_005f_005fatomic-Builtins.html#g_t_005f_005fatomic-Builtins
> [3] https://github.com/Multicorewareinc/x265/pull/932

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
--- x265-4.2.orig/source/common/threading.h
+++ x265-4.2/source/common/threading.h
@@ -81,11 +81,11 @@ int64_t no_atomic_add64(int64_t* ptr, in
 #define BSF(id, x)            (id) = ((unsigned long)__builtin_ctz(x))
 #define BSR64(id, x)          (id) = ((unsigned long)__builtin_clzll(x) ^ 63)
 #define BSF64(id, x)          (id) = ((unsigned long)__builtin_ctzll(x))
-#define ATOMIC_OR(ptr, mask)  __sync_fetch_and_or(ptr, mask)
-#define ATOMIC_AND(ptr, mask) __sync_fetch_and_and(ptr, mask)
-#define ATOMIC_INC(ptr)       __sync_add_and_fetch((volatile int32_t*)ptr, 1)
-#define ATOMIC_DEC(ptr)       __sync_add_and_fetch((volatile int32_t*)ptr, -1)
-#define ATOMIC_ADD(ptr, val)  __sync_fetch_and_add((volatile 
__typeof__(*(ptr))*)ptr, (__typeof__(*(ptr) + 0))(val))
+#define ATOMIC_OR(ptr, mask)  __atomic_or_fetch(ptr, mask, __ATOMIC_SEQ_CST)
+#define ATOMIC_AND(ptr, mask) __atomic_and_fetch(ptr, mask, __ATOMIC_SEQ_CST)
+#define ATOMIC_INC(ptr)       __atomic_fetch_add((volatile int32_t*)ptr, 1, 
__ATOMIC_SEQ_CST)
+#define ATOMIC_DEC(ptr)       __atomic_fetch_sub((volatile int32_t*)ptr, 1, 
__ATOMIC_SEQ_CST)
+#define ATOMIC_ADD(ptr, val)  __atomic_fetch_add((volatile 
__typeof__(*(ptr))*)ptr, (__typeof__(*(ptr) + 0))(val), __ATOMIC_SEQ_CST)
 #define GIVE_UP_TIME()        usleep(0)
 
 #elif defined(_MSC_VER)       /* Windows atomic intrinsics */

Reply via email to