Skip to content

Commit f7f42c6

Browse files
committed
Add CI for Rust w/ RISC-V
Signed-off-by: Gary Guo <[email protected]>
1 parent 87447f4 commit f7f42c6

File tree

3 files changed

+2810
-1
lines changed

3 files changed

+2810
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
arch: [arm, arm64, ppc64le, x86_64]
13+
arch: [arm, arm64, ppc64le, x86_64, riscv64]
1414
toolchain: [gcc, clang, llvm]
1515
config: [debug, release]
1616
rustc: [2021-02-20]
@@ -25,6 +25,8 @@ jobs:
2525
# Exclude `LLVM=1` where not supported.
2626
- arch: ppc64le
2727
toolchain: llvm
28+
- arch: riscv64
29+
toolchain: llvm
2830

2931
# A few independent combinations to avoid exploding the matrix:
3032
# - The other option for `output`.
@@ -92,6 +94,15 @@ jobs:
9294
echo 'QEMU_ARCH=arm' >> $GITHUB_ENV
9395
echo 'QEMU_MACHINE=virt' >> $GITHUB_ENV
9496
echo 'QEMU_CPU=cortex-a7' >> $GITHUB_ENV
97+
- if: matrix.arch == 'riscv64'
98+
run: |
99+
echo 'MAKE_ARCH=ARCH=riscv' >> $GITHUB_ENV
100+
echo 'MAKE_CROSS_COMPILE=CROSS_COMPILE=riscv64-linux-gnu-' >> $GITHUB_ENV
101+
echo 'IMAGE_PATH=arch/riscv/boot/Image' >> $GITHUB_ENV
102+
echo 'QEMU_ARCH=riscv64' >> $GITHUB_ENV
103+
echo 'QEMU_MACHINE=virt' >> $GITHUB_ENV
104+
echo 'QEMU_CPU=rv64' >> $GITHUB_ENV
105+
echo 'QEMU_ARGS=-bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf' >> $GITHUB_ENV
95106
96107
- if: matrix.toolchain == 'clang'
97108
run: echo 'MAKE_TOOLCHAIN=CC=clang-11' >> $GITHUB_ENV
@@ -122,6 +133,12 @@ jobs:
122133
run: sudo apt-get install -y gcc-aarch64-linux-gnu
123134
- if: matrix.arch == 'ppc64le'
124135
run: sudo apt-get install -y gcc-powerpc64le-linux-gnu
136+
- if: matrix.arch == 'riscv64'
137+
run: sudo apt-get install -y gcc-riscv64-linux-gnu
138+
139+
# Setup OpenSBI
140+
- if: matrix.arch == 'riscv64'
141+
run: sudo apt-get install -y opensbi
125142

126143
# Setup: libelf
127144
- run: sudo apt-get install -y libelf-dev
@@ -133,6 +150,8 @@ jobs:
133150
run: sudo apt-get install -y qemu-system-arm
134151
- if: matrix.arch == 'ppc64le'
135152
run: sudo apt-get install -y qemu-system-ppc
153+
- if: matrix.arch == 'riscv64'
154+
run: sudo apt-get install -y qemu-system-misc
136155

137156
# Setup: rustc
138157
- if: matrix.install == 'rustup'
@@ -205,6 +224,7 @@ jobs:
205224

206225
- run: |
207226
qemu-system-${{ env.QEMU_ARCH }} \
227+
${{ env.QEMU_ARGS }} \
208228
-kernel ${{ env.BUILD_DIR }}${{ env.IMAGE_PATH }} \
209229
-initrd qemu-initramfs.img \
210230
-M ${{ env.QEMU_MACHINE }} \

0 commit comments

Comments
 (0)