diff options
| author | Chen Zhongyao <chen.zhongyao@zte.com.cn> | 2025-07-21 16:31:01 +0000 |
|---|---|---|
| committer | Zhongyao Chen <chen.zhongyao@zte.com.cn> | 2025-08-11 21:08:44 +0000 |
| commit | 988cd14ec1e1d07d8fadc2e76d370e1da8de4f46 (patch) | |
| tree | 7636db10402ab495d1ab9313fd95abe054e291f2 /src | |
| parent | a4cf5e9eca00527082fd58356e4adc8775aeee03 (diff) | |
| download | rust-988cd14ec1e1d07d8fadc2e76d370e1da8de4f46.tar.gz rust-988cd14ec1e1d07d8fadc2e76d370e1da8de4f46.zip | |
Add a disabled builder for riscv64 rva23 emulated tests
This will run all tests for `riscv64a23-unknown-linux-gnu` in a QEMU instance.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile | 108 | ||||
| -rw-r--r-- | src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/linux.config | 51 | ||||
| -rw-r--r-- | src/tools/build-manifest/src/main.rs | 2 | ||||
| -rw-r--r-- | src/tools/remote-test-client/src/main.rs | 29 |
4 files changed, 189 insertions, 1 deletions
diff --git a/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile b/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile new file mode 100644 index 00000000000..86b0d795687 --- /dev/null +++ b/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile @@ -0,0 +1,108 @@ +FROM ubuntu:24.04 + +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update -y && apt-get install -y --no-install-recommends \ + bc \ + bzip2 \ + ca-certificates \ + cmake \ + cpio \ + curl \ + file \ + flex \ + bison \ + g++ \ + g++-riscv64-linux-gnu \ + git \ + libc6-dev \ + libc6-dev-riscv64-cross \ + libssl-dev \ + make \ + ninja-build \ + python3 \ + xz-utils \ + opensbi \ + u-boot-qemu \ + libslirp0 \ + build-essential \ + pkg-config \ + libglib2.0-dev \ + libpixman-1-dev \ + libsdl2-dev \ + libfdt-dev \ + python3 \ + python3-pip + +ENV ARCH=riscv \ + CROSS_COMPILE=riscv64-linux-gnu- + +WORKDIR /build + +# From https://github.com/michaeljclark/busybear-linux/blob/master/conf/linux.config +COPY host-x86_64/riscv64a23-gnu/linux.config /build + +# qemu v10.0.2 fully support +RUN curl https://gitlab.com/qemu-project/qemu/-/archive/v10.0.2/qemu-v10.0.2.tar.bz2 | tar xjf - && \ + cd qemu-v10.0.2 && \ + ./configure --target-list=riscv64-softmmu \ + --enable-sdl --enable-debug --enable-fdt --enable-slirp && \ + make -j && make install + +# use the opensbi fw from apt-get install +RUN cp /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin /tmp + +# Compile the kernel that we're going to be emulating with. This is +# basically just done to be compatible with the QEMU target that we're going +# to be using when running tests. +RUN curl https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.97.tar.xz | tar xJf - && \ + cp linux.config linux-6.6.97/.config && \ + cd /build/linux-6.6.97 && \ + make olddefconfig && \ + make -j$(nproc) Image && \ + cp arch/riscv/boot/Image /tmp && \ + rm -rf linux-6.6.97 + +# Compile an instance of busybox as this provides a lightweight system and init +# binary which we will boot into. Only trick here is configuring busybox to +# build static binaries. +RUN curl https://www.busybox.net/downloads/busybox-1.37.0.tar.bz2 | tar xjf - && \ + cd busybox-1.37.0 && \ + make defconfig && \ + sed -i 's/# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config && \ + sed -i 's/^CONFIG_TC=y$/# CONFIG_TC is not set/' .config && \ + sed -i 's/CONFIG_SHA1_HWACCEL=y/# CONFIG_SHA1_HWACCEL is not set/' .config && \ + sed -i 's/CONFIG_SHA256_HWACCEL=y/# CONFIG_SHA256_HWACCEL is not set/' .config && \ + make -j$(nproc) && \ + make install && \ + mv _install /tmp/rootfs && \ + cd /build && \ + rm -rf busybox-1.37.0 + +# Download the ubuntu rootfs, which we'll use as a chroot for all our tests. +WORKDIR /tmp +RUN mkdir rootfs/ubuntu +RUN curl https://cdimage.ubuntu.com/ubuntu-base/releases/24.04/release/ubuntu-base-24.04.2-base-riscv64.tar.gz | \ + tar xzf - -C rootfs/ubuntu && \ + cd rootfs && mkdir proc sys dev etc etc/init.d + +# Copy over our init script, which starts up our test server and also a few other +# misc tasks +COPY scripts/qemu-bare-bones-rcS rootfs/etc/init.d/rcS +RUN chmod +x rootfs/etc/init.d/rcS + +# Helper to quickly fill the entropy pool in the kernel +COPY scripts/qemu-bare-bones-addentropy.c /tmp/addentropy.c +RUN riscv64-linux-gnu-gcc addentropy.c -o rootfs/addentropy -static + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + +# Avoid "fatal: detected dubious ownership in repository at '/checkout'" error +RUN git config --global --add safe.directory "*" + +ENV RUST_CONFIGURE_ARGS \ + --set target.riscv64a23-unknown-linux-gnu.linker=riscv64-linux-gnu-gcc \ + --set target.riscv64a23-unknown-linux-gnu.qemu-rootfs=/tmp/rootfs +ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target riscv64a23-unknown-linux-gnu + +ENV NO_CHANGE_USER=1 diff --git a/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/linux.config b/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/linux.config new file mode 100644 index 00000000000..5142664742f --- /dev/null +++ b/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/linux.config @@ -0,0 +1,51 @@ +CONFIG_DEFAULT_HOSTNAME="busybear" +CONFIG_SYSVIPC=y +CONFIG_POSIX_MQUEUE=y +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +CONFIG_CGROUPS=y +CONFIG_CGROUP_SCHED=y +CONFIG_CFS_BANDWIDTH=y +CONFIG_CGROUP_BPF=y +CONFIG_NAMESPACES=y +CONFIG_USER_NS=y +CONFIG_CHECKPOINT_RESTORE=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_EXPERT=y +CONFIG_BPF_SYSCALL=y +CONFIG_SMP=y +CONFIG_MODULES=y +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_PACKET_DIAG=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_NETLINK_DIAG=y +# CONFIG_WIRELESS is not set +CONFIG_PCI=y +CONFIG_DEVTMPFS=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_VIRTIO_BLK=y +CONFIG_NETDEVICES=y +CONFIG_VIRTIO_NET=y +# CONFIG_ETHERNET is not set +# CONFIG_WLAN is not set +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_HVC_RISCV_SBI=y +# CONFIG_HW_RANDOM is not set +# CONFIG_USB_SUPPORT is not set +CONFIG_VIRTIO_MMIO=y +CONFIG_SIFIVE_PLIC=y +CONFIG_RAS=y +CONFIG_EXT2_FS=y +CONFIG_EXT3_FS=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_AUTOFS4_FS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_TMPFS=y +# CONFIG_CRYPTO_ECHAINIV is not set +# CONFIG_CRYPTO_HW is not set +CONFIG_PRINTK_TIME=y diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 0520eff0fa2..4f26c170de0 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -40,6 +40,7 @@ static HOSTS: &[&str] = &[ "powerpc64le-unknown-linux-gnu", "powerpc64le-unknown-linux-musl", "riscv64gc-unknown-linux-gnu", + "riscv64a23-unknown-linux-gnu", "s390x-unknown-linux-gnu", "sparcv9-sun-solaris", "x86_64-apple-darwin", @@ -155,6 +156,7 @@ static TARGETS: &[&str] = &[ "riscv64gc-unknown-none-elf", "riscv64gc-unknown-linux-gnu", "riscv64gc-unknown-linux-musl", + "riscv64a23-unknown-linux-gnu", "s390x-unknown-linux-gnu", "sparc64-unknown-linux-gnu", "sparcv9-sun-solaris", diff --git a/src/tools/remote-test-client/src/main.rs b/src/tools/remote-test-client/src/main.rs index b9741431b50..e5b51722f92 100644 --- a/src/tools/remote-test-client/src/main.rs +++ b/src/tools/remote-test-client/src/main.rs @@ -111,7 +111,9 @@ fn prepare_rootfs(target: &str, rootfs: &Path, server: &Path, rootfs_img: &Path) "arm-unknown-linux-gnueabihf" | "aarch64-unknown-linux-gnu" => { prepare_rootfs_cpio(rootfs, rootfs_img) } - "riscv64gc-unknown-linux-gnu" => prepare_rootfs_ext4(rootfs, rootfs_img), + "riscv64a23-unknown-linux-gnu" | "riscv64gc-unknown-linux-gnu" => { + prepare_rootfs_ext4(rootfs, rootfs_img) + } _ => panic!("{} is not supported", target), } } @@ -234,6 +236,31 @@ fn start_qemu_emulator(target: &str, rootfs: &Path, server: &Path, tmpdir: &Path .arg(&format!("file={},format=raw,id=hd0", &rootfs_img.to_string_lossy())); t!(cmd.spawn()); } + "riscv64a23-unknown-linux-gnu" => { + let mut cmd = Command::new("qemu-system-riscv64"); + cmd.arg("-nographic") + .arg("-machine") + .arg("virt") + .arg("-cpu") + .arg("rva23s64") + .arg("-m") + .arg("1024") + .arg("-bios") + .arg("/tmp/fw_jump.bin") + .arg("-kernel") + .arg("/tmp/Image") + .arg("-append") + .arg("quiet console=ttyS0 root=/dev/vda rw") + .arg("-netdev") + .arg("user,id=net0,hostfwd=tcp::12345-:12345") + .arg("-device") + .arg("virtio-net-device,netdev=net0,mac=00:00:00:00:00:00") + .arg("-device") + .arg("virtio-blk-device,drive=hd0") + .arg("-drive") + .arg(&format!("file={},format=raw,id=hd0,if=none", &rootfs_img.to_string_lossy())); + t!(cmd.spawn()); + } _ => panic!("cannot start emulator for: {}", target), } } |
