Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 071179a

Browse files
committed
Add NuttX support for AArch64 and ARMv7-A targets
This patch adds tier 3 support for AArch64 and ARMv7-A targets in NuttX, including: - AArch64 target: aarch64-unknown-nuttx - ARMv7-A target: armv7a-nuttx-eabi, armv7a-nuttx-eabihf - Thumbv7-A target: thumbv7a-nuttx-eabi, thumbv7a-nuttx-eabihf Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
1 parent 1d55f72 commit 071179a

File tree

9 files changed

+229
-2
lines changed

9 files changed

+229
-2
lines changed

‎compiler/rustc_target/src/spec/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,8 @@ supported_targets! {
18531853

18541854
("armv7a-none-eabi", armv7a_none_eabi),
18551855
("armv7a-none-eabihf", armv7a_none_eabihf),
1856+
("armv7a-nuttx-eabi", armv7a_nuttx_eabi),
1857+
("armv7a-nuttx-eabihf", armv7a_nuttx_eabihf),
18561858

18571859
("msp430-none-elf", msp430_none_elf),
18581860

@@ -1896,6 +1898,7 @@ supported_targets! {
18961898

18971899
("aarch64-unknown-none", aarch64_unknown_none),
18981900
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
1901+
("aarch64-unknown-nuttx", aarch64_unknown_nuttx),
18991902

19001903
("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),
19011904

@@ -1971,6 +1974,8 @@ supported_targets! {
19711974
("x86_64-unknown-linux-none", x86_64_unknown_linux_none),
19721975

19731976
("thumbv6m-nuttx-eabi", thumbv6m_nuttx_eabi),
1977+
("thumbv7a-nuttx-eabi", thumbv7a_nuttx_eabi),
1978+
("thumbv7a-nuttx-eabihf", thumbv7a_nuttx_eabihf),
19741979
("thumbv7m-nuttx-eabi", thumbv7m_nuttx_eabi),
19751980
("thumbv7em-nuttx-eabi", thumbv7em_nuttx_eabi),
19761981
("thumbv7em-nuttx-eabihf", thumbv7em_nuttx_eabihf),
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Generic AArch64 target for NuttX OS
2+
//
3+
// Can be used in conjunction with the `target-feature` and
4+
// `target-cpu` compiler flags to opt-in more hardware-specific
5+
// features.
6+
//
7+
// For example, `-C target-cpu=cortex-a53`.
8+
9+
use crate::spec::{
10+
Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
11+
TargetOptions, cvs,
12+
};
13+
14+
pub(crate) fn target() -> Target {
15+
let opts = TargetOptions {
16+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
17+
linker: Some("rust-lld".into()),
18+
// Enable the Cortex-A53 errata 843419 mitigation by default
19+
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[
20+
"--fix-cortex-a53-843419",
21+
]),
22+
features: "+v8a,+strict-align,+neon,+fp-armv8".into(),
23+
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
24+
relocation_model: RelocModel::Static,
25+
disable_redzone: true,
26+
max_atomic_width: Some(128),
27+
stack_probes: StackProbeType::Inline,
28+
panic_strategy: PanicStrategy::Abort,
29+
families: cvs!["unix"],
30+
os: "nuttx".into(),
31+
..Default::default()
32+
};
33+
Target {
34+
llvm_target: "aarch64-unknown-none".into(),
35+
metadata: crate::spec::TargetMetadata {
36+
description: Some("AArch64 NuttX".into()),
37+
tier: Some(2),
38+
host_tools: Some(false),
39+
std: Some(false),
40+
},
41+
pointer_width: 64,
42+
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(),
43+
arch: "aarch64".into(),
44+
options: opts,
45+
}
46+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Targets Cortex-A7/A8/A9 processors (ARMv7-A) running NuttX
2+
//
3+
// This target assumes that the device does NOT have a FPU (Floating Point Unit)
4+
// and will use software floating point operations. This matches the NuttX EABI
5+
// configuration without hardware floating point support.
6+
7+
use crate::spec::{
8+
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
9+
};
10+
11+
pub(crate) fn target() -> Target {
12+
let opts = TargetOptions {
13+
abi: "eabi".into(),
14+
llvm_floatabi: Some(FloatAbi::Soft),
15+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
16+
linker: Some("rust-lld".into()),
17+
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
18+
relocation_model: RelocModel::Static,
19+
disable_redzone: true,
20+
max_atomic_width: Some(64),
21+
panic_strategy: PanicStrategy::Abort,
22+
emit_debug_gdb_scripts: false,
23+
c_enum_min_bits: Some(8),
24+
families: cvs!["unix"],
25+
os: "nuttx".into(),
26+
..Default::default()
27+
};
28+
Target {
29+
llvm_target: "armv7a-none-eabi".into(),
30+
metadata: crate::spec::TargetMetadata {
31+
description: Some("ARMv7-A Cortex-A with NuttX".into()),
32+
tier: Some(2),
33+
host_tools: Some(false),
34+
std: Some(false),
35+
},
36+
pointer_width: 32,
37+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
38+
arch: "arm".into(),
39+
options: opts,
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Targets Cortex-A7/A8/A9 processors (ARMv7-A) running NuttX with hardware floating point
2+
//
3+
// This target assumes that the device has a FPU (Floating Point Unit)
4+
// and will use hardware floating point operations. This matches the NuttX EABI
5+
// configuration with hardware floating point support.
6+
7+
use crate::spec::{
8+
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
9+
};
10+
11+
pub(crate) fn target() -> Target {
12+
let opts = TargetOptions {
13+
abi: "eabihf".into(),
14+
llvm_floatabi: Some(FloatAbi::Hard),
15+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
16+
linker: Some("rust-lld".into()),
17+
features: "+v7,+thumb2,+vfp3,+neon,+strict-align".into(),
18+
relocation_model: RelocModel::Static,
19+
disable_redzone: true,
20+
max_atomic_width: Some(64),
21+
panic_strategy: PanicStrategy::Abort,
22+
emit_debug_gdb_scripts: false,
23+
c_enum_min_bits: Some(8),
24+
families: cvs!["unix"],
25+
os: "nuttx".into(),
26+
..Default::default()
27+
};
28+
Target {
29+
llvm_target: "armv7a-none-eabihf".into(),
30+
metadata: crate::spec::TargetMetadata {
31+
description: Some("ARMv7-A Cortex-A with NuttX (hard float)".into()),
32+
tier: Some(2),
33+
host_tools: Some(false),
34+
std: Some(false),
35+
},
36+
pointer_width: 32,
37+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
38+
arch: "arm".into(),
39+
options: opts,
40+
}
41+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Targets Cortex-A7/A8/A9 processors (ARMv7-A)
2+
//
3+
// This target assumes that the device does NOT have a FPU (Floating Point Unit)
4+
// and will use software floating point operations. This matches the NuttX EABI
5+
// configuration without hardware floating point support.
6+
7+
use crate::spec::{FloatAbi, Target, TargetOptions, base, cvs};
8+
9+
pub(crate) fn target() -> Target {
10+
Target {
11+
llvm_target: "thumbv7a-none-eabi".into(),
12+
metadata: crate::spec::TargetMetadata {
13+
description: None,
14+
tier: None,
15+
host_tools: None,
16+
std: None,
17+
},
18+
pointer_width: 32,
19+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
20+
arch: "arm".into(),
21+
22+
options: TargetOptions {
23+
families: cvs!["unix"],
24+
os: "nuttx".into(),
25+
abi: "eabi".into(),
26+
llvm_floatabi: Some(FloatAbi::Soft),
27+
// Cortex-A7/A8/A9 with software floating point
28+
features: "+soft-float,-neon".into(),
29+
max_atomic_width: Some(64),
30+
..base::thumb::opts()
31+
},
32+
}
33+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Targets Cortex-A7/A8/A9 processors (ARMv7-A)
2+
//
3+
// This target assumes that the device has a FPU (Floating Point Unit) and lowers all (single
4+
// precision) floating point operations to hardware instructions. Cortex-A7/A8/A9 processors
5+
// support VFPv3-D32 or VFPv4-D32 floating point units with optional double-precision support.
6+
//
7+
// This target uses the "hard" floating convention (ABI) where floating point values
8+
// are passed to/from subroutines via FPU registers (S0, S1, D0, D1, etc.).
9+
10+
use crate::spec::{FloatAbi, Target, TargetOptions, base, cvs};
11+
12+
pub(crate) fn target() -> Target {
13+
Target {
14+
llvm_target: "thumbv7a-none-eabihf".into(),
15+
metadata: crate::spec::TargetMetadata {
16+
description: None,
17+
tier: None,
18+
host_tools: None,
19+
std: None,
20+
},
21+
pointer_width: 32,
22+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
23+
arch: "arm".into(),
24+
25+
options: TargetOptions {
26+
families: cvs!["unix"],
27+
os: "nuttx".into(),
28+
abi: "eabihf".into(),
29+
llvm_floatabi: Some(FloatAbi::Hard),
30+
// Cortex-A7/A8/A9 support VFPv3-D32/VFPv4-D32 with optional double-precision
31+
// and NEON SIMD instructions
32+
features: "+vfp3,+neon".into(),
33+
max_atomic_width: Some(64),
34+
..base::thumb::opts()
35+
},
36+
}
37+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ target | std | host | notes
260260
[`aarch64-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD
261261
[`aarch64-unknown-nto-qnx700`](platform-support/nto-qnx.md) | ? | | ARM64 QNX Neutrino 7.0 RTOS |
262262
[`aarch64-unknown-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | ARM64 QNX Neutrino 7.1 RTOS |
263+
[`aarch64-unknown-nuttx`](platform-support/nuttx.md) | * | | ARM64 with NuttX
263264
[`aarch64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | ARM64 OpenBSD
264265
[`aarch64-unknown-redox`](platform-support/redox.md) | ✓ | | ARM64 Redox OS
265266
[`aarch64-unknown-teeos`](platform-support/aarch64-unknown-teeos.md) | ? | | ARM64 TEEOS |
@@ -295,6 +296,8 @@ target | std | host | notes
295296
[`armv7k-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | Armv7-A Apple WatchOS
296297
[`armv7s-apple-ios`](platform-support/apple-ios.md) | ✓ | | Armv7-A Apple-A6 Apple iOS
297298
[`armv8r-none-eabihf`](platform-support/armv8r-none-eabihf.md) | * | | Bare Armv8-R, hardfloat
299+
[`armv7a-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7-A with NuttX
300+
[`armv7a-nuttx-eabihf`](platform-support/nuttx.md) | * | | ARMv7-A with NuttX, hardfloat
298301
`avr-unknown-gnu-atmega328` | * | | AVR. Requires `-Z build-std=core`
299302
`bpfeb-unknown-none` | * | | BPF (big endian)
300303
`bpfel-unknown-none` | * | | BPF (little endian)
@@ -389,6 +392,7 @@ target | std | host | notes
389392
[`thumbv6m-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv6M with NuttX
390393
`thumbv7a-pc-windows-msvc` | | |
391394
[`thumbv7a-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | | |
395+
[`thumbv7a-nuttx-eabihf`](platform-support/nuttx.md) | * | | ARMv7-A with NuttX, hardfloat
392396
[`thumbv7em-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7EM with NuttX
393397
[`thumbv7em-nuttx-eabihf`](platform-support/nuttx.md) | * | | ARMv7EM with NuttX, hardfloat
394398
[`thumbv7m-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7M with NuttX

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ The target name follow this format: `ARCH[-VENDOR]-nuttx-ABI`, where `ARCH` is t
2020

2121
The following target names are defined:
2222

23-
- `thumbv6m-nuttx-eal`
24-
- `thumbv7m-nuttx-eal`
23+
- `aarch64-unknown-nuttx`
24+
- `armv7a-nuttx-eabi`
25+
- `armv7a-nuttx-eabihf`
26+
- `thumbv6m-nuttx-eabi`
27+
- `thumbv7a-nuttx-eabi`
28+
- `thumbv7a-nuttx-eabihf`
29+
- `thumbv7m-nuttx-eabi`
2530
- `thumbv7em-nuttx-eabi`
2631
- `thumbv7em-nuttx-eabihf`
2732
- `thumbv8m.base-nuttx-eabi`

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
//@ revisions: aarch64_unknown_teeos
6767
//@ [aarch64_unknown_teeos] compile-flags: --target aarch64-unknown-teeos
6868
//@ [aarch64_unknown_teeos] needs-llvm-components: aarch64
69+
//@ revisions: aarch64_unknown_nuttx
70+
//@ [aarch64_unknown_nuttx] compile-flags: --target aarch64-unknown-nuttx
71+
//@ [aarch64_unknown_nuttx] needs-llvm-components: aarch64
6972
//@ revisions: aarch64_unknown_trusty
7073
//@ [aarch64_unknown_trusty] compile-flags: --target aarch64-unknown-trusty
7174
//@ [aarch64_unknown_trusty] needs-llvm-components: aarch64
@@ -177,6 +180,12 @@
177180
//@ revisions: armv7a_none_eabihf
178181
//@ [armv7a_none_eabihf] compile-flags: --target armv7a-none-eabihf
179182
//@ [armv7a_none_eabihf] needs-llvm-components: arm
183+
//@ revisions: armv7a_nuttx_eabi
184+
//@ [armv7a_nuttx_eabi] compile-flags: --target armv7a-nuttx-eabi
185+
//@ [armv7a_nuttx_eabi] needs-llvm-components: arm
186+
//@ revisions: armv7a_nuttx_eabihf
187+
//@ [armv7a_nuttx_eabihf] compile-flags: --target armv7a-nuttx-eabihf
188+
//@ [armv7a_nuttx_eabihf] needs-llvm-components: arm
180189
//@ revisions: armv7r_none_eabi
181190
//@ [armv7r_none_eabi] compile-flags: --target armv7r-none-eabi
182191
//@ [armv7r_none_eabi] needs-llvm-components: arm
@@ -621,6 +630,12 @@
621630
//@ revisions: thumbv6m_nuttx_eabi
622631
//@ [thumbv6m_nuttx_eabi] compile-flags: --target thumbv6m-nuttx-eabi
623632
//@ [thumbv6m_nuttx_eabi] needs-llvm-components: arm
633+
//@ revisions: thumbv7a_nuttx_eabi
634+
//@ [thumbv7a_nuttx_eabi] compile-flags: --target thumbv7a-nuttx-eabi
635+
//@ [thumbv7a_nuttx_eabi] needs-llvm-components: arm
636+
//@ revisions: thumbv7a_nuttx_eabihf
637+
//@ [thumbv7a_nuttx_eabihf] compile-flags: --target thumbv7a-nuttx-eabihf
638+
//@ [thumbv7a_nuttx_eabihf] needs-llvm-components: arm
624639
//@ revisions: thumbv7m_nuttx_eabi
625640
//@ [thumbv7m_nuttx_eabi] compile-flags: --target thumbv7m-nuttx-eabi
626641
//@ [thumbv7m_nuttx_eabi] needs-llvm-components: arm

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /