-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add X86 target support for NuttX #136181
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
Closed
Closed
Add X86 target support for NuttX #136181
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
compiler/rustc_target/src/spec/targets/i686_unknown_nuttx.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, StackProbeType, Target, TargetOptions, cvs}; | ||
|
||
pub(crate) fn target() -> Target { | ||
let mut base = TargetOptions { | ||
os: "nuttx".into(), | ||
dynamic_linking: false, | ||
families: cvs!["unix"], | ||
no_default_libraries: true, | ||
has_rpath: false, | ||
position_independent_executables: false, | ||
relocation_model: RelocModel::Static, | ||
relro_level: crate::spec::RelroLevel::Full, | ||
has_thread_local: true, | ||
use_ctors_section: true, | ||
..Default::default() | ||
}; | ||
base.cpu = "pentium4".into(); | ||
base.max_atomic_width = Some(64); | ||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); | ||
base.stack_probes = StackProbeType::Inline; | ||
|
||
Target { | ||
llvm_target: "i686-unknown-nuttx".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: Some("NuttX/x86".into()), | ||
tier: Some(3), | ||
host_tools: Some(false), | ||
std: Some(true), | ||
}, | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ | ||
i128:128-f64:32:64-f80:32-n8:16:32-S128" | ||
.into(), | ||
arch: "x86".into(), | ||
options: base, | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
compiler/rustc_target/src/spec/targets/x86_64_unknown_nuttx.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Generic x86-64 target for NuttX RTOS | ||
// | ||
// Can be used in conjunction with the `target-feature` and | ||
// `target-cpu` compiler flags to opt-in more hardware-specific | ||
// features. | ||
|
||
use crate::spec::{RelocModel, StackProbeType, Target, TargetOptions, cvs}; | ||
|
||
pub(crate) fn target() -> Target { | ||
let mut base = TargetOptions { | ||
os: "nuttx".into(), | ||
dynamic_linking: false, | ||
families: cvs!["unix"], | ||
no_default_libraries: true, | ||
has_rpath: false, | ||
position_independent_executables: false, | ||
relocation_model: RelocModel::Static, | ||
relro_level: crate::spec::RelroLevel::Full, | ||
has_thread_local: true, | ||
use_ctors_section: true, | ||
..Default::default() | ||
}; | ||
base.cpu = "x86-64".into(); | ||
base.max_atomic_width = Some(64); | ||
base.stack_probes = StackProbeType::Inline; | ||
|
||
Target { | ||
llvm_target: "x86_64-unknown-nuttx".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: Some("NuttX/x86_64".into()), | ||
tier: Some(3), | ||
host_tools: Some(false), | ||
std: Some(true), | ||
}, | ||
pointer_width: 64, | ||
data_layout: | ||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), | ||
arch: "x86_64".into(), | ||
options: base, | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ The target name follow this format: `ARCH[-VENDOR]-nuttx-ABI`, where `ARCH` is t | |
|
||
The following target names are defined: | ||
|
||
- `i686-unknown-nuttx` | ||
- `x86_64-unknown-nuttx` | ||
- `aarch64-unknown-nuttx` | ||
- `armv7a-nuttx-eabi` | ||
- `armv7a-nuttx-eabihf` | ||
|
@@ -52,13 +54,22 @@ linker = "riscv-none-elf-gcc" | |
|
||
The toolchain for the target can be found in [NuttX's quick start guide](https://nuttx.apache.org/docs/latest/quickstart/install.html). | ||
|
||
|
||
## Testing | ||
|
||
This is a cross-compiled `no-std` target, which must be run either in a simulator | ||
or by programming them onto suitable hardware. It is not possible to run the | ||
Rust test-suite on this target. | ||
|
||
## Note for Floating-Point support on X86/X86_64 | ||
|
||
For the NuttX platform, X86/X86_64 targets have two usage scenarios: | ||
1. Linked to a "SIM" running in a POSIX environment (more common) | ||
2. Running directly on baremetal hardware | ||
|
||
In the SIM environment, the FPU (Floating Point Unit) configuration is fixed and not configurable. For baremetal scenarios: | ||
- On i686 (targeting i486 in NuttX), the FPU is typically disabled | ||
- On x86_64, the FPU is enabled by default but can be disabled if needed | ||
Comment on lines
+70
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to Rust, only one of these can be true per target. Pick. |
||
|
||
## Cross-compilation toolchains and C code | ||
|
||
This target supports C code. If interlinking with C or C++, you may need to use | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an i486 CPU, this is a 32-bit x86 CPU with SSE2 registers.