Browse Source

Added v8 10.2.154.13 source and patches

Clement 1 year ago
parent
commit
6114b0f1f9

+ 51 - 0
v8/README.md

@@ -0,0 +1,51 @@
+===v8 10.2.154.13 Cross-compiling===
+
+Reference doc: https://github.com/riscv-collab/v8/wiki/Get-the-Source
+
+1. Install depot_tools and add it into your PATH.
+2. Then, create a new folder and 'fetch v8' in the directory, example as below:
+    $ mkdir v8-cr
+    $ cd v8-cr
+    $ fetch v8
+
+3. Git checkout into the version that we wanted:
+    $ git checkout 10.2.154.13
+
+Alternatively, you can use exisiting source code:
+    $ cd v8-10.2.154.13
+
+4. Then, run the following so that the gclient tool will retrieve the dependencies that match to this particular branch.
+    $ cd v8-cr/v8
+    $ gclient sync --with_branch_heads --with_tags
+
+5. Prepare RISC-V Toolchain and add the toolchain path to PATH:
+
+    $ export PATH="<toolchain_path>:$PATH"
+
+
+The following files are need to be made:
+
+6. Go to 'build/toolchain/linux/BUILD.gn', change "riscv64-linux-gnu" to "riscv64-unknown-linux-gnu" (Around line 302)
+
+gcc_toolchain("riscv64") {
+-  toolprefix = "riscv64-linux-gnu"
++  toolprefix = "riscv64-unknown-linux-gnu"
+
+  cc = "${toolprefix}-gcc"
+  cxx = "${toolprefix}-g++"
+
+
+7. Apply the following patches:
+    $ git apply 0001-riscv64-disable-fp-multiply-and-accumulate-instructi.patch
+    $ git apply 0002-riscv64-fix-the-staticstackframesize.patch
+
+8. Use gn to configure the build as such:
+
+    $ gn gen out/riscv64.native.release --args='is_component_build=false is_debug=false target_cpu="riscv64" v8_target_cpu="riscv64" use_goma=false goma_dir="None" treat_warnings_as_errors=false v8_use_external_startup_data=false'
+
+9. Build with ninja:
+
+    $ ninja -C out/riscv64.native.release -j32
+
+
+10. Output files will be in out/riscv64.native.release.

+ 31 - 0
v8/patch/0001-riscv64-disable-fp-multiply-and-accumulate-instructi.patch

@@ -0,0 +1,31 @@
+From 4a599374d97dc4402ddc00171e388df6df21265c Mon Sep 17 00:00:00 2001
+From: JY <junyuan.tan@starfivetech.com>
+Date: Mon, 14 Nov 2022 10:39:16 +0800
+Subject: [PATCH 1/1] [riscv64]  disable fp multiply and accumulate
+ instructions
+
+Some wasm interpreter tests are failing since instructions generated
+by gcc such as *multiply and and* (fmadds) create intermediate
+results bigger than 8 bytes which doesn't match other architectures,
+hence the resulting output differs.
+
+Port commit 13314a207e2b22a10c72bfa83f985c7ff144c775
+---
+ BUILD.gn | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/BUILD.gn b/BUILD.gn
+index 988c907d96..fff48825e0 100644
+--- a/BUILD.gn
++++ b/BUILD.gn
+@@ -1009,6 +1009,7 @@ config("toolchain") {
+   cflags = []
+   ldflags = []
+ 
++  cflags += ["-ffp-contract=off"]
+   if (v8_current_cpu == "arm") {
+     defines += [ "V8_TARGET_ARCH_ARM" ]
+     if (arm_version >= 7) {
+-- 
+2.25.1
+

+ 30 - 0
v8/patch/0002-riscv64-fix-the-staticstackframesize.patch

@@ -0,0 +1,30 @@
+From 70caf337c3f69b16ac9ffec0d9a776aa95f896fc Mon Sep 17 00:00:00 2001
+From: Lu Yahan <yahan@iscas.ac.cn>
+Date: Thu, 14 Apr 2022 11:32:59 +0800
+Subject: [PATCH] [riscv64] Fix the StaticStackFrameSize
+
+ Update the size to kTierupBudgetOffset.
+
+Change-Id: Ibe241211ef67148fae3a4a9eed271f9293ca4801
+Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3585492
+Reviewed-by: ji qiu <qiuji@iscas.ac.cn>
+Commit-Queue: Yahan Lu <yahan@iscas.ac.cn>
+Auto-Submit: Yahan Lu <yahan@iscas.ac.cn>
+Cr-Commit-Position: refs/heads/main@{#79978}
+---
+ src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h b/src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h
+index 642a7d2a335..8d7ef96f3ad 100644
+--- a/src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h
++++ b/src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h
+@@ -393,7 +393,7 @@ void LiftoffAssembler::AbortCompilation() { AbortedCodeGeneration(); }
+ 
+ // static
+ constexpr int LiftoffAssembler::StaticStackFrameSize() {
+-  return liftoff::kFeedbackVectorOffset;
++  return liftoff::kTierupBudgetOffset;
+ }
+ 
+ int LiftoffAssembler::SlotSizeForType(ValueKind kind) {

+ 1 - 0
v8/v8

@@ -0,0 +1 @@
+Subproject commit 7dfc4b52b039fac12a8dc79b8dabb8cd7b4daf16