Skip to content

Commit 1d089f5

Browse files
committed
Add riscv32 CI run
1 parent e907456 commit 1d089f5

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

.github/workflows/main.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
os: ubuntu-latest
5757
- tuple: aarch64-unknown-linux-gnu
5858
os: ubuntu-latest
59+
- tuple: riscv32gc-unknown-linux-gnu
60+
os: ubuntu-latest
5961
- tuple: riscv64gc-unknown-linux-gnu
6062
os: ubuntu-latest
6163
- tuple: powerpc-unknown-linux-gnu
@@ -147,6 +149,11 @@ jobs:
147149
tuple: powerpc64le-unknown-linux-gnu
148150
os: ubuntu-latest
149151
test_everything: true
152+
- target:
153+
tuple: riscv32gc-unknown-linux-gnu
154+
os: ubuntu-latest
155+
test_everything: true
156+
build_std: true
150157
- target:
151158
tuple: riscv64gc-unknown-linux-gnu
152159
os: ubuntu-latest
@@ -192,13 +199,18 @@ jobs:
192199

193200
steps:
194201
- uses: actions/checkout@v4
195-
with:
196-
submodules: recursive
202+
197203
- name: Install Rust
198204
run: |
199205
rustup update nightly --no-self-update
200206
rustup default nightly
201207
- run: rustup target add ${{ matrix.target.tuple }}
208+
if: matrix.build_std == ''
209+
- run: |
210+
rustup component add rust-src
211+
echo "CARGO_UNSTABLE_BUILD_STD=std" >> $GITHUB_ENV
212+
if: matrix.build_std != ''
213+
202214
- run: cargo generate-lockfile
203215

204216
# Configure some env vars based on matrix configuration
@@ -227,7 +239,7 @@ jobs:
227239
# ... while Linux goes to `run-docker.sh`
228240
- run: ./ci/run-docker.sh ${{ matrix.target.tuple }}
229241
shell: bash
230-
if: "matrix.target.os == 'ubuntu-latest' && !startsWith(matrix.target.tuple, 'thumb')"
242+
if: matrix.target.os == 'ubuntu-latest' && !startsWith(matrix.target.tuple, 'thumb')
231243
env:
232244
TARGET: ${{ matrix.target.tuple }}
233245

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ubuntu:25.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
gcc libc6-dev qemu-user ca-certificates \
5+
wget xz-utils make file llvm
6+
7+
ENV VERSION=2025.01.20
8+
9+
RUN wget "https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/${VERSION}/riscv32-glibc-ubuntu-24.04-gcc-nightly-${VERSION}-nightly.tar.xz" \
10+
-O riscv-toolchain.tar.xz
11+
RUN tar -xJf riscv-toolchain.tar.xz
12+
13+
ENV CARGO_TARGET_RISCV32GC_UNKNOWN_LINUX_GNU_LINKER=/riscv/bin/riscv32-unknown-linux-gnu-gcc \
14+
CARGO_TARGET_RISCV32GC_UNKNOWN_LINUX_GNU_RUNNER="qemu-riscv32 -cpu max -L /riscv/sysroot" \
15+
OBJDUMP=llvm-objdump

ci/run-docker.sh

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ run() {
3636
--env NOSTD \
3737
--env NORUN \
3838
--env RUSTFLAGS \
39+
--env CARGO_UNSTABLE_BUILD_STD \
3940
--volume "${HOME}/.cargo":/cargo \
4041
--volume "$(rustc --print sysroot)":/rust:ro \
4142
--volume "$(pwd)":/checkout:ro \

ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ case ${TARGET} in
4444
;;
4545
# Some of our test dependencies use the deprecated `gcc` crates which
4646
# doesn't detect RISC-V compilers automatically, so do it manually here.
47-
riscv64*)
47+
riscv*)
4848
export RUSTFLAGS="${RUSTFLAGS} -Ctarget-feature=+zk,+zks,+zbb,+zbc"
4949
export TARGET_CC="riscv64-linux-gnu-gcc"
5050
;;

crates/stdarch-test/src/disassembly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub(crate) fn disassemble_myself() -> HashSet<Function> {
7777
let add_args = if cfg!(target_vendor = "apple") && cfg!(target_arch = "aarch64") {
7878
// Target features need to be enabled for LLVM objdump on Darwin ARM64
7979
vec!["--mattr=+v8.6a,+crypto,+tme"]
80-
} else if cfg!(target_arch = "riscv64") {
80+
} else if cfg!(any(target_arch = "riscv32", target_arch = "riscv64")) {
8181
vec!["--mattr=+zk,+zks,+zbc,+zbb"]
8282
} else {
8383
vec![]

0 commit comments

Comments
 (0)