Skip to content

Add new Tier-3 target: riscv64a23-unknown-linux-gnu #145076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 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,11 @@ 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" | "rva23s64" | "rva23u64" | "sha" | "ssnpm" | "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 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()
},
}
}
113 changes: 113 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,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"]),
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 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+
Expand Down
42 changes: 42 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,42 @@
# `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 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

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
16 changes: 16 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,8 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`relax`
`relaxed-simd`
`rtm`
`rva23s64`
`rva23u64`
`sb`
`scq`
`sha`
Expand Down Expand Up @@ -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`
Expand All @@ -310,6 +323,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`sve2-sha3`
`sve2-sm4`
`sve2p1`
`svinval`
`svnapot`
`svpbmt`
`tail-call`
`tbm`
`thumb-mode`
Expand Down
Loading