Skip to content

Commit 2ef3779

Browse files
authored
Unrolled build for #150863
Rollup merge of #150863 - ferrocene:add-aarch64v8r-targets, r=wesleywiser Adds two new Tier 3 targets - `aarch64v8r-unknown-none{,-softfloat}` ## New Tier 3 targets - `aarch64v8r-unknown-none` and `aarch64v8r-unknown-none-softfloat` This PR 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. These targets are in support of firmware development on upcoming systems using the Arm Cortex-R82, particularly safety-critical firmware development. For now, it can be tested using the Arm's Armv8-R AArch64 Fixed Virtual Platform emulator, which we have used to test this target. We are also in the process of testing this target with the full compiler test suite as part of Ferrocene, in the same way we test `aarch64-unknown-none` to a safety-qualified standard. We have not identified any issues as yet, but if we do, we will send the fixes upstream to you. ## Ownership This PR was developed by Ferrous Systems on behalf of Arm. Arm is the owner of these changes. ## Tier 3 Policy Notes To cover off the Tier 3 requirements: > A tier 3 target must have a designated developer or developers Arm will maintain this target, and I have presumed the Embedded Devices Working Group will also take an interest, as they maintain the existing Arm bare-metal targets. > Targets must use naming consistent with any existing targets We prefix this target with `aarch64` because it generates A64 machine code (like `arm*` generates A32 and `thumb*` generates T32). In an ideal world I'd get to rename the existing target `aarch64v8a-unknown-none` but that's basically impossible at this point. You can assume `v6` for any `arm*` target where unspecified, and you can assume `v8a` for any `aarch64*` target where not specified. > Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users. It works just like the existing AArch64 bare-metal target. > Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions. Noted. > Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate. It's a bare-metal target, offering libcore and liballoc. > The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. Done > Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. AArch64 is a Tier 1 architecture, so I don't expect this target to cause any issues. > Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. Noted. > Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. It's AArch64 and so works with LLVM.
2 parents b3cda16 + 6ecb3f3 commit 2ef3779

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
@@ -1709,6 +1709,8 @@ supported_targets! {
17091709
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
17101710
("aarch64_be-unknown-none-softfloat", aarch64_be_unknown_none_softfloat),
17111711
("aarch64-unknown-nuttx", aarch64_unknown_nuttx),
1712+
("aarch64v8r-unknown-none", aarch64v8r_unknown_none),
1713+
("aarch64v8r-unknown-none-softfloat", aarch64v8r_unknown_none_softfloat),
17121714

17131715
("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),
17141716

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
@@ -46,6 +46,8 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
4646
"armv6-none-eabi",
4747
"armv6-none-eabihf",
4848
"thumbv6-none-eabi",
49+
"aarch64v8r-unknown-none",
50+
"aarch64v8r-unknown-none-softfloat",
4951
];
5052

5153
/// 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
@@ -275,6 +275,8 @@ target | std | host | notes
275275
[`aarch64-unknown-trusty`](platform-support/trusty.md) | ✓ | |
276276
[`aarch64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
277277
[`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS
278+
[`aarch64v8r-unknown-none`](platform-support/aarch64v8r-unknown-none.md) | * | | Bare Armv8-R in AArch64 mode, hardfloat
279+
[`aarch64v8r-unknown-none-softfloat`](platform-support/aarch64v8r-unknown-none.md) | * | | Bare Armv8-R in AArch64 mode, softfloat
278280
[`aarch64_be-unknown-hermit`](platform-support/hermit.md) | ✓ | | ARM64 Hermit (big-endian)
279281
`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian)
280282
`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
@@ -15,6 +15,9 @@ and [Cortex-R52+][cortex-r52-plus].
1515
See [`arm-none-eabi`](arm-none-eabi.md) for information applicable to all
1616
`arm-none-eabi` targets.
1717

18+
For Armv8-R CPUs running in AArch64 mode (such as the Arm Cortex-R82), see
19+
[`aarch64v8r-unknown-none`](aarch64v8r-unknown-none.md) instead.
20+
1821
[cortex-r52]: https://www.arm.com/products/silicon-ip-cpu/cortex-r/cortex-r52
1922
[cortex-r52-plus]: https://www.arm.com/products/silicon-ip-cpu/cortex-r/cortex-r52-plus
2023

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)