[PATCH 15/53] webkitgtk: Fix build with clang

Khem Raj
2016-01-08T10:19:36Z

backtrace is glibc only feature on linux so check for glibc before using
it
Clangs clear_cache has different signature than gcc provided builtin
make it compatible for both

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
...nable-backtrace-on-linux-when-using-glibc.patch | 39 ++++++++++++++++++++++
meta/recipes-sato/webkit/webkitgtk/clang.patch | 25 ++++++++++++++
meta/recipes-sato/webkit/webkitgtk_2.10.4.bb | 2 ++
3 files changed, 66 insertions(+)
create mode 100644 meta/recipes-sato/webkit/webkitgtk/0001-Enable-backtrace-on-linux-when-using-glibc.patch
create mode 100644 meta/recipes-sato/webkit/webkitgtk/clang.patch

diff --git a/meta/recipes-sato/webkit/webkitgtk/0001-Enable-backtrace-on-linux-when-using-glibc.patch b/meta/recipes-sato/webkit/webkitgtk/0001-Enable-backtrace-on-linux-when-using-glibc.patch
new file mode 100644
index 0000000..146087b
--- /dev/null
+++ b/meta/recipes-sato/webkit/webkitgtk/0001-Enable-backtrace-on-linux-when-using-glibc.patch
@@ -0,0 +1,39 @@
+From 0b68ad206d2d90df78d91cad4da19152084014cf Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 16 Sep 2015 05:15:04 +0000
+Subject: [PATCH] Enable backtrace on linux when using glibc
+
+We dont have backtrace() implemented on non-glibc libc's on linux
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Pending
+
+ Source/WTF/wtf/Assertions.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Source/WTF/wtf/Assertions.cpp b/Source/WTF/wtf/Assertions.cpp
+index 191d53f..a4d86b5 100644
+--- a/Source/WTF/wtf/Assertions.cpp
++++ b/Source/WTF/wtf/Assertions.cpp
+@@ -68,7 +68,7 @@
+ #include <unistd.h>
+ #endif
+
+-#if OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))
++#if OS(DARWIN) || (OS(LINUX) && defined(__GLIBC__) && !defined(__UCLIBC__))
+ #include <cxxabi.h>
+ #include <dlfcn.h>
+ #include <execinfo.h>
+@@ -225,7 +225,7 @@ void WTFReportArgumentAssertionFailure(const char* file, int line, const char* f
+
+ void WTFGetBacktrace(void** stack, int* size)
+ {
+-#if OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))
++#if OS(DARWIN) || (OS(LINUX) && defined(__GLIBC__) && !defined(__UCLIBC__))
+ *size = backtrace(stack, *size);
+ #elif OS(WINDOWS)
+ // The CaptureStackBackTrace function is available in XP, but it is not defined
+--
+2.5.2
+
diff --git a/meta/recipes-sato/webkit/webkitgtk/clang.patch b/meta/recipes-sato/webkit/webkitgtk/clang.patch
new file mode 100644
index 0000000..ef77755
--- /dev/null
+++ b/meta/recipes-sato/webkit/webkitgtk/clang.patch
@@ -0,0 +1,25 @@
+Clang's builtin for clear_cache accepts char* and errors out when using void*,
+using char* work on both gcc and clang since char* is auto-converted to void* in gcc case
+
+Source/JavaScriptCore/assembler/ARM64Assembler.h:2857:33: error: cannot initialize a parameter of type 'char *' with an rvalue of type 'void *'
+ __builtin___clear_cache(reinterpret_cast<void*>(begin), reinterpret_cast<void*>(end));
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+1 error generated.
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Upstream-Status: Pending
+
+Index: webkitgtk-2.8.5/Source/JavaScriptCore/assembler/ARM64Assembler.h
+===================================================================
+--- webkitgtk-2.8.5.orig/Source/JavaScriptCore/assembler/ARM64Assembler.h
++++ webkitgtk-2.8.5/Source/JavaScriptCore/assembler/ARM64Assembler.h
+@@ -2854,7 +2854,7 @@ public:
+ #if OS(LINUX) && COMPILER(GCC)
+ static inline void linuxPageFlush(uintptr_t begin, uintptr_t end)
+ {
+- __builtin___clear_cache(reinterpret_cast<void*>(begin), reinterpret_cast<void*>(end));
++ __builtin___clear_cache(reinterpret_cast<char*>(begin), reinterpret_cast<char*>(end));
+ }
+ #endif
+
diff --git a/meta/recipes-sato/webkit/webkitgtk_2.10.4.bb b/meta/recipes-sato/webkit/webkitgtk_2.10.4.bb
index 4d5aeb4..f5add32 100644
--- a/meta/recipes-sato/webkit/webkitgtk_2.10.4.bb
+++ b/meta/recipes-sato/webkit/webkitgtk_2.10.4.bb
@@ -12,6 +12,8 @@ LIC_FILES_CHKSUM = "file://Source/JavaScriptCore/COPYING.LIB;md5=d0c6d6397a5d842

SRC_URI = "\
http://www.webkitgtk.org/releases/${BPN}-${PV}.tar.xz \
+ file://clang.patch \
+ file://0001-Enable-backtrace-on-linux-when-using-glibc.patch \
"
SRC_URI[md5sum] = "fb010031c6f61c3a1a00793b112badb5"
SRC_URI[sha256sum] = "dbf8260da5cac0c74de2d3cce1fe7c519da3cd816a2c769cb6c6d56addd2f055"
--
2.7.0