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

Add NuttX support for AArch64 and ARMv7-A targets #135757

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

Merged
bors merged 1 commit into rust-lang:master from no1wudi:master
Jan 24, 2025
Merged
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
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,8 @@ supported_targets! {

("armv7a-none-eabi", armv7a_none_eabi),
("armv7a-none-eabihf", armv7a_none_eabihf),
("armv7a-nuttx-eabi", armv7a_nuttx_eabi),
("armv7a-nuttx-eabihf", armv7a_nuttx_eabihf),

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

Expand Down Expand Up @@ -1896,6 +1898,7 @@ supported_targets! {

("aarch64-unknown-none", aarch64_unknown_none),
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
("aarch64-unknown-nuttx", aarch64_unknown_nuttx),

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

Expand Down Expand Up @@ -1971,6 +1974,8 @@ supported_targets! {
("x86_64-unknown-linux-none", x86_64_unknown_linux_none),

("thumbv6m-nuttx-eabi", thumbv6m_nuttx_eabi),
("thumbv7a-nuttx-eabi", thumbv7a_nuttx_eabi),
("thumbv7a-nuttx-eabihf", thumbv7a_nuttx_eabihf),
("thumbv7m-nuttx-eabi", thumbv7m_nuttx_eabi),
("thumbv7em-nuttx-eabi", thumbv7em_nuttx_eabi),
("thumbv7em-nuttx-eabihf", thumbv7em_nuttx_eabihf),
Expand Down
46 changes: 46 additions & 0 deletions compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Generic AArch64 target for NuttX OS
//
// Can be used in conjunction with the `target-feature` and
// `target-cpu` compiler flags to opt-in more hardware-specific
// features.
//
// For example, `-C target-cpu=cortex-a53`.

use crate::spec::{
Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
let opts = TargetOptions {
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
// Enable the Cortex-A53 errata 843419 mitigation by default
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[
"--fix-cortex-a53-843419",
]),
features: "+v8a,+strict-align,+neon,+fp-armv8".into(),
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
panic_strategy: PanicStrategy::Abort,
families: cvs!["unix"],
os: "nuttx".into(),
..Default::default()
};
Target {
llvm_target: "aarch64-unknown-none".into(),
metadata: crate::spec::TargetMetadata {
description: Some("AArch64 NuttX".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
pointer_width: 64,
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(),
arch: "aarch64".into(),
options: opts,
}
}
41 changes: 41 additions & 0 deletions compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabi.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Targets Cortex-A7/A8/A9 processors (ARMv7-A) running NuttX
//
// This target assumes that the device does NOT have a FPU (Floating Point Unit)
// and will use software floating point operations. This matches the NuttX EABI
// configuration without hardware floating point support.

use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
let opts = TargetOptions {
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
emit_debug_gdb_scripts: false,
c_enum_min_bits: Some(8),
families: cvs!["unix"],
os: "nuttx".into(),
..Default::default()
};
Target {
llvm_target: "armv7a-none-eabi".into(),
metadata: crate::spec::TargetMetadata {
description: Some("ARMv7-A Cortex-A with NuttX".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
options: opts,
}
}
41 changes: 41 additions & 0 deletions compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabihf.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Targets Cortex-A7/A8/A9 processors (ARMv7-A) running NuttX with hardware floating point
//
// This target assumes that the device has a FPU (Floating Point Unit)
// and will use hardware floating point operations. This matches the NuttX EABI
// configuration with hardware floating point support.

use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
let opts = TargetOptions {
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+thumb2,+vfp3,+neon,+strict-align".into(),
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
emit_debug_gdb_scripts: false,
c_enum_min_bits: Some(8),
families: cvs!["unix"],
os: "nuttx".into(),
..Default::default()
};
Target {
llvm_target: "armv7a-none-eabihf".into(),
metadata: crate::spec::TargetMetadata {
description: Some("ARMv7-A Cortex-A with NuttX (hard float)".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
options: opts,
}
}
33 changes: 33 additions & 0 deletions compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabi.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Targets Cortex-A7/A8/A9 processors (ARMv7-A)
//
// This target assumes that the device does NOT have a FPU (Floating Point Unit)
// and will use software floating point operations. This matches the NuttX EABI
// configuration without hardware floating point support.

use crate::spec::{FloatAbi, Target, TargetOptions, base, cvs};

pub(crate) fn target() -> Target {
Target {
llvm_target: "thumbv7a-none-eabi".into(),
metadata: crate::spec::TargetMetadata {
description: None,
tier: None,
host_tools: None,
std: None,
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),

options: TargetOptions {
families: cvs!["unix"],
os: "nuttx".into(),
abi: "eabi".into(),
llvm_floatabi: Some(FloatAbi::Soft),
// Cortex-A7/A8/A9 with software floating point
features: "+soft-float,-neon".into(),
max_atomic_width: Some(64),
..base::thumb::opts()
},
}
}
37 changes: 37 additions & 0 deletions compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabihf.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Targets Cortex-A7/A8/A9 processors (ARMv7-A)
//
// This target assumes that the device has a FPU (Floating Point Unit) and lowers all (single
// precision) floating point operations to hardware instructions. Cortex-A7/A8/A9 processors
// support VFPv3-D32 or VFPv4-D32 floating point units with optional double-precision support.
//
// This target uses the "hard" floating convention (ABI) where floating point values
// are passed to/from subroutines via FPU registers (S0, S1, D0, D1, etc.).

use crate::spec::{FloatAbi, Target, TargetOptions, base, cvs};

pub(crate) fn target() -> Target {
Target {
llvm_target: "thumbv7a-none-eabihf".into(),
metadata: crate::spec::TargetMetadata {
description: None,
tier: None,
host_tools: None,
std: None,
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),

options: TargetOptions {
families: cvs!["unix"],
os: "nuttx".into(),
abi: "eabihf".into(),
llvm_floatabi: Some(FloatAbi::Hard),
// Cortex-A7/A8/A9 support VFPv3-D32/VFPv4-D32 with optional double-precision
// and NEON SIMD instructions
features: "+vfp3,+neon".into(),
max_atomic_width: Some(64),
..base::thumb::opts()
},
}
}
5 changes: 5 additions & 0 deletions src/doc/rustc/src/platform-support.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ target | std | host | notes
[`aarch64-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD
[`aarch64-unknown-nto-qnx700`](platform-support/nto-qnx.md) | ? | | ARM64 QNX Neutrino 7.0 RTOS |
[`aarch64-unknown-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | ARM64 QNX Neutrino 7.1 RTOS |
[`aarch64-unknown-nuttx`](platform-support/nuttx.md) | * | | ARM64 with NuttX
[`aarch64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | ARM64 OpenBSD
[`aarch64-unknown-redox`](platform-support/redox.md) | ✓ | | ARM64 Redox OS
[`aarch64-unknown-teeos`](platform-support/aarch64-unknown-teeos.md) | ? | | ARM64 TEEOS |
Expand Down Expand Up @@ -295,6 +296,8 @@ target | std | host | notes
[`armv7k-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | Armv7-A Apple WatchOS
[`armv7s-apple-ios`](platform-support/apple-ios.md) | ✓ | | Armv7-A Apple-A6 Apple iOS
[`armv8r-none-eabihf`](platform-support/armv8r-none-eabihf.md) | * | | Bare Armv8-R, hardfloat
[`armv7a-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7-A with NuttX
[`armv7a-nuttx-eabihf`](platform-support/nuttx.md) | * | | ARMv7-A with NuttX, hardfloat
`avr-unknown-gnu-atmega328` | * | | AVR. Requires `-Z build-std=core`
`bpfeb-unknown-none` | * | | BPF (big endian)
`bpfel-unknown-none` | * | | BPF (little endian)
Expand Down Expand Up @@ -389,6 +392,8 @@ target | std | host | notes
[`thumbv6m-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv6M with NuttX
`thumbv7a-pc-windows-msvc` | | |
[`thumbv7a-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | | |
[`thumbv7a-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7-A with NuttX
[`thumbv7a-nuttx-eabihf`](platform-support/nuttx.md) | * | | ARMv7-A with NuttX, hardfloat
[`thumbv7em-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7EM with NuttX
[`thumbv7em-nuttx-eabihf`](platform-support/nuttx.md) | * | | ARMv7EM with NuttX, hardfloat
[`thumbv7m-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7M with NuttX
Expand Down
9 changes: 7 additions & 2 deletions src/doc/rustc/src/platform-support/nuttx.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ The target name follow this format: `ARCH[-VENDOR]-nuttx-ABI`, where `ARCH` is t

The following target names are defined:

- `thumbv6m-nuttx-eal`
- `thumbv7m-nuttx-eal`
- `aarch64-unknown-nuttx`
- `armv7a-nuttx-eabi`
- `armv7a-nuttx-eabihf`
- `thumbv6m-nuttx-eabi`
- `thumbv7a-nuttx-eabi`
- `thumbv7a-nuttx-eabihf`
- `thumbv7m-nuttx-eabi`
- `thumbv7em-nuttx-eabi`
- `thumbv7em-nuttx-eabihf`
- `thumbv8m.base-nuttx-eabi`
Expand Down
15 changes: 15 additions & 0 deletions tests/assembly/targets/targets-elf.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
//@ revisions: aarch64_unknown_teeos
//@ [aarch64_unknown_teeos] compile-flags: --target aarch64-unknown-teeos
//@ [aarch64_unknown_teeos] needs-llvm-components: aarch64
//@ revisions: aarch64_unknown_nuttx
//@ [aarch64_unknown_nuttx] compile-flags: --target aarch64-unknown-nuttx
//@ [aarch64_unknown_nuttx] needs-llvm-components: aarch64
//@ revisions: aarch64_unknown_trusty
//@ [aarch64_unknown_trusty] compile-flags: --target aarch64-unknown-trusty
//@ [aarch64_unknown_trusty] needs-llvm-components: aarch64
Expand Down Expand Up @@ -177,6 +180,12 @@
//@ revisions: armv7a_none_eabihf
//@ [armv7a_none_eabihf] compile-flags: --target armv7a-none-eabihf
//@ [armv7a_none_eabihf] needs-llvm-components: arm
//@ revisions: armv7a_nuttx_eabi
//@ [armv7a_nuttx_eabi] compile-flags: --target armv7a-nuttx-eabi
//@ [armv7a_nuttx_eabi] needs-llvm-components: arm
//@ revisions: armv7a_nuttx_eabihf
//@ [armv7a_nuttx_eabihf] compile-flags: --target armv7a-nuttx-eabihf
//@ [armv7a_nuttx_eabihf] needs-llvm-components: arm
//@ revisions: armv7r_none_eabi
//@ [armv7r_none_eabi] compile-flags: --target armv7r-none-eabi
//@ [armv7r_none_eabi] needs-llvm-components: arm
Expand Down Expand Up @@ -621,6 +630,12 @@
//@ revisions: thumbv6m_nuttx_eabi
//@ [thumbv6m_nuttx_eabi] compile-flags: --target thumbv6m-nuttx-eabi
//@ [thumbv6m_nuttx_eabi] needs-llvm-components: arm
//@ revisions: thumbv7a_nuttx_eabi
//@ [thumbv7a_nuttx_eabi] compile-flags: --target thumbv7a-nuttx-eabi
//@ [thumbv7a_nuttx_eabi] needs-llvm-components: arm
//@ revisions: thumbv7a_nuttx_eabihf
//@ [thumbv7a_nuttx_eabihf] compile-flags: --target thumbv7a-nuttx-eabihf
//@ [thumbv7a_nuttx_eabihf] needs-llvm-components: arm
//@ revisions: thumbv7m_nuttx_eabi
//@ [thumbv7m_nuttx_eabi] compile-flags: --target thumbv7m-nuttx-eabi
//@ [thumbv7m_nuttx_eabi] needs-llvm-components: arm
Expand Down
Loading

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