Skip to content
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
None
}
// Filter out features that are not supported by the current LLVM version
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,
("riscv32" | "riscv64", "zacas" | "rva23u64" | "supm") if get_version().0 < 20 => None,
(
"s390x",
"message-security-assist-extension12"
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
Original file line number Diff line number Diff line change
@@ -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 6.8.0, glibc 2.39)".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".into(),
llvm_abiname: "lp64d".into(),
max_atomic_width: Some(64),
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
..base::linux_gnu::opts()
},
}
}
43 changes: 43 additions & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,49 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
),
("m", Stable, &[]),
("relax", Unstable(sym::riscv_target_feature), &[]),
(
"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",
],
),
("supm", 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"]),
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
];

Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 6.8.0+, glibc 2.39)
[`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+
Expand Down
41 changes: 41 additions & 0 deletions src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# `riscv64a23-unknown-linux-gnu`

**Tier: 3**

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 by default.

## Target maintainers

[@ZhongyaoChen](https://github.com/ZhongyaoChen)
[@CaiWeiran](https://github.com/CaiWeiran)

## Requirements

This target can be sucessfully build on the following platform: ubuntu 24.04 (Linux Kernel version 6.8.0, glibc 2.39).

Other platforms may work, but are not tested. Please contanct if you encounter any issues.

## Building the target

Tier-3 target is not distributed through `rustup`.

You need to build your own Rust, the target can be build with:

```bash
./x build --target riscv64a23-unknown-linux-gnu
```

## Building Rust programs

Add the toolchain:

```bash
rustup toolchain link rva23-toolchain {path-to-rust}/build/host/stage2
```

Then cross compile crates with:

```bash
RUSTFLAGS="-C linker=riscv64-linux-gnu-gcc" cargo +rva23-toolchain build --target=riscv64a23-unknown-linux-gnu
```
3 changes: 3 additions & 0 deletions tests/assembly-llvm/targets/targets-elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/check-cfg/target_feature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`relax`
`relaxed-simd`
`rtm`
`rva23u64`
`sb`
`scq`
`sha`
Expand Down Expand Up @@ -302,6 +303,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`ssve-fp8dot2`
`ssve-fp8dot4`
`ssve-fp8fma`
`supm`
`sve`
`sve-b16b16`
`sve2`
Expand Down
Loading