]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile
Auto merge of #73583 - anp:location-eq, r=dtolnay
[rust.git] / src / ci / docker / host-x86_64 / disabled / riscv64gc-linux / Dockerfile
1 # based on armhf-gnu/Dockerfile
2 FROM ubuntu:20.04
3
4 RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
5 RUN apt-get update -y && apt-get install -y --no-install-recommends \
6     bc \
7     bison \
8     ca-certificates \
9     cmake \
10     cpio \
11     curl \
12     debian-ports-archive-keyring \
13     debootstrap \
14     flex \
15     gcc \
16     gcc-riscv64-linux-gnu \
17     git \
18     g++-riscv64-linux-gnu \
19     g++ \
20     libc6-dev \
21     libc6-dev-riscv64-cross \
22     make \
23     patch \
24     python3 \
25     qemu-system-misc \
26     xz-utils
27
28 ENV ARCH=riscv
29 ENV CROSS_COMPILE=riscv64-linux-gnu-
30
31 WORKDIR /build
32
33 # From https://github.com/michaeljclark/busybear-linux/blob/master/conf/linux.config
34 COPY host-x86_64/riscv64gc-linux/linux.config /build
35
36 # Compile the kernel that we're going to be emulating with. This is
37 # basically just done to be compatible with the QEMU target that we're going
38 # to be using when running tests.
39 RUN curl https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.16.tar.xz | tar xJf - && \
40     cp linux.config linux-5.6.16/.config && \
41     cd /build/linux-5.6.16 && \
42     make olddefconfig && \
43     make -j$(nproc) vmlinux && \
44     cp vmlinux /tmp && \
45     rm -rf linux-5.6.16
46
47 # Compile an instance of busybox as this provides a lightweight system and init
48 # binary which we will boot into. Only trick here is configuring busybox to
49 # build static binaries.
50 RUN curl https://busybox.net/downloads/busybox-1.31.1.tar.bz2 | tar xjf -
51 COPY host-x86_64/riscv64gc-linux/0001-Remove-stime-function-calls.patch /build/busybox-1.31.1/
52 RUN cd /build/busybox-1.31.1 && \
53     patch -p1 -i 0001-Remove-stime-function-calls.patch && \
54     make defconfig && \
55     sed -i 's/.*CONFIG_STATIC.*/CONFIG_STATIC=y/' .config && \
56     make -j$(nproc) && \
57     make install && \
58     mv _install /tmp/rootfs && \
59     cd /build && \
60     rm -rf busybox-1.31.1
61
62 # Download the ubuntu rootfs, which we'll use as a chroot for all our tests
63 # This is only needed to provide /lib/* and /usr/lib/*
64 WORKDIR /tmp
65 RUN debootstrap --variant=minbase --arch=riscv64 --foreign focal /tmp/rootfs/ubuntu
66 RUN cd rootfs && mkdir proc sys dev etc etc/init.d
67 # rootfs/ubuntu/proc is in a weird state (access fails with ELOOP) until
68 # rootfs/ubuntu/debootstrap/debootstrap --second-stage is run (under emulation),
69 # but this takes ages. Instead hack it into a good enough state.
70 # /proc is used by std::env::current_exe() (which is roughly
71 # `readlink /proc/self/exe`)
72 RUN cd rootfs/ubuntu && rm -rf proc && mkdir proc
73
74 # Copy over our init script, which starts up our test server and also a few other
75 # misc tasks
76 COPY scripts/qemu-bare-bones-rcS rootfs/etc/init.d/rcS
77 RUN chmod +x rootfs/etc/init.d/rcS
78
79 # Helper to quickly fill the entropy pool in the kernel
80 COPY scripts/qemu-bare-bones-addentropy.c /tmp/addentropy.c
81 RUN riscv64-linux-gnu-gcc addentropy.c -o rootfs/addentropy -static
82
83 # download and build the riscv bootloader
84 RUN git clone https://github.com/riscv/riscv-pk
85 WORKDIR /tmp/riscv-pk
86 # nothing special about this revision: it is just master at the time of writing
87 # v1.0.0 doesn't build
88 RUN git checkout 5d9ed238e1cabfbca3c47f50d32894ce94bfc304
89 RUN mkdir build && cd build && \
90     ../configure --with-payload=/tmp/vmlinux --host=riscv64-linux-gnu && \
91     make -j$(nproc) && \
92     cp bbl /tmp
93 WORKDIR /tmp
94 RUN rm -rf /tmp/riscv-pk
95
96 COPY scripts/sccache.sh /scripts/
97 RUN sh /scripts/sccache.sh
98
99 ENV RUST_CONFIGURE_ARGS --qemu-riscv64-rootfs=/tmp/rootfs
100 ENV SCRIPT python3 ../x.py test --target riscv64gc-unknown-linux-gnu
101
102 ENV NO_CHANGE_USER=1