package: qtwebkit: support riscv

Signed-off-by: Andy Hu <andy.hu@starfivetech.com>
This commit is contained in:
Andy Hu
2023-07-24 11:20:59 +08:00
parent 2c1e4a5861
commit 69a5fdf298
3 changed files with 243 additions and 0 deletions
@@ -0,0 +1,96 @@
From ec4c0b5e652ce1080c72e9f527af6c586925ba6f Mon Sep 17 00:00:00 2001
From: Andy Hu <andy.hu@starfivetech.com>
Date: Wed, 12 Jul 2023 12:29:11 +0800
Subject: [PATCH 1/2] add riscv support
---
Source/JavaScriptCore/CMakeLists.txt | 1 +
Source/WTF/wtf/Platform.h | 12 ++++++++++--
Source/WTF/wtf/dtoa/utils.h | 6 +++---
3 files changed, 14 insertions(+), 5 deletions(-)
mode change 100644 => 100755 Source/JavaScriptCore/CMakeLists.txt
mode change 100644 => 100755 Source/WTF/wtf/Platform.h
mode change 100644 => 100755 Source/WTF/wtf/dtoa/utils.h
diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt
old mode 100644
new mode 100755
index 73917eb5..479b7d3c
--- a/Source/JavaScriptCore/CMakeLists.txt
+++ b/Source/JavaScriptCore/CMakeLists.txt
@@ -535,6 +535,7 @@ if (WTF_CPU_ARM)
list(APPEND JavaScriptCore_SOURCES ${DERIVED_SOURCES_DIR}/GeneratedJITStubs.obj)
endif ()
+elseif (WTF_CPU_RISCV64)
elseif (WTF_CPU_MIPS)
elseif (WTF_CPU_X86)
elseif (WTF_CPU_X86_64)
diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
old mode 100644
new mode 100755
index 9cf65684..e3956824
--- a/Source/WTF/wtf/Platform.h
+++ b/Source/WTF/wtf/Platform.h
@@ -357,7 +357,14 @@
#endif
#endif
-#if CPU(ARM) || CPU(MIPS) || CPU(SH4) || CPU(SPARC) || CPU(MIPS64)
+#if defined(__riscv)
+#define WTF_CPU_RISCV 1
+#if __riscv_xlen == 64
+#define WTF_CPU_RISCV64 1
+#endif
+#endif
+
+#if CPU(ARM) || CPU(MIPS) || CPU(SH4) || CPU(SPARC) || CPU(MIPS64) || CPU(RISCV)
#define WTF_CPU_NEEDS_ALIGNED_ACCESS 1
#endif
@@ -761,7 +768,8 @@
|| CPU(S390X) \
|| CPU(AARCH64) \
|| CPU(MIPS64) \
- || CPU(PPC64)
+ || CPU(PPC64) \
+ || CPU(RISCV64)
#define WTF_USE_JSVALUE64 1
#else
#define WTF_USE_JSVALUE32_64 1
diff --git a/Source/WTF/wtf/dtoa/utils.h b/Source/WTF/wtf/dtoa/utils.h
old mode 100644
new mode 100755
index 298bf4d9..07032773
--- a/Source/WTF/wtf/dtoa/utils.h
+++ b/Source/WTF/wtf/dtoa/utils.h
@@ -49,7 +49,7 @@
defined(__ARMEL__) || \
defined(_MIPS_ARCH_MIPS32R2)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
-#elif CPU(MIPS) || CPU(PPC) || CPU(PPC64) || OS(WINCE) || CPU(SH4) || CPU(S390) || CPU(S390X) || CPU(IA64) || CPU(SPARC) || CPU(ALPHA) || CPU(MIPS64) || CPU(AARCH64) || CPU(HPPA)
+#elif CPU(MIPS) || CPU(PPC) || CPU(PPC64) || OS(WINCE) || CPU(SH4) || CPU(S390) || CPU(S390X) || CPU(IA64) || CPU(SPARC) || CPU(ALPHA) || CPU(MIPS64) || CPU(AARCH64) || CPU(HPPA) || CPU(RISCV)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(_M_IX86) || defined(__i386__)
#if defined(_WIN32)
@@ -151,7 +151,7 @@ namespace double_conversion {
// spanning from and including 'from', to but not including 'to'.
BufferReference<T> SubBufferReference(int from, int to) {
ASSERT(to <= length_);
- ASSERT(from < to);
+ ASSERT_WITH_SECURITY_IMPLICATION(from < to);
ASSERT(0 <= from);
return BufferReference<T>(start() + from, to - from);
}
@@ -292,7 +292,7 @@ namespace double_conversion {
inline Dest BitCast(const Source& source) {
// Compile time assertion: sizeof(Dest) == sizeof(Source)
// A compile error here means your Dest and Source have different sizes.
- typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
+ static_assert(sizeof(Dest) == sizeof(Source), "Source and destination sizes must be equal");
Dest dest;
memcpy(&dest, &source, sizeof(dest));
--
2.41.0
@@ -0,0 +1,122 @@
From 9770a62d43bce6381fe9d047146eb271be3c5ce1 Mon Sep 17 00:00:00 2001
From: Andy Hu <andy.hu@starfivetech.com>
Date: Wed, 12 Jul 2023 12:31:50 +0800
Subject: [PATCH 2/2] fix the compile gobject issue
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
/space/code/visionfive_qtwebkit/work/buildroot_initramfs/host/riscv64-buildroot-linux-gnu/sysroot/usr/include/glib-2.0/glib/gmacros.h:247:24: error: expected unqualified-id before typename
247 | #define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
| ^~~~~~~~
/space/code/visionfive_qtwebkit/work/buildroot_initramfs/host/riscv64-buildroot-linux-gnu/sysroot/usr/include/glib-2.0/gobject/gobject.h:524:34: note: in expansion of macro glib_typeof
524 | #define g_object_ref_sink(Obj) ((glib_typeof (Obj)) (g_object_ref_sink) (Obj))
| ^~~~~~~~~~~
../WTF/wtf/gobject/GRefPtr.h:32:21: note: in expansion of macro g_object_ref_sink
32 | extern C gpointer g_object_ref_sink(gpointer);
---
Source/WTF/wtf/dtoa/strtod.cc | 13 ++++++++++---
Source/WTF/wtf/gobject/GRefPtr.h | 6 ++++--
include/QtWebKit/QtWebKit | 1 +
3 files changed, 15 insertions(+), 5 deletions(-)
mode change 100644 => 100755 Source/WTF/wtf/dtoa/strtod.cc
diff --git a/Source/WTF/wtf/dtoa/strtod.cc b/Source/WTF/wtf/dtoa/strtod.cc
old mode 100644
new mode 100755
index 5f63b22a..5270c3e5
--- a/Source/WTF/wtf/dtoa/strtod.cc
+++ b/Source/WTF/wtf/dtoa/strtod.cc
@@ -38,11 +38,13 @@
namespace WTF {
namespace double_conversion {
-
+
+#if defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
// 2^53 = 9007199254740992.
// Any integer with at most 15 decimal digits will hence fit into a double
// (which has a 53bit significand) without loss of precision.
static const int kMaxExactDoubleIntegerDecimalDigits = 15;
+#endif
// 2^64 = 18446744073709551616 > 10^19
static const int kMaxUint64DecimalDigits = 19;
@@ -58,7 +60,7 @@ namespace double_conversion {
// 2^64 = 18446744073709551616
static const uint64_t kMaxUint64 = UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF);
-
+#if defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
static const double exact_powers_of_ten[] = {
1.0, // 10^0
10.0,
@@ -86,6 +88,7 @@ namespace double_conversion {
10000000000000000000000.0
};
static const int kExactPowersOfTenSize = ARRAY_SIZE(exact_powers_of_ten);
+#endif
// Maximum number of significant digits in the decimal representation.
// In fact the value is 772 (see conversions.cc), but to give us some margin
@@ -177,6 +180,9 @@ namespace double_conversion {
int exponent,
double* result) {
#if !defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
+ UNUSED_PARAM(trimmed);
+ UNUSED_PARAM(exponent);
+ UNUSED_PARAM(result);
// On x86 the floating-point stack can be 64 or 80 bits wide. If it is
// 80 bits wide (as is the case on Linux) then double-rounding occurs and the
// result is not accurate.
@@ -184,7 +190,7 @@ namespace double_conversion {
// Note that the ARM simulator is compiled for 32bits. It therefore exhibits
// the same problem.
return false;
-#endif
+#else
if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) {
int read_digits;
// The trimmed input fits into a double.
@@ -222,6 +228,7 @@ namespace double_conversion {
}
}
return false;
+#endif
}
diff --git a/Source/WTF/wtf/gobject/GRefPtr.h b/Source/WTF/wtf/gobject/GRefPtr.h
index 6c50f4da..2715df86 100644
--- a/Source/WTF/wtf/gobject/GRefPtr.h
+++ b/Source/WTF/wtf/gobject/GRefPtr.h
@@ -25,11 +25,13 @@
#if USE(GLIB)
+#include <glib-object.h>
+
#include <wtf/RefPtr.h>
#include <algorithm>
-extern "C" void g_object_unref(gpointer);
-extern "C" gpointer g_object_ref_sink(gpointer);
+//extern "C" void g_object_unref(gpointer);
+//extern "C" gpointer g_object_ref_sink(gpointer);
namespace WTF {
diff --git a/include/QtWebKit/QtWebKit b/include/QtWebKit/QtWebKit
index 9bc17d32..8b162a5f 100644
--- a/include/QtWebKit/QtWebKit
+++ b/include/QtWebKit/QtWebKit
@@ -10,5 +10,6 @@
#include "qwebpluginfactory.h"
#include "qwebsecurityorigin.h"
#include "qwebsettings.h"
+#include "util.h"
#include "qtwebkitversion.h"
#endif
--
2.41.0
@@ -0,0 +1,25 @@
From e86ba68cddb9bcae8c63885af810d3563907d087 Mon Sep 17 00:00:00 2001
From: Andy Hu <andy.hu@starfivetech.com>
Date: Wed, 12 Jul 2023 19:39:13 +0800
Subject: [PATCH] Fix the qt5webkit-example compile issue
when compile qt5webkit-example had the below issue:
work/buildroot_initramfs/host/riscv64-buildroot-linux-gnu/sysroot/usr/include/qt5/QtWebKit/QtWebKit:13:10: fatal error: util.h: No such file or directory
---
include/QtWebKit/QtWebKit | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/QtWebKit/QtWebKit b/include/QtWebKit/QtWebKit
index 8b162a5f..9bc17d32 100644
--- a/include/QtWebKit/QtWebKit
+++ b/include/QtWebKit/QtWebKit
@@ -10,6 +10,5 @@
#include "qwebpluginfactory.h"
#include "qwebsecurityorigin.h"
#include "qwebsettings.h"
-#include "util.h"
#include "qtwebkitversion.h"
#endif
--
2.41.0