Skip to content

Commit 4aa3e10

Browse files
committed
riscv64 CI job
Signed-off-by: Joel Winarske <[email protected]>
1 parent b1e622f commit 4aa3e10

6 files changed

+294
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Linux riscv64
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize, reopened, closed ]
6+
release:
7+
types: [ published, created, edited ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
linux-riscv64:
12+
13+
env:
14+
# TODO - hard coded for now
15+
SRCREV: "c9b9d5780da342eb3f0f5e439a7db06f7d112575"
16+
17+
runs-on: [self-hosted, linux, x64]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
24+
- name: Install packages
25+
run: |
26+
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
27+
28+
- name: Get Flutter Source
29+
run: |
30+
rm -rf out/linux_debug_riscv64|true
31+
rm -rf out/linux_release_riscv64|true
32+
rm -rf out/linux_profile_riscv64|true
33+
34+
export PATH=$PATH:$PWD/depot_tools
35+
export VPYTHON_VIRTUALENV_ROOT=$PWD/vpython
36+
gclient config --spec 'solutions=[{"name":"src/flutter","url":"https://github.com/flutter/engine.git","deps_file":"DEPS","managed":False,"custom_deps":{},"custom_vars":{"download_android_deps":False,"download_windows_deps":False,"download_linux_deps":True}}]'
37+
gclient sync --force --shallow --no-history -R -D --revision $SRCREV -j$(nproc) -v
38+
39+
PATCH_DIR=$PWD/patches
40+
41+
# fetch arm64 sysroot
42+
cd src
43+
44+
# setting system_libdir in args.gn does not work
45+
git apply $PATCH_DIR/riscv64/0001-system-libdir.patch
46+
47+
git apply $PATCH_DIR/0001-clang-toolchain.patch
48+
cd flutter
49+
git apply $PATCH_DIR/0001-export-GPU-symbols.patch
50+
51+
git apply $PATCH_DIR/riscv64/0001-gn-riscv32-and-riscv64.patch
52+
git apply $PATCH_DIR/riscv64/0002-fml-build-config-add-riscv.patch
53+
git apply $PATCH_DIR/riscv64/0003-swiftshader-riscv-support.patch
54+
git apply $PATCH_DIR/riscv64/0004-tonic-riscv-support.patch
55+
56+
- name: Fetch sysroot & toolchain
57+
working-directory: src/build/linux
58+
run: |
59+
rm -rf debian_sid_riscv64-sysroot |true
60+
curl -L "https://drive.usercontent.google.com/download?id=1YM1OR7d_Z7KibqcUHVWuufqhsQlmH3qg&confirm=xxx" -o debian_sid_riscv64-sysroot.tar.gz
61+
mkdir -p debian_sid_riscv64-sysroot
62+
tar -xvzf debian_sid_riscv64-sysroot.tar.gz -C debian_sid_riscv64-sysroot
63+
rm debian_sid_riscv64-sysroot.tar.gz
64+
65+
cd ../../flutter/buildtools/linux-x64
66+
67+
rm -rf recipe-sysroot-native |true
68+
curl -L "https://drive.usercontent.google.com/download?id=1gdV-1dJ4HD-EMWdFGAXKJwi8sFWnM1Qq&confirm=xxx" -o recipe-sysroot-native.tar.gz
69+
tar -xvzf recipe-sysroot-native.tar.gz -C .
70+
rm recipe-sysroot-native.tar.gz
71+
72+
- name: Build Debug
73+
working-directory: src
74+
run: |
75+
export PATH=$PATH:$PWD/../depot_tools
76+
export VPYTHON_VIRTUALENV_ROOT=$PWD/vpython
77+
./flutter/tools/gn --runtime-mode=debug \
78+
--embedder-for-target \
79+
--no-build-embedder-examples \
80+
--enable-impeller-3d \
81+
--no-goma --no-rbe \
82+
--no-stripped --no-enable-unittests \
83+
--no-prebuilt-dart-sdk \
84+
--linux-cpu riscv64 \
85+
--target-os linux \
86+
--target-sysroot $PWD/build/linux/debian_sid_riscv64-sysroot \
87+
--target-toolchain $PWD/flutter/buildtools/linux-x64/recipe-sysroot-native/usr \
88+
--target-triple riscv64-unknown-linux-gnu
89+
90+
ninja -C out/linux_debug_riscv64
91+
92+
- name: Publish Debug
93+
working-directory: src/out/linux_debug_riscv64
94+
run: |
95+
ls -laR exe.unstripped
96+
ls -la *.so
97+
98+
- name: Build Release
99+
working-directory: src
100+
run: |
101+
export PATH=$PATH:$PWD/../depot_tools
102+
export VPYTHON_VIRTUALENV_ROOT=$PWD/vpython
103+
./flutter/tools/gn --runtime-mode=release \
104+
--embedder-for-target \
105+
--no-build-embedder-examples \
106+
--enable-impeller-3d \
107+
--no-goma --no-rbe \
108+
--no-stripped --no-enable-unittests \
109+
--no-prebuilt-dart-sdk \
110+
--linux-cpu riscv64 \
111+
--target-os linux \
112+
--target-sysroot $PWD/build/linux/debian_sid_riscv64-sysroot \
113+
--target-toolchain $PWD/flutter/buildtools/linux-x64/recipe-sysroot-native/usr \
114+
--target-triple riscv64-unknown-linux-gnu
115+
116+
ninja -C out/linux_release_riscv64
117+
118+
- name: Publish Release
119+
working-directory: src/out/linux_release_riscv64
120+
run: |
121+
ls -laR exe.unstripped
122+
ls -la *.so
123+
124+
- name: Build Profile
125+
working-directory: src
126+
run: |
127+
export PATH=$PATH:$PWD/../depot_tools
128+
export VPYTHON_VIRTUALENV_ROOT=$PWD/vpython
129+
./flutter/tools/gn --runtime-mode=profile \
130+
--embedder-for-target \
131+
--no-build-embedder-examples \
132+
--enable-impeller-3d \
133+
--no-goma --no-rbe \
134+
--no-stripped --no-enable-unittests \
135+
--no-prebuilt-dart-sdk \
136+
--linux-cpu riscv64 \
137+
--target-os linux \
138+
--target-sysroot $PWD/build/linux/debian_sid_riscv64-sysroot \
139+
--target-toolchain $PWD/flutter/buildtools/linux-x64/recipe-sysroot-native/usr \
140+
--target-triple riscv64-unknown-linux-gnu
141+
142+
ninja -C out/linux_profile_riscv64
143+
144+
- name: Publish Profile
145+
working-directory: src/out/linux_profile_riscv64
146+
run: |
147+
ls -laR exe.unstripped
148+
ls -la *.so
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 748e416e394552cac6e4be30112c3ef45d1c0ec3 Mon Sep 17 00:00:00 2001
2+
From: Joel Winarske <[email protected]>
3+
Date: Tue, 6 Aug 2024 08:03:59 -0700
4+
Subject: [PATCH] gn riscv32 and riscv64
5+
6+
Signed-off-by: Joel Winarske <[email protected]>
7+
---
8+
tools/gn | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/tools/gn b/tools/gn
12+
index 0be76e5477..8fee233aed 100755
13+
--- a/tools/gn
14+
+++ b/tools/gn
15+
@@ -1015,7 +1015,7 @@ def parse_args(args):
16+
parser.add_argument('--web', action='store_true', default=False)
17+
parser.add_argument('--windows', dest='target_os', action='store_const', const='win')
18+
19+
- parser.add_argument('--linux-cpu', type=str, choices=['x64', 'x86', 'arm64', 'arm'])
20+
+ parser.add_argument('--linux-cpu', type=str, choices=['x64', 'x86', 'arm64', 'arm', 'riscv32', 'riscv64'])
21+
parser.add_argument('--fuchsia-cpu', type=str, choices=['x64', 'arm64'], default='x64')
22+
parser.add_argument('--windows-cpu', type=str, choices=['x64', 'arm64', 'x86'], default='x64')
23+
parser.add_argument('--simulator-cpu', type=str, choices=['x64', 'arm64'], default='x64')
24+
--
25+
2.45.2
26+
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 2dea579a9473d42a99fafbe79e893d49ed4475bb Mon Sep 17 00:00:00 2001
2+
From: Joel Winarske <[email protected]>
3+
Date: Tue, 27 Aug 2024 14:17:06 -0700
4+
Subject: [PATCH] system libdir
5+
6+
Signed-off-by: Joel Winarske <[email protected]>
7+
---
8+
build/config/linux/pkg_config.gni | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/build/config/linux/pkg_config.gni b/build/config/linux/pkg_config.gni
12+
index 3deef2b..82d0f97 100644
13+
--- a/build/config/linux/pkg_config.gni
14+
+++ b/build/config/linux/pkg_config.gni
15+
@@ -44,7 +44,7 @@ declare_args() {
16+
# chrome build scheme. This variable permits controlling this for GN builds
17+
# in similar fashion by setting the `system_libdir` variable in the build's
18+
# args.gn file to 'lib' or 'lib64' as appropriate for the target architecture.
19+
- system_libdir = "lib"
20+
+ system_libdir = "lib/riscv64-linux-gnu"
21+
}
22+
23+
pkg_config_script = "//build/config/linux/pkg-config.py"
24+
--
25+
2.25.1
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From 8b34fbdace418dcf338492ac63ce1048ecc20bf5 Mon Sep 17 00:00:00 2001
2+
From: Joel Winarske <[email protected]>
3+
Date: Wed, 13 Mar 2024 21:28:43 +0000
4+
Subject: [PATCH] fml build config add riscv
5+
6+
Signed-off-by: Joel Winarske <[email protected]>
7+
---
8+
fml/build_config.h | 10 ++++++++++
9+
1 file changed, 10 insertions(+)
10+
11+
diff --git a/fml/build_config.h b/fml/build_config.h
12+
index d42a88e..9ee6e04 100644
13+
--- a/fml/build_config.h
14+
+++ b/fml/build_config.h
15+
@@ -93,6 +93,16 @@
16+
#define FML_ARCH_CPU_ARM64 1
17+
#define FML_ARCH_CPU_64_BITS 1
18+
#define FML_ARCH_CPU_LITTLE_ENDIAN 1
19+
+#elif defined(__riscv)
20+
+#define FML_ARCH_CPU_RISC_FAMILY 1
21+
+#if (__riscv_xlen == 32)
22+
+#define FML_ARCH_CPU_RISCV32 1
23+
+#define FML_ARCH_CPU_32_BITS 1
24+
+#elif (__riscv_xlen == 64)
25+
+#define FML_ARCH_CPU_RISCV64 1
26+
+#define FML_ARCH_CPU_64_BITS 1
27+
+#endif
28+
+#define FML_ARCH_CPU_LITTLE_ENDIAN 1
29+
#elif defined(__pnacl__)
30+
#define FML_ARCH_CPU_32_BITS 1
31+
#define FML_ARCH_CPU_LITTLE_ENDIAN 1
32+
--
33+
2.44.0
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 9d3788480dba3dcc27cd00d4852c968b0e5de502 Mon Sep 17 00:00:00 2001
2+
From: Joel Winarske <[email protected]>
3+
Date: Sun, 4 Aug 2024 20:41:17 +0000
4+
Subject: [PATCH] swiftshader-riscv
5+
6+
Signed-off-by: Joel Winarske <[email protected]>
7+
---
8+
third_party/swiftshader/src/Reactor/BUILD.gn | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/third_party/swiftshader/src/Reactor/BUILD.gn b/third_party/swiftshader/src/Reactor/BUILD.gn
12+
index 67dfeb0..dcb1361 100644
13+
--- a/third_party/swiftshader/src/Reactor/BUILD.gn
14+
+++ b/third_party/swiftshader/src/Reactor/BUILD.gn
15+
@@ -307,7 +307,7 @@ if (supports_subzero) {
16+
17+
if (supports_llvm) {
18+
swiftshader_source_set("swiftshader_llvm_reactor") {
19+
- llvm_dir = "../../third_party/llvm-10.0"
20+
+ llvm_dir = "../../third_party/llvm-16.0"
21+
22+
deps = [
23+
":swiftshader_reactor_base",
24+
--
25+
2.45.2
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From 9be5e09115a693ab7fc8cee2122d0a4318fc6e71 Mon Sep 17 00:00:00 2001
2+
From: Joel Winarske <[email protected]>
3+
Date: Sun, 4 Aug 2024 20:53:56 +0000
4+
Subject: [PATCH] tonic riscv support
5+
6+
Signed-off-by: Joel Winarske <[email protected]>
7+
---
8+
third_party/tonic/common/build_config.h | 10 ++++++++++
9+
1 file changed, 10 insertions(+)
10+
11+
diff --git a/third_party/tonic/common/build_config.h b/third_party/tonic/common/build_config.h
12+
index 365808a1a7..f3edb471be 100644
13+
--- a/third_party/tonic/common/build_config.h
14+
+++ b/third_party/tonic/common/build_config.h
15+
@@ -88,6 +88,16 @@
16+
#define ARCH_CPU_ARM64 1
17+
#define ARCH_CPU_64_BITS 1
18+
#define ARCH_CPU_LITTLE_ENDIAN 1
19+
+#elif defined(__riscv)
20+
+#define FML_ARCH_CPU_RISC_FAMILY 1
21+
+#if (__riscv_xlen == 32)
22+
+#define ARCH_CPU_RISCV32 1
23+
+#define ARCH_CPU_32_BITS 1
24+
+#elif (__riscv_xlen == 64)
25+
+#define ARCH_CPU_RISCV64 1
26+
+#define ARCH_CPU_64_BITS 1
27+
+#endif
28+
+#define ARCH_CPU_LITTLE_ENDIAN 1
29+
#elif defined(__pnacl__)
30+
#define ARCH_CPU_32_BITS 1
31+
#define ARCH_CPU_LITTLE_ENDIAN 1
32+
--
33+
2.45.2
34+

0 commit comments

Comments
 (0)