From a4cf5e9eca00527082fd58356e4adc8775aeee03 Mon Sep 17 00:00:00 2001 From: Chen Zhongyao Date: Mon, 14 Jul 2025 13:35:53 +0000 Subject: [PATCH 1/5] Add new Tier-3 target: riscv64a23-unknown-linux-gnu --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 6 +- compiler/rustc_target/src/spec/mod.rs | 1 + .../targets/riscv64a23_unknown_linux_gnu.rs | 27 +++++ compiler/rustc_target/src/target_features.rs | 113 ++++++++++++++++++ src/bootstrap/src/core/sanity.rs | 1 + tests/assembly-llvm/targets/targets-elf.rs | 3 + tests/ui/check-cfg/target_feature.stderr | 16 +++ 7 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 compiler/rustc_target/src/spec/targets/riscv64a23_unknown_linux_gnu.rs diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 28d2100f478cc..a85a894e42c60 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -278,7 +278,11 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option None, + ("riscv32" | "riscv64", "zacas" | "rva23s64" | "rva23u64" | "sha" | "ssnpm" | "supm") + if get_version().0 < 20 => + { + None + } ( "s390x", "message-security-assist-extension12" diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index b9fbff8db05be..d72d8bd2d088f 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2137,6 +2137,7 @@ supported_targets! { ("riscv64gc-unknown-none-elf", riscv64gc_unknown_none_elf), ("riscv64gc-unknown-linux-gnu", riscv64gc_unknown_linux_gnu), ("riscv64gc-unknown-linux-musl", riscv64gc_unknown_linux_musl), + ("riscv64a23-unknown-linux-gnu", riscv64a23_unknown_linux_gnu), ("sparc-unknown-none-elf", sparc_unknown_none_elf), diff --git a/compiler/rustc_target/src/spec/targets/riscv64a23_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/riscv64a23_unknown_linux_gnu.rs new file mode 100644 index 0000000000000..27a0e27c969ae --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64a23_unknown_linux_gnu.rs @@ -0,0 +1,27 @@ +use std::borrow::Cow; + +use crate::spec::{CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; + +pub(crate) fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-linux-gnu".into(), + metadata: TargetMetadata { + description: Some("RISC-V Linux (kernel 4.20, glibc 2.29)".into()), + tier: Some(3), + host_tools: Some(true), + std: Some(true), + }, + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".into(), + features: "+rva23u64,+rva23s64".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 297d9ed84c504..434f6a840b68e 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -597,6 +597,119 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ), ("m", Stable, &[]), ("relax", Unstable(sym::riscv_target_feature), &[]), + ( + "rva23s64", + Unstable(sym::riscv_target_feature), + &[ + "m", + "a", + "f", + "d", + "c", + "b", + "v", + "zicsr", + "zicntr", + "zihpm", + "ziccif", + "ziccrse", + "ziccamoa", + "zicclsm", + "zic64b", + "za64rs", + "zihintpause", + "zba", + "zbb", + "zbs", + "zicbom", + "zicbop", + "zicboz", + "zfhmin", + "zkt", + "zvfhmin", + "zvbb", + "zvkt", + "zihintntl", + "zicond", + "zimop", + "zcmop", + "zcb", + "zfa", + "zawrs", + "svbare", + "svade", + "ssccptr", + "sstvecd", + "sstvala", + "sscounterenw", + "svpbmt", + "svinval", + "svnapot", + "sstc", + "sscofpmf", + "ssnpm", + "ssu64xl", + "sha", + "supm", + ], + ), + ( + "rva23u64", + Unstable(sym::riscv_target_feature), + &[ + "m", + "a", + "f", + "d", + "c", + "b", + "v", + "zicsr", + "zicntr", + "zihpm", + "ziccif", + "ziccrse", + "ziccamoa", + "zicclsm", + "zic64b", + "za64rs", + "zihintpause", + "zba", + "zbb", + "zbs", + "zicbom", + "zicbop", + "zicboz", + "zfhmin", + "zkt", + "zvfhmin", + "zvbb", + "zvkt", + "zihintntl", + "zicond", + "zimop", + "zcmop", + "zcb", + "zfa", + "zawrs", + "supm", + ], + ), + ("sha", Unstable(sym::riscv_target_feature), &[]), + ("ssccptr", Unstable(sym::riscv_target_feature), &[]), + ("sscofpmf", Unstable(sym::riscv_target_feature), &[]), + ("sscounterenw", Unstable(sym::riscv_target_feature), &[]), + ("ssnpm", Unstable(sym::riscv_target_feature), &[]), + ("sstc", Unstable(sym::riscv_target_feature), &[]), + ("sstvala", Unstable(sym::riscv_target_feature), &[]), + ("sstvecd", Unstable(sym::riscv_target_feature), &[]), + ("ssu64xl", Unstable(sym::riscv_target_feature), &[]), + ("supm", Unstable(sym::riscv_target_feature), &[]), + ("svade", Unstable(sym::riscv_target_feature), &[]), + ("svbare", Unstable(sym::riscv_target_feature), &[]), + ("svinval", Unstable(sym::riscv_target_feature), &[]), + ("svnapot", Unstable(sym::riscv_target_feature), &[]), + ("svpbmt", Unstable(sym::riscv_target_feature), &[]), ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]), ("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]), ("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]), diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 3080e641b5bed..a2d5d3f0e3787 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -34,6 +34,7 @@ pub struct Finder { // Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap). const STAGE0_MISSING_TARGETS: &[&str] = &[ "armv7a-vex-v5", + "riscv64a23-unknown-linux-gnu", // just a dummy comment so the list doesn't get onelined ]; diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index ee63dffe9ea44..44f536b6856e8 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -475,6 +475,9 @@ //@ revisions: riscv64gc_unknown_linux_gnu //@ [riscv64gc_unknown_linux_gnu] compile-flags: --target riscv64gc-unknown-linux-gnu //@ [riscv64gc_unknown_linux_gnu] needs-llvm-components: riscv +//@ revisions: riscv64a23_unknown_linux_gnu +//@ [riscv64a23_unknown_linux_gnu] compile-flags: --target riscv64a23-unknown-linux-gnu +//@ [riscv64a23_unknown_linux_gnu] needs-llvm-components: riscv //@ revisions: riscv64gc_unknown_linux_musl //@ [riscv64gc_unknown_linux_musl] compile-flags: --target riscv64gc-unknown-linux-musl //@ [riscv64gc_unknown_linux_musl] needs-llvm-components: riscv diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 44fc23b63906e..a484fb0e5f07d 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -241,6 +241,8 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `relax` `relaxed-simd` `rtm` +`rva23s64` +`rva23u64` `sb` `scq` `sha` @@ -292,16 +294,27 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `soft-float` `spe` `ssbs` +`ssccptr` +`sscofpmf` +`sscounterenw` `sse` `sse2` `sse3` `sse4.1` `sse4.2` `sse4a` +`ssnpm` `ssse3` +`sstc` +`sstvala` +`sstvecd` +`ssu64xl` `ssve-fp8dot2` `ssve-fp8dot4` `ssve-fp8fma` +`supm` +`svade` +`svbare` `sve` `sve-b16b16` `sve2` @@ -310,6 +323,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `sve2-sha3` `sve2-sm4` `sve2p1` +`svinval` +`svnapot` +`svpbmt` `tail-call` `tbm` `thumb-mode` From 988cd14ec1e1d07d8fadc2e76d370e1da8de4f46 Mon Sep 17 00:00:00 2001 From: Chen Zhongyao Date: Mon, 21 Jul 2025 16:31:01 +0000 Subject: [PATCH 2/5] Add a disabled builder for riscv64 rva23 emulated tests This will run all tests for `riscv64a23-unknown-linux-gnu` in a QEMU instance. --- .../disabled/riscv64a23-gnu/Dockerfile | 108 ++++++++++++++++++ .../disabled/riscv64a23-gnu/linux.config | 51 +++++++++ src/tools/build-manifest/src/main.rs | 2 + src/tools/remote-test-client/src/main.rs | 29 ++++- 4 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile create mode 100644 src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/linux.config 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 0000000000000..86b0d795687c7 --- /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 0000000000000..5142664742f20 --- /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 0520eff0fa277..4f26c170de063 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 b9741431b5034..e5b51722f92ae 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), } } From 31ae666f0f57a5fefd924a9945e5aca816c001f8 Mon Sep 17 00:00:00 2001 From: Zhongyao Chen Date: Tue, 29 Jul 2025 21:20:03 +0000 Subject: [PATCH 3/5] Add target page for riscv64a23-unknown-linux-gnu --- src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/platform-support.md | 1 + .../riscv64a23-unknown-linux-gnu.md | 66 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 25f154f11807c..79e229595c836 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -104,6 +104,7 @@ - [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md) - [riscv64gc-unknown-linux-gnu](platform-support/riscv64gc-unknown-linux-gnu.md) - [riscv64gc-unknown-linux-musl](platform-support/riscv64gc-unknown-linux-musl.md) + - [riscv64a23-unknown-linux-gnu](platform-support/riscv64a23-unknown-linux-gnu.md) - [s390x-unknown-linux-gnu](platform-support/s390x-unknown-linux-gnu.md) - [s390x-unknown-linux-musl](platform-support/s390x-unknown-linux-musl.md) - [sparc-unknown-none-elf](./platform-support/sparc-unknown-none-elf.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 8ebaa8dd8747b..cf55d4bd68fad 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -389,6 +389,7 @@ target | std | host | notes [`riscv64gc-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 64bit with NuttX [`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64 [`riscv64imac-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 64bit with NuttX +[`riscv64a23-unknown-linux-gnu`](platform-support/riscv64a23-unknown-linux-gnu.md) | ✓ | ✓ | RISC-V Linux (kernel 4.20+, glibc 2.29) [`s390x-unknown-linux-musl`](platform-support/s390x-unknown-linux-musl.md) | ✓ | | S390x Linux (kernel 3.2, musl 1.2.3) `sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux [`sparc-unknown-none-elf`](./platform-support/sparc-unknown-none-elf.md) | * | | Bare 32-bit SPARC V7+ diff --git a/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md b/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md new file mode 100644 index 0000000000000..00790ba197f1f --- /dev/null +++ b/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md @@ -0,0 +1,66 @@ +# `riscv64a23-unknown-linux-gnu` + +**Tier: 3** + +RISC-V targets using the ratified [RVA23 Profile](https://github.com/riscv/riscv-profiles/blob/main/rva23-profile.adoc). +This target will enable all mandary features of rva23u64 and rva23s64 by default. + + +## Target maintainers + +[@ZhongyaoChen](https://github.com/ZhongyaoChen) +[@CaiWeiran](https://github.com/CaiWeiran) + +## Requirements + +This target requires: + +* Linux Kernel version 4.20 or later +* glibc 2.17 or later + + +## Building the target + +The target is distributed through `rustup`, and otherwise require no +special configuration. + +If you need to build your own Rust for some reason though, the target can be build with: + +```bash +./x build --target riscv64a23-unknown-linux-gnu +``` + +## Building Rust programs + +Add the target: + +```bash +rustup target add riscv64a23-unknown-linux-gnu +``` + +Then cross compile crates with: + +```bash +cargo build --target riscv64a23-unknown-linux-gnu +``` + +## Cross-compilation toolchains and Testing + +On Ubuntu 24.04, we can install compilation dependencies with: + +```bash +apt install -y git python3 g++ g++-riscv64-linux-gnu +``` + +Then build target with: + +```bash +./x build --target=riscv64a23-unknown-linux-gnu +``` + +There are no special requirements for testing and running the targets. +For testing cross-builds on the host, you can use the docker image. It will automatically set up a RISC-V QEMU emulator and run all the test suite. + +```bash +DEPLOY=1 ./src/ci/docker/run.sh riscv64a23-gnu +``` From 93a8c1d12cee1af04d84ffc59597dbd877de671f Mon Sep 17 00:00:00 2001 From: zhongyao Date: Fri, 8 Aug 2025 14:42:51 +0800 Subject: [PATCH 4/5] Update src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com> --- .../riscv64a23-unknown-linux-gnu.md | 36 ++++--------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md b/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md index 00790ba197f1f..6db4a67293688 100644 --- a/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md +++ b/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md @@ -2,10 +2,9 @@ **Tier: 3** -RISC-V targets using the ratified [RVA23 Profile](https://github.com/riscv/riscv-profiles/blob/main/rva23-profile.adoc). +RISC-V target using the ratified [RVA23 Profile](https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc). This target will enable all mandary features of rva23u64 and rva23s64 by default. - ## Target maintainers [@ZhongyaoChen](https://github.com/ZhongyaoChen) @@ -18,13 +17,11 @@ This target requires: * Linux Kernel version 4.20 or later * glibc 2.17 or later - ## Building the target -The target is distributed through `rustup`, and otherwise require no -special configuration. +Tier-3 target is not distributed through `rustup`. -If you need to build your own Rust for some reason though, the target can be build with: +You need to build your own Rust, the target can be build with: ```bash ./x build --target riscv64a23-unknown-linux-gnu @@ -32,35 +29,14 @@ If you need to build your own Rust for some reason though, the target can be bui ## Building Rust programs -Add the target: +Add the toolchain: ```bash -rustup target add riscv64a23-unknown-linux-gnu +rustup toolchain link rva23-toolchain {path-to-rust}/build/host/stage2 ``` Then cross compile crates with: ```bash -cargo build --target riscv64a23-unknown-linux-gnu -``` - -## Cross-compilation toolchains and Testing - -On Ubuntu 24.04, we can install compilation dependencies with: - -```bash -apt install -y git python3 g++ g++-riscv64-linux-gnu -``` - -Then build target with: - -```bash -./x build --target=riscv64a23-unknown-linux-gnu -``` - -There are no special requirements for testing and running the targets. -For testing cross-builds on the host, you can use the docker image. It will automatically set up a RISC-V QEMU emulator and run all the test suite. - -```bash -DEPLOY=1 ./src/ci/docker/run.sh riscv64a23-gnu +RUSTFLAGS="-C linker=riscv64-linux-gnu-gcc" cargo +rva23-toolchain build --target=riscv64a23-unknown-linux-gnu ``` From 87fd28998c92a014935d879ae0129b09baa56588 Mon Sep 17 00:00:00 2001 From: Zhongyao Chen Date: Sat, 9 Aug 2025 12:27:38 +0000 Subject: [PATCH 5/5] Revert "Add a disabled builder for riscv64 rva23 emulated tests" This reverts commit 289688ca494ddc45bcd0b0706dc173c19fbb7caa. --- .../disabled/riscv64a23-gnu/Dockerfile | 108 ------------------ .../disabled/riscv64a23-gnu/linux.config | 51 --------- src/tools/build-manifest/src/main.rs | 2 - src/tools/remote-test-client/src/main.rs | 29 +---- 4 files changed, 1 insertion(+), 189 deletions(-) delete mode 100644 src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile delete mode 100644 src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/linux.config diff --git a/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile b/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile deleted file mode 100644 index 86b0d795687c7..0000000000000 --- a/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/Dockerfile +++ /dev/null @@ -1,108 +0,0 @@ -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 deleted file mode 100644 index 5142664742f20..0000000000000 --- a/src/ci/docker/host-x86_64/disabled/riscv64a23-gnu/linux.config +++ /dev/null @@ -1,51 +0,0 @@ -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 4f26c170de063..0520eff0fa277 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -40,7 +40,6 @@ 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", @@ -156,7 +155,6 @@ 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 e5b51722f92ae..b9741431b5034 100644 --- a/src/tools/remote-test-client/src/main.rs +++ b/src/tools/remote-test-client/src/main.rs @@ -111,9 +111,7 @@ 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) } - "riscv64a23-unknown-linux-gnu" | "riscv64gc-unknown-linux-gnu" => { - prepare_rootfs_ext4(rootfs, rootfs_img) - } + "riscv64gc-unknown-linux-gnu" => prepare_rootfs_ext4(rootfs, rootfs_img), _ => panic!("{} is not supported", target), } } @@ -236,31 +234,6 @@ 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), } }