diff options
author | Khem Raj <raj.khem@gmail.com> | 2017-08-16 17:48:00 -0700 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2017-08-16 17:48:00 -0700 |
commit | 30b7c8c8f229735dda6ffd45cda7b5543f0cde06 (patch) | |
tree | 4676e14ee04f8d426ccf85abcfb3be4ec05fbb68 | |
parent | 0383b374ef8e328de9622505e508950d4d4d2596 (diff) | |
download | meta-clang-30b7c8c8f229735dda6ffd45cda7b5543f0cde06.tar.gz |
mesa: Add 64bits atomics patches for clang/x86
These patches are taken from mailing list
Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 files changed, 127 insertions, 0 deletions
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 @@ | |||
1 | From cc580e1c4d2628f8d1fa41c574d0af2498c7b33c Mon Sep 17 00:00:00 2001 | ||
2 | From: Jan Beich <jbeich@freebsd.org> | ||
3 | Date: Sat, 13 May 2017 11:20:53 +0200 | ||
4 | Subject: [PATCH 1/2] Clang doesn't have 64bit __atomic* builtins on i386 | ||
5 | |||
6 | glsl/.libs/libstandalone.a(libmesautil_la-disk_cache.o): In function `disk_cache_remove': | ||
7 | disk_cache.c:(.text+0x763): undefined reference to `__atomic_fetch_add_8' | ||
8 | glsl/.libs/libstandalone.a(libmesautil_la-disk_cache.o): In function `cache_put': | ||
9 | disk_cache.c:(.text+0xabc): undefined reference to `__atomic_fetch_add_8' | ||
10 | disk_cache.c:(.text+0xec1): undefined reference to `__atomic_fetch_add_8' | ||
11 | c++: error: linker command failed with exit code 1 (use -v to see invocation) | ||
12 | |||
13 | Signed-off-by: Jan Beich <jbeich@FreeBSD.org> | ||
14 | --- | ||
15 | configure.ac | 13 ++++++++++++- | ||
16 | src/util/u_atomic.c | 4 ++++ | ||
17 | 2 files changed, 16 insertions(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/configure.ac b/configure.ac | ||
20 | index e3babd3909..6554ab7251 100644 | ||
21 | --- a/configure.ac | ||
22 | +++ b/configure.ac | ||
23 | @@ -415,13 +415,24 @@ AM_CONDITIONAL([GCC_ATOMIC_BUILTINS_SUPPORTED], [test x$GCC_ATOMIC_BUILTINS_SUPP | ||
24 | |||
25 | dnl Check if host supports 64-bit atomics | ||
26 | dnl note that lack of support usually results in link (not compile) error | ||
27 | -AC_MSG_CHECKING(whether __sync_add_and_fetch_8 is supported) | ||
28 | +save_CFLAGS=$CFLAGS | ||
29 | +if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" = x1; then | ||
30 | + CFLAGS="$CFLAGS -DUSE_GCC_ATOMIC_BUILTINS" | ||
31 | + AC_MSG_CHECKING(whether __atomic_fetch_add_8 is supported) | ||
32 | +else | ||
33 | + AC_MSG_CHECKING(whether __sync_add_and_fetch_8 is supported) | ||
34 | +fi | ||
35 | AC_LINK_IFELSE([AC_LANG_SOURCE([[ | ||
36 | #include <stdint.h> | ||
37 | uint64_t v; | ||
38 | int main() { | ||
39 | +#ifdef USE_GCC_ATOMIC_BUILTINS | ||
40 | + return __atomic_add_fetch(&v, 1, __ATOMIC_ACQ_REL); | ||
41 | +#else | ||
42 | return __sync_add_and_fetch(&v, (uint64_t)1); | ||
43 | +#endif | ||
44 | }]])], GCC_64BIT_ATOMICS_SUPPORTED=yes, GCC_64BIT_ATOMICS_SUPPORTED=no) | ||
45 | +CFLAGS=$save_CFLAGS | ||
46 | if test "x$GCC_64BIT_ATOMICS_SUPPORTED" != xyes; then | ||
47 | DEFINES="$DEFINES -DMISSING_64BIT_ATOMICS" | ||
48 | fi | ||
49 | diff --git a/src/util/u_atomic.c b/src/util/u_atomic.c | ||
50 | index 44b75fb0c0..691c34cf30 100644 | ||
51 | --- a/src/util/u_atomic.c | ||
52 | +++ b/src/util/u_atomic.c | ||
53 | @@ -34,6 +34,7 @@ | ||
54 | |||
55 | static pthread_mutex_t sync_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
56 | |||
57 | +#ifndef USE_GCC_ATOMIC_BUILTINS | ||
58 | WEAK uint64_t | ||
59 | __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val) | ||
60 | { | ||
61 | @@ -60,6 +61,8 @@ __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val) | ||
62 | return r; | ||
63 | } | ||
64 | |||
65 | +#else | ||
66 | + | ||
67 | WEAK uint64_t | ||
68 | __atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder) | ||
69 | { | ||
70 | @@ -71,5 +74,6 @@ __atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder) | ||
71 | { | ||
72 | return __sync_sub_and_fetch(ptr, val); | ||
73 | } | ||
74 | +#endif /* !USE_GCC_ATOMIC_BUILTINS */ | ||
75 | |||
76 | #endif | ||
77 | -- | ||
78 | 2.14.1 | ||
79 | |||
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 @@ | |||
1 | From b919db72e6f1b1d98d0c97f9919b7593af11d0ae Mon Sep 17 00:00:00 2001 | ||
2 | From: Jan Beich <jbeich@freebsd.org> | ||
3 | Date: Sat, 13 May 2017 11:21:12 +0200 | ||
4 | Subject: [PATCH 2/2] Add prototypes for 64bit atomics fallback | ||
5 | |||
6 | u_atomic.c:67:1: error: no previous prototype for function '__atomic_fetch_add_8' | ||
7 | [-Werror,-Wmissing-prototypes] | ||
8 | __atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder) | ||
9 | ^ | ||
10 | u_atomic.c:73:1: error: no previous prototype for function '__atomic_fetch_sub_8' | ||
11 | [-Werror,-Wmissing-prototypes] | ||
12 | __atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder) | ||
13 | ^ | ||
14 | 2 errors generated. | ||
15 | |||
16 | Signed-off-by: Jan Beich <jbeich@FreeBSD.org> | ||
17 | --- | ||
18 | src/util/u_atomic.c | 8 ++++++++ | ||
19 | 1 file changed, 8 insertions(+) | ||
20 | |||
21 | diff --git a/src/util/u_atomic.c b/src/util/u_atomic.c | ||
22 | index 691c34cf30..ce600aeeed 100644 | ||
23 | --- a/src/util/u_atomic.c | ||
24 | +++ b/src/util/u_atomic.c | ||
25 | @@ -34,6 +34,14 @@ | ||
26 | |||
27 | static pthread_mutex_t sync_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
28 | |||
29 | +#ifdef USE_GCC_ATOMIC_BUILTINS | ||
30 | +uint64_t __atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder); | ||
31 | +uint64_t __atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder); | ||
32 | +#else | ||
33 | +uint64_t __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val); | ||
34 | +uint64_t __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val); | ||
35 | +#endif | ||
36 | + | ||
37 | #ifndef USE_GCC_ATOMIC_BUILTINS | ||
38 | WEAK uint64_t | ||
39 | __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val) | ||
40 | -- | ||
41 | 2.14.1 | ||
42 | |||
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 @@ | |||
1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
2 | |||
3 | SRC_URI_append_toolchain-clang = "\ | ||
4 | file://0001-Clang-doesn-t-have-64bit-__atomic-builtins-on-i386.patch \ | ||
5 | file://0002-Add-prototypes-for-64bit-atomics-fallback.patch \ | ||
6 | " | ||