Skip to content

Commit ade1223

Browse files
authored
Add support for RISC-V (#13670)
Motivation: RISC-V is gaining traction across the industry and many projects rely on Netty. To run these projects, Netty needs to support RISC-V. Modifications: Mostly build scripts and CI files. CentOS doesn't have packages with recent-enough versions for autoconf, automake, libtool, and the GNU compiler toolchain. Result: Fixes #13667 linux-riscv64 packages are created in a similar manner to linux-aarch64 packages.
1 parent e2c706a commit ade1223

19 files changed

Lines changed: 413 additions & 12 deletions

File tree

.github/workflows/ci-deploy.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
- setup: linux-aarch64
4343
docker-compose-build: "-f docker/docker-compose.centos-7.yaml build"
4444
docker-compose-run: "-f docker/docker-compose.centos-7.yaml run cross-compile-aarch64-stage-snapshot"
45+
- setup: linux-riscv64
46+
docker-compose-build: "-f docker/docker-compose.ubuntu-20.04.yaml build"
47+
docker-compose-run: "-f docker/docker-compose.ubuntu-20.04.yaml run cross-compile-riscv64-stage-snapshot"
4548

4649
name: stage-snapshot-${{ matrix.setup }}
4750
steps:
@@ -111,6 +114,12 @@ jobs:
111114
name: linux-aarch64-local-staging
112115
path: ~/linux-aarch64-local-staging
113116

117+
- name: Download linux-riscv64 staging directory
118+
uses: actions/download-artifact@v3
119+
with:
120+
name: linux-riscv64-local-staging
121+
path: ~/linux-riscv64-local-staging
122+
114123
- name: Download linux-x86_64-java8 staging directory
115124
uses: actions/download-artifact@v3
116125
with:
@@ -122,6 +131,8 @@ jobs:
122131
mkdir -p ~/local-staging/deferred
123132
cat ~/linux-aarch64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
124133
cp -r ~/linux-aarch64-local-staging/deferred/* ~/local-staging/deferred/
134+
cat ~/linux-riscv64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
135+
cp -r ~/linux-riscv64-local-staging/deferred/* ~/local-staging/deferred/
125136
cat ~/linux-x86_64-java8-local-staging/deferred/.index >> ~/local-staging/deferred/.index
126137
cp -r ~/linux-x86_64-java8-local-staging/deferred/* ~/local-staging/deferred/
127138

.github/workflows/ci-pr.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,17 @@ jobs:
104104
**/target/surefire-reports/
105105
**/hs_err*.log
106106
107-
build-pr-aarch64:
108-
name: linux-aarch64-verify-native
107+
build-pr-cross:
109108
# The host should always be Linux
110109
runs-on: ubuntu-20.04
110+
strategy:
111+
matrix:
112+
include:
113+
- arch: aarch64
114+
java_arch: arm64
115+
- arch: riscv64
116+
117+
name: linux-${{ matrix.arch }}-verify-native
111118
permissions:
112119
contents: read # for actions/checkout to fetch code
113120
packages: write # for uraimo/run-on-arch-action to cache docker images
@@ -121,16 +128,16 @@ jobs:
121128
continue-on-error: true
122129
with:
123130
path: ~/.m2/repository
124-
key: ${{ runner.os }}-maven-build-pr-aarch64-${{ hashFiles('**/pom.xml') }}
131+
key: ${{ runner.os }}-maven-build-pr-${{ matrix.arch }}-${{ hashFiles('**/pom.xml') }}
125132
restore-keys: |
126-
${{ runner.os }}-maven-build-pr-aarch64-
133+
${{ runner.os }}-maven-build-pr-${{ matrix.arch }}-
127134
${{ runner.os }}-maven-
128135
129136
- uses: uraimo/run-on-arch-action@v2.5.1
130137
name: Run commands
131138
id: runcmd
132139
with:
133-
arch: aarch64
140+
arch: ${{ matrix.arch }}
134141
distro: ubuntu20.04
135142

136143
# Not required, but speeds up builds by storing container images in
@@ -147,11 +154,11 @@ jobs:
147154
apt-get install -q -y openjdk-11-jdk autoconf automake libtool make tar maven git
148155
149156
# Compile native code and the modules it depend on and run NativeLoadingTest. This is enough to ensure
150-
# we can load the native module on aarch64
157+
# we can load the native module on ${{ matrix.arch }}
151158
#
152159
# Use tcnative.classifier that is empty as we don't support using the shared lib version on ubuntu.
153160
run: |
154-
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64 ./mvnw -B -ntp -pl testsuite-native -am clean package -DskipTests=true -Dcheckstyle.skip=true -DskipNativeTestsuite=false -Dtcnative.classifier=
161+
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-${{ matrix.java_arch || matrix.arch }} ./mvnw -V -B -ntp -pl testsuite-native -am clean package -DskipTests=true -Dcheckstyle.skip=true -DskipNativeTestsuite=false -Dtcnative.classifier=
155162
156163
build-pr:
157164
runs-on: ubuntu-latest

.github/workflows/ci-release-5.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ jobs:
8787
- setup: linux-aarch64
8888
docker-compose-build: "-f docker/docker-compose.centos-7.yaml build"
8989
docker-compose-run: "-f docker/docker-compose.centos-7.yaml run cross-compile-aarch64-stage-release"
90+
- setup: linux-riscv64
91+
docker-compose-build: "-f docker/docker-compose.ubuntu-20.04.yaml build"
92+
docker-compose-run: "-f docker/docker-compose.ubuntu-20.04.yaml run cross-compile-riscv64-stage-release"
9093

9194
name: stage-release-${{ matrix.setup }}
9295

@@ -204,6 +207,12 @@ jobs:
204207
name: linux-aarch64-local-staging
205208
path: ~/linux-aarch64-local-staging
206209

210+
- name: Download linux-riscv64 staging directory
211+
uses: actions/download-artifact@v3
212+
with:
213+
name: linux-riscv64-local-staging
214+
path: ~/linux-riscv64-local-staging
215+
207216
- name: Download linux-x86_64-java11 staging directory
208217
uses: actions/download-artifact@v3
209218
with:
@@ -214,7 +223,7 @@ jobs:
214223
# all together with one maven command.
215224
- name: Merge staging repositories
216225
working-directory: ./prepare-release-workspace/
217-
run: bash ./.github/scripts/merge_local_staging.sh /home/runner/local-staging/staging ~/linux-aarch64-local-staging/staging ~/linux-x86_64-java11-local-staging/staging
226+
run: bash ./.github/scripts/merge_local_staging.sh /home/runner/local-staging/staging ~/linux-aarch64-local-staging/staging ~/linux-riscv64-local-staging/staging ~/linux-x86_64-java11-local-staging/staging
218227

219228
- uses: s4u/maven-settings-action@v2.8.0
220229
with:

.github/workflows/ci-release.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ jobs:
8787
- setup: linux-aarch64
8888
docker-compose-build: "-f docker/docker-compose.centos-7.yaml build"
8989
docker-compose-run: "-f docker/docker-compose.centos-7.yaml run cross-compile-aarch64-stage-release"
90+
- setup: linux-riscv64
91+
docker-compose-build: "-f docker/docker-compose.ubuntu-20.04.yaml build"
92+
docker-compose-run: "-f docker/docker-compose.ubuntu-20.04.yaml run cross-compile-riscv64-stage-release"
9093

9194
name: stage-release-${{ matrix.setup }}
9295

@@ -204,6 +207,12 @@ jobs:
204207
name: linux-aarch64-local-staging
205208
path: ~/linux-aarch64-local-staging
206209

210+
- name: Download linux-riscv64 staging directory
211+
uses: actions/download-artifact@v3
212+
with:
213+
name: linux-riscv64-local-staging
214+
path: ~/linux-riscv64-local-staging
215+
207216
- name: Download linux-x86_64-java8 staging directory
208217
uses: actions/download-artifact@v3
209218
with:
@@ -214,7 +223,7 @@ jobs:
214223
# all together with one maven command.
215224
- name: Merge staging repositories
216225
working-directory: ./prepare-release-workspace/
217-
run: bash ./.github/scripts/merge_local_staging.sh /home/runner/local-staging/staging ~/linux-aarch64-local-staging/staging ~/linux-x86_64-java8-local-staging/staging
226+
run: bash ./.github/scripts/merge_local_staging.sh /home/runner/local-staging/staging ~/linux-aarch64-local-staging/staging ~/linux-riscv64-local-staging/staging ~/linux-x86_64-java8-local-staging/staging
218227

219228
- uses: s4u/maven-settings-action@v2.8.0
220229
with:

all/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@
8080
<classifier>linux-aarch_64</classifier>
8181
<scope>runtime</scope>
8282
</dependency>
83+
<dependency>
84+
<groupId>${project.groupId}</groupId>
85+
<artifactId>netty-transport-native-epoll</artifactId>
86+
<classifier>linux-riscv64</classifier>
87+
<scope>runtime</scope>
88+
</dependency>
8389
<dependency>
8490
<groupId>${project.groupId}</groupId>
8591
<artifactId>netty-transport-native-kqueue</artifactId>

bom/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@
243243
<version>${project.version}</version>
244244
<classifier>linux-aarch_64</classifier>
245245
</dependency>
246+
<dependency>
247+
<groupId>io.netty</groupId>
248+
<artifactId>netty-transport-native-unix-common</artifactId>
249+
<version>${project.version}</version>
250+
<classifier>linux-riscv64</classifier>
251+
</dependency>
246252
<dependency>
247253
<groupId>io.netty</groupId>
248254
<artifactId>netty-transport-native-unix-common</artifactId>
@@ -277,6 +283,12 @@
277283
<version>${project.version}</version>
278284
<classifier>linux-aarch_64</classifier>
279285
</dependency>
286+
<dependency>
287+
<groupId>io.netty</groupId>
288+
<artifactId>netty-transport-native-epoll</artifactId>
289+
<version>${project.version}</version>
290+
<classifier>linux-riscv64</classifier>
291+
</dependency>
280292
<dependency>
281293
<groupId>io.netty</groupId>
282294
<artifactId>netty-transport-native-epoll</artifactId>

codec-http/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@
8686
<artifactId>native-linux-aarch64</artifactId>
8787
<scope>test</scope>
8888
</dependency>
89+
<dependency>
90+
<groupId>com.aayushatharva.brotli4j</groupId>
91+
<artifactId>native-linux-riscv64</artifactId>
92+
<scope>test</scope>
93+
</dependency>
8994
<dependency>
9095
<groupId>com.aayushatharva.brotli4j</groupId>
9196
<artifactId>native-osx-x86_64</artifactId>

codec-http2/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
<artifactId>native-linux-aarch64</artifactId>
102102
<scope>test</scope>
103103
</dependency>
104+
<dependency>
105+
<groupId>com.aayushatharva.brotli4j</groupId>
106+
<artifactId>native-linux-riscv64</artifactId>
107+
<scope>test</scope>
108+
</dependency>
104109
<dependency>
105110
<groupId>com.aayushatharva.brotli4j</groupId>
106111
<artifactId>native-linux-armv7</artifactId>

codec/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@
103103
<artifactId>native-linux-aarch64</artifactId>
104104
<optional>true</optional>
105105
</dependency>
106+
<dependency>
107+
<groupId>com.aayushatharva.brotli4j</groupId>
108+
<artifactId>native-linux-riscv64</artifactId>
109+
<optional>true</optional>
110+
</dependency>
106111
<dependency>
107112
<groupId>com.aayushatharva.brotli4j</groupId>
108113
<artifactId>native-osx-x86_64</artifactId>

common/src/main/java/io/netty/util/internal/PlatformDependent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,10 @@ private static String normalizeArch(String value) {
15641564
if ("aarch64".equals(value)) {
15651565
return "aarch_64";
15661566
}
1567+
if ("riscv64".equals(value)) {
1568+
// os.detected.arch is riscv64 for RISC-V, no underscore
1569+
return "riscv64";
1570+
}
15671571
if (value.matches("^(ppc|ppc32)$")) {
15681572
return "ppc_32";
15691573
}

0 commit comments

Comments
 (0)