|
| 1 | +FROM ubuntu:24.04 |
| 2 | + |
| 3 | +ARG DEBIAN_FRONTEND=noninteractive |
| 4 | +RUN apt-get update -y && apt-get install -y --no-install-recommends \ |
| 5 | + bc \ |
| 6 | + bzip2 \ |
| 7 | + ca-certificates \ |
| 8 | + cmake \ |
| 9 | + cpio \ |
| 10 | + curl \ |
| 11 | + file \ |
| 12 | + flex \ |
| 13 | + bison \ |
| 14 | + g++ \ |
| 15 | + g++-riscv64-linux-gnu \ |
| 16 | + git \ |
| 17 | + libc6-dev \ |
| 18 | + libc6-dev-riscv64-cross \ |
| 19 | + libssl-dev \ |
| 20 | + make \ |
| 21 | + ninja-build \ |
| 22 | + python3 \ |
| 23 | + xz-utils \ |
| 24 | + opensbi \ |
| 25 | + u-boot-qemu \ |
| 26 | + libslirp0 \ |
| 27 | + build-essential \ |
| 28 | + pkg-config \ |
| 29 | + libglib2.0-dev \ |
| 30 | + libpixman-1-dev \ |
| 31 | + libsdl2-dev \ |
| 32 | + libfdt-dev \ |
| 33 | + python3 \ |
| 34 | + python3-pip |
| 35 | + |
| 36 | +ENV ARCH=riscv \ |
| 37 | + CROSS_COMPILE=riscv64-linux-gnu- |
| 38 | + |
| 39 | +WORKDIR /build |
| 40 | + |
| 41 | +# From https://github.com/michaeljclark/busybear-linux/blob/master/conf/linux.config |
| 42 | +COPY host-x86_64/riscv64a23-gnu/linux.config /build |
| 43 | + |
| 44 | +# qemu v10.0.2 fully support |
| 45 | +RUN curl https://gitlab.com/qemu-project/qemu/-/archive/v10.0.2/qemu-v10.0.2.tar.bz2 | tar xjf - && \ |
| 46 | + cd qemu-v10.0.2 && \ |
| 47 | + ./configure --target-list=riscv64-softmmu \ |
| 48 | + --enable-sdl --enable-debug --enable-fdt --enable-slirp && \ |
| 49 | + make -j && make install |
| 50 | + |
| 51 | +# use the opensbi fw from apt-get install |
| 52 | +RUN cp /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin /tmp |
| 53 | + |
| 54 | +# Compile the kernel that we're going to be emulating with. This is |
| 55 | +# basically just done to be compatible with the QEMU target that we're going |
| 56 | +# to be using when running tests. |
| 57 | +RUN curl https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.97.tar.xz | tar xJf - && \ |
| 58 | + cp linux.config linux-6.6.97/.config && \ |
| 59 | + cd /build/linux-6.6.97 && \ |
| 60 | + make olddefconfig && \ |
| 61 | + make -j$(nproc) Image && \ |
| 62 | + cp arch/riscv/boot/Image /tmp && \ |
| 63 | + rm -rf linux-6.6.97 |
| 64 | + |
| 65 | +# Compile an instance of busybox as this provides a lightweight system and init |
| 66 | +# binary which we will boot into. Only trick here is configuring busybox to |
| 67 | +# build static binaries. |
| 68 | +RUN curl https://www.busybox.net/downloads/busybox-1.37.0.tar.bz2 | tar xjf - && \ |
| 69 | + cd busybox-1.37.0 && \ |
| 70 | + make defconfig && \ |
| 71 | + sed -i 's/# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config && \ |
| 72 | + sed -i 's/^CONFIG_TC=y$/# CONFIG_TC is not set/' .config && \ |
| 73 | + sed -i 's/CONFIG_SHA1_HWACCEL=y/# CONFIG_SHA1_HWACCEL is not set/' .config && \ |
| 74 | + sed -i 's/CONFIG_SHA256_HWACCEL=y/# CONFIG_SHA256_HWACCEL is not set/' .config && \ |
| 75 | + make -j$(nproc) && \ |
| 76 | + make install && \ |
| 77 | + mv _install /tmp/rootfs && \ |
| 78 | + cd /build && \ |
| 79 | + rm -rf busybox-1.37.0 |
| 80 | + |
| 81 | +# Download the ubuntu rootfs, which we'll use as a chroot for all our tests. |
| 82 | +WORKDIR /tmp |
| 83 | +RUN mkdir rootfs/ubuntu |
| 84 | +RUN curl https://cdimage.ubuntu.com/ubuntu-base/releases/24.04/release/ubuntu-base-24.04.2-base-riscv64.tar.gz | \ |
| 85 | + tar xzf - -C rootfs/ubuntu && \ |
| 86 | + cd rootfs && mkdir proc sys dev etc etc/init.d |
| 87 | + |
| 88 | +# Copy over our init script, which starts up our test server and also a few other |
| 89 | +# misc tasks |
| 90 | +COPY scripts/qemu-bare-bones-rcS rootfs/etc/init.d/rcS |
| 91 | +RUN chmod +x rootfs/etc/init.d/rcS |
| 92 | + |
| 93 | +# Helper to quickly fill the entropy pool in the kernel |
| 94 | +COPY scripts/qemu-bare-bones-addentropy.c /tmp/addentropy.c |
| 95 | +RUN riscv64-linux-gnu-gcc addentropy.c -o rootfs/addentropy -static |
| 96 | + |
| 97 | +COPY scripts/sccache.sh /scripts/ |
| 98 | +RUN sh /scripts/sccache.sh |
| 99 | + |
| 100 | +# Avoid "fatal: detected dubious ownership in repository at '/checkout'" error |
| 101 | +RUN git config --global --add safe.directory "*" |
| 102 | + |
| 103 | +ENV RUST_CONFIGURE_ARGS \ |
| 104 | + --set target.riscv64a23-unknown-linux-gnu.linker=riscv64-linux-gnu-gcc \ |
| 105 | + --set target.riscv64a23-unknown-linux-gnu.qemu-rootfs=/tmp/rootfs |
| 106 | +ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target riscv64a23-unknown-linux-gnu |
| 107 | + |
| 108 | +ENV NO_CHANGE_USER=1 |
0 commit comments