Skip to content

Commit 879bb22

Browse files
Rollup merge of #145076 - ZhongyaoChen:feature/add-tier3-riscv64a23-target, r=davidtwco
Add new Tier-3 target: riscv64a23-unknown-linux-gnu MCP: [Tier 3 target proposal: riscv64a23-unknown-linux-gnu](rust-lang/compiler-team#894) Changes: - add new target: riscv64a23-unknown-linux-gnu - add target page
2 parents 5a74ce8 + 45ea228 commit 879bb22

File tree

10 files changed

+121
-1
lines changed

10 files changed

+121
-1
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
279279
}
280280
("loongarch32" | "loongarch64", "32s") if get_version().0 < 21 => None,
281281
// Filter out features that are not supported by the current LLVM version
282-
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,
282+
("riscv32" | "riscv64", "zacas" | "rva23u64" | "supm") if get_version().0 < 20 => None,
283283
(
284284
"s390x",
285285
"message-security-assist-extension12"

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,7 @@ supported_targets! {
21502150
("riscv64gc-unknown-none-elf", riscv64gc_unknown_none_elf),
21512151
("riscv64gc-unknown-linux-gnu", riscv64gc_unknown_linux_gnu),
21522152
("riscv64gc-unknown-linux-musl", riscv64gc_unknown_linux_musl),
2153+
("riscv64a23-unknown-linux-gnu", riscv64a23_unknown_linux_gnu),
21532154

21542155
("sparc-unknown-none-elf", sparc_unknown_none_elf),
21552156

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use std::borrow::Cow;
2+
3+
use crate::spec::{CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base};
4+
5+
pub(crate) fn target() -> Target {
6+
Target {
7+
llvm_target: "riscv64-unknown-linux-gnu".into(),
8+
metadata: TargetMetadata {
9+
description: Some("RISC-V Linux (kernel 6.8.0, glibc 2.39)".into()),
10+
tier: Some(3),
11+
host_tools: Some(true),
12+
std: Some(true),
13+
},
14+
pointer_width: 64,
15+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
16+
arch: "riscv64".into(),
17+
options: TargetOptions {
18+
code_model: Some(CodeModel::Medium),
19+
cpu: "generic-rv64".into(),
20+
features: "+rva23u64".into(),
21+
llvm_abiname: "lp64d".into(),
22+
max_atomic_width: Some(64),
23+
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
24+
..base::linux_gnu::opts()
25+
},
26+
}
27+
}

compiler/rustc_target/src/target_features.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,49 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
601601
),
602602
("m", Stable, &[]),
603603
("relax", Unstable(sym::riscv_target_feature), &[]),
604+
(
605+
"rva23u64",
606+
Unstable(sym::riscv_target_feature),
607+
&[
608+
"m",
609+
"a",
610+
"f",
611+
"d",
612+
"c",
613+
"b",
614+
"v",
615+
"zicsr",
616+
"zicntr",
617+
"zihpm",
618+
"ziccif",
619+
"ziccrse",
620+
"ziccamoa",
621+
"zicclsm",
622+
"zic64b",
623+
"za64rs",
624+
"zihintpause",
625+
"zba",
626+
"zbb",
627+
"zbs",
628+
"zicbom",
629+
"zicbop",
630+
"zicboz",
631+
"zfhmin",
632+
"zkt",
633+
"zvfhmin",
634+
"zvbb",
635+
"zvkt",
636+
"zihintntl",
637+
"zicond",
638+
"zimop",
639+
"zcmop",
640+
"zcb",
641+
"zfa",
642+
"zawrs",
643+
"supm",
644+
],
645+
),
646+
("supm", Unstable(sym::riscv_target_feature), &[]),
604647
("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
605648
("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
606649
("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct Finder {
3434
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
3535
const STAGE0_MISSING_TARGETS: &[&str] = &[
3636
"armv7a-vex-v5",
37+
"riscv64a23-unknown-linux-gnu",
3738
// just a dummy comment so the list doesn't get onelined
3839
"aarch64_be-unknown-hermit",
3940
"aarch64_be-unknown-none-softfloat",

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
- [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md)
108108
- [riscv64gc-unknown-linux-gnu](platform-support/riscv64gc-unknown-linux-gnu.md)
109109
- [riscv64gc-unknown-linux-musl](platform-support/riscv64gc-unknown-linux-musl.md)
110+
- [riscv64a23-unknown-linux-gnu](platform-support/riscv64a23-unknown-linux-gnu.md)
110111
- [s390x-unknown-linux-gnu](platform-support/s390x-unknown-linux-gnu.md)
111112
- [s390x-unknown-linux-musl](platform-support/s390x-unknown-linux-musl.md)
112113
- [sparc-unknown-none-elf](./platform-support/sparc-unknown-none-elf.md)

src/doc/rustc/src/platform-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ target | std | host | notes
392392
[`riscv64gc-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 64bit with NuttX
393393
[`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64
394394
[`riscv64imac-unknown-nuttx-elf`](platform-support/nuttx.md) | ✓ | | RISC-V 64bit with NuttX
395+
[`riscv64a23-unknown-linux-gnu`](platform-support/riscv64a23-unknown-linux-gnu.md) | ✓ | ✓ | RISC-V Linux (kernel 6.8.0+, glibc 2.39)
395396
[`s390x-unknown-linux-musl`](platform-support/s390x-unknown-linux-musl.md) | ✓ | | S390x Linux (kernel 3.2, musl 1.2.3)
396397
`sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux
397398
[`sparc-unknown-none-elf`](./platform-support/sparc-unknown-none-elf.md) | * | | Bare 32-bit SPARC V7+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# `riscv64a23-unknown-linux-gnu`
2+
3+
**Tier: 3**
4+
5+
RISC-V target using the ratified [RVA23 Profile](https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc).
6+
This target will enable all mandary features of rva23u64 by default.
7+
8+
## Target maintainers
9+
10+
[@ZhongyaoChen](https://github.com/ZhongyaoChen)
11+
[@CaiWeiran](https://github.com/CaiWeiran)
12+
13+
## Requirements
14+
15+
This target can be sucessfully build on the following platform: ubuntu 24.04 (Linux Kernel version 6.8.0, glibc 2.39).
16+
17+
Other platforms may work, but are not tested. Please contanct if you encounter any issues.
18+
19+
## Building the target
20+
21+
Tier-3 target is not distributed through `rustup`.
22+
23+
You need to build your own Rust, the target can be build with:
24+
25+
```bash
26+
./x build --target riscv64a23-unknown-linux-gnu
27+
```
28+
29+
## Building Rust programs
30+
31+
Add the toolchain:
32+
33+
```bash
34+
rustup toolchain link rva23-toolchain {path-to-rust}/build/host/stage2
35+
```
36+
37+
Then cross compile crates with:
38+
39+
```bash
40+
RUSTFLAGS="-C linker=riscv64-linux-gnu-gcc" cargo +rva23-toolchain build --target=riscv64a23-unknown-linux-gnu
41+
```

tests/assembly-llvm/targets/targets-elf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@
484484
//@ revisions: riscv64gc_unknown_linux_gnu
485485
//@ [riscv64gc_unknown_linux_gnu] compile-flags: --target riscv64gc-unknown-linux-gnu
486486
//@ [riscv64gc_unknown_linux_gnu] needs-llvm-components: riscv
487+
//@ revisions: riscv64a23_unknown_linux_gnu
488+
//@ [riscv64a23_unknown_linux_gnu] compile-flags: --target riscv64a23-unknown-linux-gnu
489+
//@ [riscv64a23_unknown_linux_gnu] needs-llvm-components: riscv
487490
//@ revisions: riscv64gc_unknown_linux_musl
488491
//@ [riscv64gc_unknown_linux_musl] compile-flags: --target riscv64gc-unknown-linux-musl
489492
//@ [riscv64gc_unknown_linux_musl] needs-llvm-components: riscv

tests/ui/check-cfg/target_feature.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
243243
`relax`
244244
`relaxed-simd`
245245
`rtm`
246+
`rva23u64`
246247
`sb`
247248
`scq`
248249
`sha`
@@ -304,6 +305,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
304305
`ssve-fp8dot2`
305306
`ssve-fp8dot4`
306307
`ssve-fp8fma`
308+
`supm`
307309
`sve`
308310
`sve-b16b16`
309311
`sve2`

0 commit comments

Comments
 (0)