-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement `i686-unknown-nuttx` and `x86_64-unknown-nuttx` target definitions * Integrate new targets into the platform support documentation * Update tests to include new target revisions This change introduces support for 32-bit and 64-bit x86 architectures on the NuttX operating system, enhancing the range of platforms Rust can target. The targets are defined as tier 3, indicating that they are supported but not automatically tested by the Rust project. The `i686-unknown-nuttx` target uses the `pentium4` CPU and 32-bit pointers, while the `x86_64-unknown-nuttx` target uses the `x86-64` CPU and 64-bit pointers. Both targets disable dynamic linking and use inline stack probes for improved performance and reliability in a bare-metal environment. Additionally, this commit updates the platform support documentation to list the new targets and includes them in the test suite to ensure that they build correctly. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
- Loading branch information
Showing
6 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 bare-metal code - Floating point disabled | ||
// | ||
// 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 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 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 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