From 30b7c8c8f229735dda6ffd45cda7b5543f0cde06 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 16 Aug 2017 17:48:00 -0700 Subject: mesa: Add 64bits atomics patches for clang/x86 These patches are taken from mailing list Signed-off-by: Khem Raj --- ...sn-t-have-64bit-__atomic-builtins-on-i386.patch | 79 ++++++++++++++++++++++ ...Add-prototypes-for-64bit-atomics-fallback.patch | 42 ++++++++++++ recipes-graphics/mesa/mesa_%.bbappend | 6 ++ 3 files changed, 127 insertions(+) create mode 100644 recipes-graphics/mesa/mesa/0001-Clang-doesn-t-have-64bit-__atomic-builtins-on-i386.patch create mode 100644 recipes-graphics/mesa/mesa/0002-Add-prototypes-for-64bit-atomics-fallback.patch create mode 100644 recipes-graphics/mesa/mesa_%.bbappend diff --git a/recipes-graphics/mesa/mesa/0001-Clang-doesn-t-have-64bit-__atomic-builtins-on-i386.patch b/recipes-graphics/mesa/mesa/0001-Clang-doesn-t-have-64bit-__atomic-builtins-on-i386.patch new file mode 100644 index 0000000..05c9074 --- /dev/null +++ b/recipes-graphics/mesa/mesa/0001-Clang-doesn-t-have-64bit-__atomic-builtins-on-i386.patch @@ -0,0 +1,79 @@ +From cc580e1c4d2628f8d1fa41c574d0af2498c7b33c Mon Sep 17 00:00:00 2001 +From: Jan Beich +Date: Sat, 13 May 2017 11:20:53 +0200 +Subject: [PATCH 1/2] Clang doesn't have 64bit __atomic* builtins on i386 + +glsl/.libs/libstandalone.a(libmesautil_la-disk_cache.o): In function `disk_cache_remove': +disk_cache.c:(.text+0x763): undefined reference to `__atomic_fetch_add_8' +glsl/.libs/libstandalone.a(libmesautil_la-disk_cache.o): In function `cache_put': +disk_cache.c:(.text+0xabc): undefined reference to `__atomic_fetch_add_8' +disk_cache.c:(.text+0xec1): undefined reference to `__atomic_fetch_add_8' +c++: error: linker command failed with exit code 1 (use -v to see invocation) + +Signed-off-by: Jan Beich +--- + configure.ac | 13 ++++++++++++- + src/util/u_atomic.c | 4 ++++ + 2 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index e3babd3909..6554ab7251 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -415,13 +415,24 @@ AM_CONDITIONAL([GCC_ATOMIC_BUILTINS_SUPPORTED], [test x$GCC_ATOMIC_BUILTINS_SUPP + + dnl Check if host supports 64-bit atomics + dnl note that lack of support usually results in link (not compile) error +-AC_MSG_CHECKING(whether __sync_add_and_fetch_8 is supported) ++save_CFLAGS=$CFLAGS ++if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" = x1; then ++ CFLAGS="$CFLAGS -DUSE_GCC_ATOMIC_BUILTINS" ++ AC_MSG_CHECKING(whether __atomic_fetch_add_8 is supported) ++else ++ AC_MSG_CHECKING(whether __sync_add_and_fetch_8 is supported) ++fi + AC_LINK_IFELSE([AC_LANG_SOURCE([[ + #include + uint64_t v; + int main() { ++#ifdef USE_GCC_ATOMIC_BUILTINS ++ return __atomic_add_fetch(&v, 1, __ATOMIC_ACQ_REL); ++#else + return __sync_add_and_fetch(&v, (uint64_t)1); ++#endif + }]])], GCC_64BIT_ATOMICS_SUPPORTED=yes, GCC_64BIT_ATOMICS_SUPPORTED=no) ++CFLAGS=$save_CFLAGS + if test "x$GCC_64BIT_ATOMICS_SUPPORTED" != xyes; then + DEFINES="$DEFINES -DMISSING_64BIT_ATOMICS" + fi +diff --git a/src/util/u_atomic.c b/src/util/u_atomic.c +index 44b75fb0c0..691c34cf30 100644 +--- a/src/util/u_atomic.c ++++ b/src/util/u_atomic.c +@@ -34,6 +34,7 @@ + + static pthread_mutex_t sync_mutex = PTHREAD_MUTEX_INITIALIZER; + ++#ifndef USE_GCC_ATOMIC_BUILTINS + WEAK uint64_t + __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val) + { +@@ -60,6 +61,8 @@ __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val) + return r; + } + ++#else ++ + WEAK uint64_t + __atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder) + { +@@ -71,5 +74,6 @@ __atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder) + { + return __sync_sub_and_fetch(ptr, val); + } ++#endif /* !USE_GCC_ATOMIC_BUILTINS */ + + #endif +-- +2.14.1 + diff --git a/recipes-graphics/mesa/mesa/0002-Add-prototypes-for-64bit-atomics-fallback.patch b/recipes-graphics/mesa/mesa/0002-Add-prototypes-for-64bit-atomics-fallback.patch new file mode 100644 index 0000000..5c05607 --- /dev/null +++ b/recipes-graphics/mesa/mesa/0002-Add-prototypes-for-64bit-atomics-fallback.patch @@ -0,0 +1,42 @@ +From b919db72e6f1b1d98d0c97f9919b7593af11d0ae Mon Sep 17 00:00:00 2001 +From: Jan Beich +Date: Sat, 13 May 2017 11:21:12 +0200 +Subject: [PATCH 2/2] Add prototypes for 64bit atomics fallback + +u_atomic.c:67:1: error: no previous prototype for function '__atomic_fetch_add_8' + [-Werror,-Wmissing-prototypes] +__atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder) +^ +u_atomic.c:73:1: error: no previous prototype for function '__atomic_fetch_sub_8' + [-Werror,-Wmissing-prototypes] +__atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder) +^ +2 errors generated. + +Signed-off-by: Jan Beich +--- + src/util/u_atomic.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/util/u_atomic.c b/src/util/u_atomic.c +index 691c34cf30..ce600aeeed 100644 +--- a/src/util/u_atomic.c ++++ b/src/util/u_atomic.c +@@ -34,6 +34,14 @@ + + static pthread_mutex_t sync_mutex = PTHREAD_MUTEX_INITIALIZER; + ++#ifdef USE_GCC_ATOMIC_BUILTINS ++uint64_t __atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder); ++uint64_t __atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder); ++#else ++uint64_t __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val); ++uint64_t __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val); ++#endif ++ + #ifndef USE_GCC_ATOMIC_BUILTINS + WEAK uint64_t + __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val) +-- +2.14.1 + diff --git a/recipes-graphics/mesa/mesa_%.bbappend b/recipes-graphics/mesa/mesa_%.bbappend new file mode 100644 index 0000000..65ef609 --- /dev/null +++ b/recipes-graphics/mesa/mesa_%.bbappend @@ -0,0 +1,6 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI_append_toolchain-clang = "\ + file://0001-Clang-doesn-t-have-64bit-__atomic-builtins-on-i386.patch \ + file://0002-Add-prototypes-for-64bit-atomics-fallback.patch \ +" -- cgit v1.2.3-54-g00ecf