dart-lang / dart-docker

Docker images for the Dart programming language (https://dart.dev)
BSD 3-Clause "New" or "Revised" License
67 stars 15 forks source link

RISC-V image for beta channel #96

Open edwardxia opened 2 years ago

edwardxia commented 2 years ago

Now dart has experimental support for RISC-V in beta channel. Having the RISC-V container image for beta channel would be nice.

cpswan commented 1 year ago

It looks like debian:bullseye-slim doesn't yet have OS/ARCH support for linux/riscv64 so there's an upstream dependency issue to be dealt with (and although Debian can be run on RISC-V boards/emulators the architecture isn't yet listed as one of their official images).

cpswan commented 1 year ago

It also turns out that RISC-V shouldn't have appeared in the beta channel - https://github.com/dart-lang/sdk/issues/50548#issuecomment-1326763431

For my own efforts I think I'm going to hold off until it does make it to beta.

cpswan commented 1 year ago

Dart on RISC-V is back in the beta channel (since 15 Mar 2023). I'm also seeing Debian images for linux/riscv (at least in the unstable tags). So the pieces are sliding into place...

cpswan commented 1 year ago

Here's a Dockerfile that I used to make a build image with RISC-V support (based on the existing beta/bullseye Dockerfile):

FROM debian:unstable-slim

RUN set -eux; \
    apt-get update; \
    apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        dnsutils \
        git \
        openssh-client \
        unzip \
    ; \
    rm -rf /var/lib/apt/lists/*

# Create a minimal runtime environment for executing AOT-compiled Dart code
# with the smallest possible image size.
# usage: COPY --from=dart:xxx /runtime/ /
# uses hard links here to save space
RUN set -eux; \
    case "$(dpkg --print-architecture)" in \
        amd64) \
            TRIPLET="x86_64-linux-gnu" ; \
            FILES="/lib64/ld-linux-x86-64.so.2" ;; \
        armhf) \
            TRIPLET="arm-linux-gnueabihf" ; \
            FILES="/lib/ld-linux-armhf.so.3 \
                /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3";; \
        arm64) \
            TRIPLET="aarch64-linux-gnu" ; \
            FILES="/lib/ld-linux-aarch64.so.1 \
                /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1" ;; \
        riscv64) \
            TRIPLET="riscv64-linux-gnu" ; \
            FILES="/lib/ld-linux-riscv64-lp64d.so.1 \
                /lib/riscv64-linux-gnu/ld-linux-riscv64-lp64d.so.1" ;; \
        *) \
            echo "Unsupported architecture" ; \
            exit 5;; \
    esac; \
    FILES="$FILES \
        /etc/nsswitch.conf \
        /etc/ssl/certs \
        /usr/share/ca-certificates \
        /lib/$TRIPLET/libc.so.6 \
        /lib/$TRIPLET/libdl.so.2 \
        /lib/$TRIPLET/libm.so.6 \
        /lib/$TRIPLET/libnss_dns.so.2 \
        /lib/$TRIPLET/libpthread.so.0 \
        /lib/$TRIPLET/libresolv.so.2 \
        /lib/$TRIPLET/librt.so.1"; \
    for f in $FILES; do \
        dir=$(dirname "$f"); \
        mkdir -p "/runtime$dir"; \
        cp --archive --link --dereference --no-target-directory "$f" "/runtime$f"; \
    done

ENV DART_SDK /usr/lib/dart
ENV PATH $DART_SDK/bin:$PATH

WORKDIR /root
RUN set -eux; \
    case "$(dpkg --print-architecture)" in \
        amd64) \
            DART_SHA256=eaaeee6be87a140a08ae0b6cc76e23ff4e5cb0ef7bbfa8ffa08b90e26b826e6e; \
            SDK_ARCH="x64";; \
        armhf) \
            DART_SHA256=7636eb23c9053bceebf326ae46c8e7be57c5c3cbaedabe2a5a0d6c8717dcc5e9; \
            SDK_ARCH="arm";; \
        arm64) \
            DART_SHA256=b8f3d1f6c65657296757455ac99fab5772dcdb333cc83d15d626717779f2224a; \
            SDK_ARCH="arm64";; \
        riscv64) \
            DART_SHA256=013000bebf117608e9572336f227bffa1839d119753d084009331fc6e1747c9e; \
            SDK_ARCH="riscv64";; \
    esac; \
    SDK="dartsdk-linux-${SDK_ARCH}-release.zip"; \
    BASEURL="https://storage.googleapis.com/dart-archive/channels"; \
    URL="$BASEURL/beta/release/3.0.0-290.3.beta/sdk/$SDK"; \
    echo "SDK: $URL" >> dart_setup.log ; \
    curl -fLO "$URL"; \
    echo "$DART_SHA256 *$SDK" \
        | sha256sum --check --status --strict -; \
    unzip "$SDK" && mv dart-sdk "$DART_SDK" && rm "$SDK" \
        && chmod 755 "$DART_SDK" && chmod 755 "$DART_SDK/bin";
cpswan commented 1 year ago

The main obstacle to getting this done is Debian support for RISC-V.

As I noted above it's been in 'sid' (unstable) for a little while now, but the Dockerfiles for stable and beta start FROM debian:bullseye-slim, which is the (now old) stable release (Debian 11).

Debian have announced riscv64 is now an official architecture, but that came after the release of Debian 12 "Bookworm" as the latest stable.

If things run their normal course this means that we'll be waiting until Debian 14 "Forky" for RISC-V to make it into a stable release as a supported architecture, and that will be years away (~summer of 2027). I'm hopeful though that we won't have to wait that long, and that we'll start seeing RISC-V show up in Debian 13 "Trixie" and maybe even Debian 12.

As a point of comparison, Ubuntu already have a bunch of 23.04 "Lunar Lobster" releases available for the popular RISC-V dev boards (and QEMU) - Download Ubuntu for RISC-V Platforms, which hints at Ubuntu on RISC-V being ready for the 24.04 LTS release next year. Though there aren't yet any linux/riscv64 official Ubuntu images on Docker Hub.

SPECULATION what I think will happen here is that Ubuntu will fully support RISC-V from 24.04 LTS (including Docker images). Debian will likely then catch up with a 12 stable release (and 13 testing release) that also supports RISC-V. So we have about a year to wait./SPECULATION The reason for optimism is that substantial resource is being poured into RISC-V dependencies from companies (including Google) through the RISC-V Software Ecosystem (RISE) project. Keep an eye on the RISE Debian wiki for updates.

Meanwhile the images here need to catch up to Debian 12...

cpswan commented 3 weeks ago

Returning to this thread (a year and a bit later).

RISC-V Docker images are indeed available in Ubuntu 24.04

image

and also in Debian 13 "Trixie", which is still at the 'testing' stage and not yet a stable release

image

but no sign of it yet in the stable Debian 12 images, and maybe that will not happen, which leaves us waiting until next year when "Trixie" becomes stable.