Skip to content

Commit 5cf807e

Browse files
jonathanpallantjaparic
authored andcommitted
Adds two new Tier 3 targets - aarch64v8r-unknown-none and aarch64v8r-unknown-none-softfloat.
The existing `aarch64-unknown-none` target assumes Armv8.0-A as a baseline. However, Arm recently released the Arm Cortex-R82 processor which is the first to implement the Armv8-R AArch64 mode architecture. This architecture is similar to Armv8-A AArch64, however it has a different set of mandatory features, and is based off of Armv8.4. It is largely unrelated to the existing Armv8-R architecture target (`armv8r-none-eabihf`), which only operates in AArch32 mode. The second `aarch64v8r-unknown-none-softfloat` target allows for possible Armv8-R AArch64 CPUs with no FPU, or for use-cases where FPU register stacking is not desired. As with the existing `aarch64-unknown-none` target we have coupled FPU support and Neon support together - there is no 'has FPU but does not have NEON' target proposed even though the architecture technically allows for it. This PR was developed by Ferrous Systems on behalf of Arm. Arm is the owner of these changes.
1 parent d29e478 commit 5cf807e

26 files changed

Lines changed: 401 additions & 15 deletions

compiler/rustc_target/src/spec/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,8 @@ supported_targets! {
17041704
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
17051705
("aarch64_be-unknown-none-softfloat", aarch64_be_unknown_none_softfloat),
17061706
("aarch64-unknown-nuttx", aarch64_unknown_nuttx),
1707+
("aarch64v8r-unknown-none", aarch64v8r_unknown_none),
1708+
("aarch64v8r-unknown-none-softfloat", aarch64v8r_unknown_none_softfloat),
17071709

17081710
("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),
17091711

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use crate::spec::{
2+
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
3+
TargetMetadata, TargetOptions,
4+
};
5+
6+
pub(crate) fn target() -> Target {
7+
let opts = TargetOptions {
8+
// based off the aarch64-unknown-none target at time of addition
9+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
10+
linker: Some("rust-lld".into()),
11+
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
12+
relocation_model: RelocModel::Static,
13+
disable_redzone: true,
14+
max_atomic_width: Some(128),
15+
stack_probes: StackProbeType::Inline,
16+
panic_strategy: PanicStrategy::Abort,
17+
default_uwtable: true,
18+
19+
// deviations from aarch64-unknown-none: `+v8a` -> `+v8r`; `+v8r` implies `+neon`
20+
features: "+v8r,+strict-align".into(),
21+
..Default::default()
22+
};
23+
Target {
24+
llvm_target: "aarch64-unknown-none".into(),
25+
metadata: TargetMetadata {
26+
description: Some("Bare Armv8-R AArch64, hardfloat".into()),
27+
tier: Some(3),
28+
host_tools: Some(false),
29+
std: Some(false),
30+
},
31+
pointer_width: 64,
32+
// $ clang-21 -S -emit-llvm -target aarch64 -mcpu=cortex-r82 stub.c
33+
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
34+
arch: Arch::AArch64,
35+
options: opts,
36+
}
37+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use crate::spec::{
2+
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
3+
Target, TargetMetadata, TargetOptions,
4+
};
5+
6+
pub(crate) fn target() -> Target {
7+
let opts = TargetOptions {
8+
abi: Abi::SoftFloat,
9+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
10+
linker: Some("rust-lld".into()),
11+
relocation_model: RelocModel::Static,
12+
disable_redzone: true,
13+
max_atomic_width: Some(128),
14+
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
15+
stack_probes: StackProbeType::Inline,
16+
panic_strategy: PanicStrategy::Abort,
17+
default_uwtable: true,
18+
19+
// deviations from aarch64-unknown-none: `+v8a` -> `+v8r`
20+
features: "+v8r,+strict-align,-neon".into(),
21+
..Default::default()
22+
};
23+
Target {
24+
llvm_target: "aarch64-unknown-none".into(),
25+
metadata: TargetMetadata {
26+
description: Some("Bare Armv8-R AArch64, softfloat".into()),
27+
tier: Some(3),
28+
host_tools: Some(false),
29+
std: Some(false),
30+
},
31+
pointer_width: 64,
32+
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
33+
arch: Arch::AArch64,
34+
options: opts,
35+
}
36+
}

src/bootstrap/src/core/sanity.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub struct Finder {
3838
const STAGE0_MISSING_TARGETS: &[&str] = &[
3939
// just a dummy comment so the list doesn't get onelined
4040
"x86_64-unknown-linux-gnuasan",
41+
"aarch64v8r-unknown-none",
42+
"aarch64v8r-unknown-none-softfloat",
4143
];
4244

4345
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
- [aarch64-unknown-linux-gnu](platform-support/aarch64-unknown-linux-gnu.md)
5151
- [aarch64-unknown-linux-musl](platform-support/aarch64-unknown-linux-musl.md)
5252
- [aarch64-unknown-none*](platform-support/aarch64-unknown-none.md)
53+
- [aarch64v8r-unknown-none*](platform-support/aarch64v8r-unknown-none.md)
5354
- [aarch64_be-unknown-none-softfloat](platform-support/aarch64_be-unknown-none-softfloat.md)
5455
- [aarch64_be-unknown-linux-musl](platform-support/aarch64_be-unknown-linux-musl.md)
5556
- [amdgcn-amd-amdhsa](platform-support/amdgcn-amd-amdhsa.md)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ target | std | host | notes
274274
[`aarch64-unknown-trusty`](platform-support/trusty.md) | ✓ | |
275275
[`aarch64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
276276
[`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS
277+
[`aarch64v8r-unknown-none`](platform-support/aarch64v8r-unknown-none.md) | * | | Bare Armv8-R in AArch64 mode, hardfloat
278+
[`aarch64v8r-unknown-none-softfloat`](platform-support/aarch64v8r-unknown-none.md) | * | | Bare Armv8-R in AArch64 mode, softfloat
277279
[`aarch64_be-unknown-hermit`](platform-support/hermit.md) | ✓ | | ARM64 Hermit (big-endian)
278280
`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian)
279281
`aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# `aarch64v8r-unknown-none` and `aarch64v8r-unknown-none-softfloat`
2+
3+
* **Tier: 3**
4+
* **Library Support:** core and alloc (bare-metal, `#![no_std]`)
5+
6+
Bare-metal target for CPUs in the Armv8-R architecture family, running in
7+
AArch64 mode. Processors in this family include the
8+
[Arm Cortex-R82][cortex-r82].
9+
10+
For Armv8-R CPUs running in AArch32 mode (such as the Arm Cortex-R52), see
11+
[`armv8r-none-eabihf`](armv8r-none-eabihf.md) instead.
12+
13+
[cortex-r82]: https://developer.arm.com/processors/Cortex-R82
14+
15+
## Target maintainers
16+
17+
- [Rust Embedded Devices Working Group Arm Team]
18+
- [@rust-lang/arm-maintainers][arm_maintainers] ([rust@arm.com][arm_email])
19+
20+
[Rust Embedded Devices Working Group Arm Team]: https://github.com/rust-embedded/wg?tab=readme-ov-file#the-arm-team
21+
[arm_maintainers]: https://github.com/rust-lang/team/blob/master/teams/arm-maintainers.toml
22+
[arm_email]: mailto:rust@arm.com
23+
24+
## Target CPU and Target Feature options
25+
26+
Unlike AArch64 v8-A processors, not all AArch64 v8-R processors include an FPU
27+
(that is, not all Armv8-R AArch64 processors implement the optional Armv8
28+
`FEAT_FP` extension). If you do not have an FPU, or have an FPU but wish to use
29+
a soft-float ABI anyway, you should use the `aarch64v8r-unknown-none-softfloat`
30+
target. If you wish to use the standard hard-float Arm AArch64 calling
31+
convention, and you have an FPU, you can use the `aarch64v8r-unknown-none`
32+
target.
33+
34+
When using the `aarch64v8r-unknown-none` target, the minimum floating-point
35+
features assumed are the Advanced SIMD features (`FEAT_AdvSIMD`, or `+neon`),
36+
the implementation of which is branded Arm NEON.
37+
38+
If your processor supports a different set of floating-point features than the
39+
default expectations then these should also be enabled or disabled as needed
40+
with [`-C target-feature=(+/-)`][target-feature]. However, note that currently
41+
Rust does not support building hard-float AArch64 targets with Advanced SIMD
42+
support disabled. It is also possible to tell Rust (or LLVM) that you have a
43+
specific model of Arm processor, using the [`-Ctarget-cpu`][target-cpu] option.
44+
Doing so may change the default set of target-features enabled.
45+
46+
[target-feature]: https://doc.rust-lang.org/rustc/codegen-options/index.html#target-feature
47+
[target-cpu]: https://doc.rust-lang.org/rustc/codegen-options/index.html#target-cpu
48+
49+
## Requirements
50+
51+
These targets are cross-compiled and use static linking.
52+
53+
By default, the `lld` linker included with Rust will be used; however, you may
54+
want to use the GNU linker instead. This can be obtained for Windows/Mac/Linux
55+
from the [Arm Developer Website][arm-gnu-toolchain], or possibly from your OS's
56+
package manager. To use it, add the following to your `.cargo/config.toml`:
57+
58+
```toml
59+
[target.aarch64-unknown-none]
60+
linker = "aarch64-none-elf-ld"
61+
```
62+
63+
The GNU linker can also be used by specifying `aarch64-none-elf-gcc` as the
64+
linker. This is needed when using GCC's link time optimization.
65+
66+
These targets don't provide a linker script, so you'll need to bring your own
67+
according to the specific device you are using. Pass
68+
`-Clink-arg=-Tyour_script.ld` as a rustc argument to make the linker use
69+
`your_script.ld` during linking.
70+
71+
[arm-gnu-toolchain]: https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain
72+
73+
## Cross-compilation toolchains and C code
74+
75+
This target supports C code compiled with the `aarch64-none-elf` target
76+
triple and a suitable `-march` or `-mcpu` flag.
77+
78+
## Start-up and Low-Level Code
79+
80+
The [Rust Embedded Devices Working Group Arm Team] maintain the
81+
[`aarch64-cpu`] crate, which may be useful for writing bare-metal code using
82+
this target.
83+
84+
[`aarch64-cpu`]: https://docs.rs/aarch64-cpu

src/doc/rustc/src/platform-support/armv8r-none-eabihf.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and [Cortex-R52+][cortex-r52-plus].
1212
See [`arm-none-eabi`](arm-none-eabi.md) for information applicable to all
1313
`arm-none-eabi` targets.
1414

15+
For Armv8-R CPUs running in AArch64 mode (such as the Arm Cortex-R82), see
16+
[`aarch64v8r-unknown-none`](aarch64v8r-unknown-none.md) instead.
17+
1518
[cortex-r52]: https://www.arm.com/products/silicon-ip-cpu/cortex-r/cortex-r52
1619
[cortex-r52-plus]: https://www.arm.com/products/silicon-ip-cpu/cortex-r/cortex-r52-plus
1720

src/tools/tidy/src/target_specific_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn arch_to_llvm_component(arch: &str) -> String {
9898
// enough for the purpose of this tidy check.
9999
match arch {
100100
"amdgcn" => "amdgpu".into(),
101-
"aarch64_be" | "arm64_32" | "arm64e" | "arm64ec" => "aarch64".into(),
101+
"aarch64v8r" | "aarch64_be" | "arm64_32" | "arm64e" | "arm64ec" => "aarch64".into(),
102102
"i386" | "i586" | "i686" | "x86" | "x86_64" | "x86_64h" => "x86".into(),
103103
"loongarch32" | "loongarch64" => "loongarch".into(),
104104
"nvptx64" => "nvptx".into(),

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
//@ revisions: aarch64_unknown_none_softfloat
6868
//@ [aarch64_unknown_none_softfloat] compile-flags: --target aarch64-unknown-none-softfloat
6969
//@ [aarch64_unknown_none_softfloat] needs-llvm-components: aarch64
70+
//@ revisions: aarch64v8r_unknown_none
71+
//@ [aarch64v8r_unknown_none] compile-flags: --target aarch64v8r-unknown-none
72+
//@ [aarch64v8r_unknown_none] needs-llvm-components: aarch64
73+
//@ revisions: aarch64v8r_unknown_none_softfloat
74+
//@ [aarch64v8r_unknown_none_softfloat] compile-flags: --target aarch64v8r-unknown-none-softfloat
75+
//@ [aarch64v8r_unknown_none_softfloat] needs-llvm-components: aarch64
7076
//@ revisions: aarch64_unknown_nto_qnx700
7177
//@ [aarch64_unknown_nto_qnx700] compile-flags: --target aarch64-unknown-nto-qnx700
7278
//@ [aarch64_unknown_nto_qnx700] needs-llvm-components: aarch64

0 commit comments

Comments
 (0)