Skip to content
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

Add riscv64 support #3109

Merged
merged 2 commits into from
Oct 9, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/snapshot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ jobs:
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
file: Dockerfile-${{ matrix.image }}
# TODO: Add `linux/riscv64` once https://github.com/paritytech/polkadot-sdk/issues/5996 is resolved and ring
# 0.16.x is no longer in dependencies
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand Down
13 changes: 12 additions & 1 deletion Dockerfile-bootstrap-node
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ RUN \
libc6-dev-arm64-cross \
; fi

RUN \
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
g++-riscv64-linux-gnu \
gcc-riscv64-linux-gnu \
libc6-dev-riscv64-cross \
; fi

RUN \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION && \
/root/.cargo/bin/rustup target add wasm32-unknown-unknown
Expand All @@ -54,10 +62,13 @@ RUN \
if [ $BUILDARCH != "arm64" ] && [ $TARGETARCH = "arm64" ]; then \
export RUSTFLAGS="$RUSTFLAGS -C linker=aarch64-linux-gnu-gcc" \
; fi && \
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
export RUSTFLAGS="$RUSTFLAGS -C linker=riscv64-linux-gnu-gcc" \
; fi && \
if [ $TARGETARCH = "amd64" ] && [ $RUSTFLAGS = ""]; then \
export RUSTFLAGS="-C target-cpu=skylake" \
; fi && \
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g") && \
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g" | sed "s/riscv64/riscv64gc/g") && \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
Expand Down
41 changes: 32 additions & 9 deletions Dockerfile-farmer
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ RUN \
libc6-dev-arm64-cross \
; fi

RUN \
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
g++-riscv64-linux-gnu \
gcc-riscv64-linux-gnu \
libc6-dev-riscv64-cross \
; fi

RUN \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION && \
/root/.cargo/bin/rustup target add wasm32-unknown-unknown
Expand Down Expand Up @@ -96,11 +104,14 @@ RUN \
if [ $BUILDARCH != "arm64" ] && [ $TARGETARCH = "arm64" ]; then \
export RUSTFLAGS="$RUSTFLAGS -C linker=aarch64-linux-gnu-gcc" \
; fi && \
if [ $TARGETARCH = "amd64" ] && [ $RUSTFLAGS = ""]; then \
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
export RUSTFLAGS="$RUSTFLAGS -C linker=riscv64-linux-gnu-gcc" \
; fi && \
if [ $TARGETARCH = "amd64" ] && [ $RUSTFLAGS = "" ]; then \
export RUSTFLAGS="-C target-cpu=skylake" \
; fi && \
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}} && \
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g") && \
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g" | sed "s/riscv64/riscv64gc/g") && \
if [ $BUILDARCH = "amd64" ] && [ $TARGETARCH = "amd64" ]; then \
NVCC=off /root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
Expand All @@ -111,18 +122,30 @@ RUN \
--target $RUSTC_TARGET_ARCH-unknown-linux-gnu && \
mv target/*/*/subspace-farmer subspace-farmer-rocm \
; fi && \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
--bin subspace-farmer \
--features cuda \
--target $RUSTC_TARGET_ARCH-unknown-linux-gnu && \
if [ $(which nvcc) ]; then \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
--bin subspace-farmer \
--features cuda \
--target $RUSTC_TARGET_ARCH-unknown-linux-gnu \
; else \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
--bin subspace-farmer \
--target $RUSTC_TARGET_ARCH-unknown-linux-gnu \
; fi && \
mv target/*/*/subspace-farmer subspace-farmer && \
rm -rf target

FROM ubuntu:22.04

ARG BUILDARCH
ARG TARGETARCH

# Next block is for ROCm support
# ROCm is only used on x86-64 since they don't have other packages
ARG ROCM_VERSION=6.2.2
Expand Down
13 changes: 12 additions & 1 deletion Dockerfile-node
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ RUN \
libc6-dev-arm64-cross \
; fi

RUN \
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
g++-riscv64-linux-gnu \
gcc-riscv64-linux-gnu \
libc6-dev-riscv64-cross \
; fi

RUN \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION && \
/root/.cargo/bin/rustup target add wasm32-unknown-unknown
Expand All @@ -56,10 +64,13 @@ RUN \
if [ $BUILDARCH != "arm64" ] && [ $TARGETARCH = "arm64" ]; then \
export RUSTFLAGS="$RUSTFLAGS -C linker=aarch64-linux-gnu-gcc" \
; fi && \
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
export RUSTFLAGS="$RUSTFLAGS -C linker=riscv64-linux-gnu-gcc" \
; fi && \
if [ $TARGETARCH = "amd64" ] && [ $RUSTFLAGS = ""]; then \
export RUSTFLAGS="-C target-cpu=skylake" \
; fi && \
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g") && \
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g" | sed "s/riscv64/riscv64gc/g") && \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
Expand Down
13 changes: 12 additions & 1 deletion Dockerfile-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ RUN \
libc6-dev-arm64-cross \
; fi

RUN \
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
g++-riscv64-linux-gnu \
gcc-riscv64-linux-gnu \
libc6-dev-riscv64-cross \
; fi

RUN \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION && \
/root/.cargo/bin/rustup target add wasm32-unknown-unknown
Expand All @@ -54,10 +62,13 @@ RUN \
if [ $BUILDARCH != "arm64" ] && [ $TARGETARCH = "arm64" ]; then \
export RUSTFLAGS="$RUSTFLAGS -C linker=aarch64-linux-gnu-gcc" \
; fi && \
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
export RUSTFLAGS="$RUSTFLAGS -C linker=riscv64-linux-gnu-gcc" \
; fi && \
if [ $TARGETARCH = "amd64" ] && [ $RUSTFLAGS = ""]; then \
export RUSTFLAGS="-C target-cpu=skylake" \
; fi && \
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g") && \
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g" | sed "s/riscv64/riscv64gc/g") && \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
Expand Down
Loading