<div dir="ltr"><div>Saying nothing about the correctness, these two patches at least fix the mesa build for me when running with clang/clang++ where-as they were broken before when targetting i686-linux-gnu.<br></div><div><br></div>--Aaron<br><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 13, 2017 at 4:20 AM, Jan Beich <span dir="ltr"><<a href="mailto:jbeich@freebsd.org" target="_blank">jbeich@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">glsl/.libs/libstandalone.a(<wbr>libmesautil_la-disk_cache.o): In function `disk_cache_remove':<br>
disk_cache.c:(.text+0x763): undefined reference to `__atomic_fetch_add_8'<br>
glsl/.libs/libstandalone.a(<wbr>libmesautil_la-disk_cache.o): In function `cache_put':<br>
disk_cache.c:(.text+0xabc): undefined reference to `__atomic_fetch_add_8'<br>
disk_cache.c:(.text+0xec1): undefined reference to `__atomic_fetch_add_8'<br>
c++: error: linker command failed with exit code 1 (use -v to see invocation)<br>
<br>
Signed-off-by: Jan Beich <jbeich@FreeBSD.org><br>
---<br>
<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 13 ++++++++++++-<br>
src/util/u_atomic.c | 4 ++++<br>
2 files changed, 16 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index ce5301f3e4..08d8879986 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -415,13 +415,24 @@ AM_CONDITIONAL([GCC_ATOMIC_<wbr>BUILTINS_SUPPORTED], [test x$GCC_ATOMIC_BUILTINS_SUPP<br>
<br>
dnl Check if host supports 64-bit atomics<br>
dnl note that lack of support usually results in link (not compile) error<br>
-AC_MSG_CHECKING(whether __sync_add_and_fetch_8 is supported)<br>
+save_CFLAGS=$CFLAGS<br>
+if test "x$GCC_ATOMIC_BUILTINS_<wbr>SUPPORTED" = x1; then<br>
+ CFLAGS="$CFLAGS -DUSE_GCC_ATOMIC_BUILTINS"<br>
+ AC_MSG_CHECKING(whether __atomic_fetch_add_8 is supported)<br>
+else<br>
+ AC_MSG_CHECKING(whether __sync_add_and_fetch_8 is supported)<br>
+fi<br>
AC_LINK_IFELSE([AC_LANG_<wbr>SOURCE([[<br>
#include <stdint.h><br>
uint64_t v;<br>
int main() {<br>
+#ifdef USE_GCC_ATOMIC_BUILTINS<br>
+ return __atomic_add_fetch(&v, 1, __ATOMIC_ACQ_REL);<br>
+#else<br>
return __sync_add_and_fetch(&v, (uint64_t)1);<br>
+#endif<br>
}]])], GCC_64BIT_ATOMICS_SUPPORTED=<wbr>yes, GCC_64BIT_ATOMICS_SUPPORTED=<wbr>no)<br>
+CFLAGS=$save_CFLAGS<br>
if test "x$GCC_64BIT_ATOMICS_<wbr>SUPPORTED" != xyes; then<br>
DEFINES="$DEFINES -DMISSING_64BIT_ATOMICS"<br>
fi<br>
diff --git a/src/util/u_atomic.c b/src/util/u_atomic.c<br>
index 44b75fb0c0..691c34cf30 100644<br>
--- a/src/util/u_atomic.c<br>
+++ b/src/util/u_atomic.c<br>
@@ -34,6 +34,7 @@<br>
<br>
static pthread_mutex_t sync_mutex = PTHREAD_MUTEX_INITIALIZER;<br>
<br>
+#ifndef USE_GCC_ATOMIC_BUILTINS<br>
WEAK uint64_t<br>
__sync_add_and_fetch_8(uint64_<wbr>t *ptr, uint64_t val)<br>
{<br>
@@ -60,6 +61,8 @@ __sync_sub_and_fetch_8(uint64_<wbr>t *ptr, uint64_t val)<br>
return r;<br>
}<br>
<br>
+#else<br>
+<br>
WEAK uint64_t<br>
__atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder)<br>
{<br>
@@ -71,5 +74,6 @@ __atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder)<br>
{<br>
return __sync_sub_and_fetch(ptr, val);<br>
}<br>
+#endif /* !USE_GCC_ATOMIC_BUILTINS */<br>
<br>
#endif<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div>