Skip to content

Commit ea57f41

Browse files
committed
feat: add riscv64gc-unknown-linux-musl image
Close #1197
1 parent 4e64366 commit ea57f41

File tree

7 files changed

+109
-0
lines changed

7 files changed

+109
-0
lines changed

.changes/1664.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "added",
3+
"description": "add riscv64gc-unknown-linux-musl support",
4+
"issues": [1197]
5+
}

.github/ISSUE_TEMPLATE/b_issue_report.yml

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ body:
6666
- powerpc64-unknown-linux-gnu
6767
- powerpc-unknown-linux-gnu
6868
- riscv64gc-unknown-linux-gnu
69+
- riscv64gc-unknown-linux-musl
6970
- s390x-unknown-linux-gnu
7071
- sparc64-unknown-linux-gnu
7172
- sparcv9-sun-solaris

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ terminate.
238238
| `powerpc64-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
239239
| `powerpc64le-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
240240
| `riscv64gc-unknown-linux-gnu` | 2.35 | 11.4.0 || 8.2.2 ||
241+
| `riscv64gc-unknown-linux-musl` | 1.2.5 | 14.2.0 || 8.2.2 ||
241242
| `s390x-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
242243
| `sparc64-unknown-linux-gnu` | 2.31 | 9.4.0 || 6.1.0 ||
243244
| `sparcv9-sun-solaris` | 1.22.7 | 8.4.0 || N/A | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM ubuntu:24.04 AS cross-base
2+
ENV DEBIAN_FRONTEND=noninteractive
3+
4+
COPY common.sh lib.sh /
5+
RUN /common.sh
6+
7+
COPY cmake.sh /
8+
RUN /cmake.sh
9+
10+
COPY xargo.sh /
11+
RUN /xargo.sh
12+
13+
FROM cross-base AS build
14+
15+
RUN apt-get update && apt-get install -y --no-install-recommends \
16+
bzip2 \
17+
adduser
18+
19+
ARG VERBOSE
20+
COPY crosstool-ng.sh /
21+
COPY crosstool-config/riscv64gc-unknown-linux-musl.config /
22+
RUN /crosstool-ng.sh riscv64gc-unknown-linux-musl.config 5
23+
24+
ENV PATH=/x-tools/riscv64-unknown-linux-musl/bin/:$PATH
25+
26+
COPY qemu.sh /
27+
RUN /qemu.sh riscv64
28+
29+
COPY qemu-runner base-runner.sh /
30+
COPY toolchain.cmake /opt/toolchain.cmake
31+
32+
ENV CROSS_TOOLCHAIN_PREFIX=riscv64-unknown-linux-musl-
33+
ENV CROSS_SYSROOT=/x-tools/riscv64-unknown-linux-musl/riscv64-unknown-linux-musl/sysroot/
34+
35+
ENV CROSS_TARGET_RUNNER="/qemu-runner riscv64"
36+
ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
37+
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
38+
AR_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
39+
CC_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
40+
CXX_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
41+
CMAKE_TOOLCHAIN_FILE_riscv64gc_unknown_linux_musl=/opt/toolchain.cmake \
42+
BINDGEN_EXTRA_CLANG_ARGS_riscv64gc_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
43+
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
44+
RUST_TEST_THREADS=1 \
45+
CROSS_CMAKE_SYSTEM_NAME=Linux \
46+
CROSS_CMAKE_SYSTEM_PROCESSOR=riscv64gc \
47+
CROSS_CMAKE_CRT=musl \
48+
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -mcmodel=medany"
49+
50+
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
CT_CONFIG_VERSION="4"
2+
CT_EXPERIMENTAL=y
3+
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
4+
CT_ARCH_RISCV=y
5+
# CT_DEMULTILIB is not set
6+
CT_ARCH_USE_MMU=y
7+
CT_ARCH_ARCH="rv64g"
8+
CT_ARCH_64=y
9+
CT_KERNEL_LINUX=y
10+
CT_LINUX_V_5_19=y
11+
# CT_LINUX_NO_VERSIONS is not set
12+
CT_LINUX_VERSION="5.19.16"
13+
CT_LINUX_later_than_4_8=y
14+
CT_LINUX_4_8_or_later=y
15+
CT_LINUX_later_than_3_7=y
16+
CT_LINUX_3_7_or_later=y
17+
CT_LINUX_later_than_3_2=y
18+
CT_LINUX_3_2_or_later=y
19+
CT_LIBC_MUSL=y
20+
CT_MUSL_V_1_2_5=y
21+
# CT_MUSL_NO_VERSIONS is not set
22+
CT_MUSL_VERSION="1.2.5"
23+
CT_GCC_V_14=y
24+
# CT_GCC_NO_VERSIONS is not set
25+
CT_GCC_VERSION="14.2.0"
26+
CT_GCC_later_than_7=y
27+
CT_GCC_7_or_later=y
28+
CT_GCC_later_than_6=y
29+
CT_GCC_6_or_later=y
30+
CT_GCC_later_than_5=y
31+
CT_GCC_5_or_later=y
32+
CT_GCC_later_than_4_9=y
33+
CT_GCC_4_9_or_later=y
34+
CT_GCC_later_than_4_8=y
35+
CT_GCC_4_8_or_later=y
36+
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
37+
CT_CC_LANG_CXX=y
38+

src/docker/provided_images.rs

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ pub static PROVIDED_IMAGES: &[ProvidedImage] = &[
108108
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
109109
sub: None
110110
},
111+
ProvidedImage {
112+
name: "riscv64gc-unknown-linux-musl",
113+
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
114+
sub: None
115+
},
111116
ProvidedImage {
112117
name: "s390x-unknown-linux-gnu",
113118
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],

targets.toml

+9
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ std = true
227227
run = true
228228
runners = "qemu-user qemu-system"
229229

230+
[[target]]
231+
target = "riscv64gc-unknown-linux-musl"
232+
os = "ubuntu-latest"
233+
cpp = true
234+
dylib = true
235+
std = true
236+
run = true
237+
runners = "qemu-user"
238+
230239
[[target]]
231240
target = "s390x-unknown-linux-gnu"
232241
os = "ubuntu-latest"

0 commit comments

Comments
 (0)