Skip to content

feat: add riscv64gc-unknown-linux-musl image #1664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/1664.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "added",
"description": "add riscv64gc-unknown-linux-musl support",
"issues": [1197]
}
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/b_issue_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ body:
- powerpc64-unknown-linux-gnu
- powerpc-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
- riscv64gc-unknown-linux-musl
- s390x-unknown-linux-gnu
- sparc64-unknown-linux-gnu
- sparcv9-sun-solaris
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ terminate.
| `powerpc64-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `powerpc64le-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `riscv64gc-unknown-linux-gnu` | 2.35 | 11.4.0 | ✓ | 8.2.2 | ✓ |
| `riscv64gc-unknown-linux-musl` | 1.2.5 | 14.2.0 | ✓ | 8.2.2 | ✓ |
| `s390x-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `sparc64-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `sparcv9-sun-solaris` | 1.22.7 | 8.4.0 | ✓ | N/A | |
Expand Down
50 changes: 50 additions & 0 deletions docker/Dockerfile.riscv64gc-unknown-linux-musl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM ubuntu:24.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive

COPY common.sh lib.sh /
RUN /common.sh

COPY cmake.sh /
RUN /cmake.sh

COPY xargo.sh /
RUN /xargo.sh

FROM cross-base AS build

RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 \
adduser

ARG VERBOSE
COPY crosstool-ng.sh /
COPY crosstool-config/riscv64gc-unknown-linux-musl.config /
RUN /crosstool-ng.sh riscv64gc-unknown-linux-musl.config 5

ENV PATH=/x-tools/riscv64-unknown-linux-musl/bin/:$PATH

COPY qemu.sh /
RUN /qemu.sh riscv64

COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake

ENV CROSS_TOOLCHAIN_PREFIX=riscv64-unknown-linux-musl-
ENV CROSS_SYSROOT=/x-tools/riscv64-unknown-linux-musl/riscv64-unknown-linux-musl/sysroot/

ENV CROSS_TARGET_RUNNER="/qemu-runner riscv64"
ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_riscv64gc_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_riscv64gc_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=riscv64gc \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -mcmodel=medany"

RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
38 changes: 38 additions & 0 deletions docker/crosstool-config/riscv64gc-unknown-linux-musl.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_ARCH_RISCV=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_ARCH="rv64g"
CT_ARCH_64=y
CT_KERNEL_LINUX=y
CT_LINUX_V_5_19=y
# CT_LINUX_NO_VERSIONS is not set
CT_LINUX_VERSION="5.19.16"
CT_LINUX_later_than_4_8=y
CT_LINUX_4_8_or_later=y
CT_LINUX_later_than_3_7=y
CT_LINUX_3_7_or_later=y
CT_LINUX_later_than_3_2=y
CT_LINUX_3_2_or_later=y
CT_LIBC_MUSL=y
CT_MUSL_V_1_2_5=y
# CT_MUSL_NO_VERSIONS is not set
CT_MUSL_VERSION="1.2.5"
CT_GCC_V_14=y
# CT_GCC_NO_VERSIONS is not set
CT_GCC_VERSION="14.2.0"
CT_GCC_later_than_7=y
CT_GCC_7_or_later=y
CT_GCC_later_than_6=y
CT_GCC_6_or_later=y
CT_GCC_later_than_5=y
CT_GCC_5_or_later=y
CT_GCC_later_than_4_9=y
CT_GCC_4_9_or_later=y
CT_GCC_later_than_4_8=y
CT_GCC_4_8_or_later=y
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
CT_CC_LANG_CXX=y

5 changes: 5 additions & 0 deletions src/docker/provided_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ pub static PROVIDED_IMAGES: &[ProvidedImage] = &[
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
sub: None
},
ProvidedImage {
name: "riscv64gc-unknown-linux-musl",
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
sub: None
},
ProvidedImage {
name: "s390x-unknown-linux-gnu",
platforms: &[ImagePlatform::X86_64_UNKNOWN_LINUX_GNU],
Expand Down
9 changes: 9 additions & 0 deletions targets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ std = true
run = true
runners = "qemu-user qemu-system"

[[target]]
target = "riscv64gc-unknown-linux-musl"
os = "ubuntu-latest"
cpp = true
dylib = true
std = true
run = true
runners = "qemu-user"

[[target]]
target = "s390x-unknown-linux-gnu"
os = "ubuntu-latest"
Expand Down
Loading