Skip to content

Commit da9ca41

Browse files
committed
Add SOLID targets
SOLID[1] is an embedded development platform provided by Kyoto Microcomputer Co., Ltd. This commit introduces a basic Tier 3 support for SOLID. # New Targets The following targets are added: - `aarch64-kmc-solid_asp3` - `armv7a-kmc-solid_asp3-eabi` - `armv7a-kmc-solid_asp3-eabihf` SOLID's target software system can be divided into two parts: an RTOS kernel, which is responsible for threading and synchronization, and Core Services, which provides filesystems, networking, and other things. The RTOS kernel is a μITRON4.0[2][3]-derived kernel based on the open-source TOPPERS RTOS kernels[4]. For uniprocessor systems (more precisely, systems where only one processor core is allocated for SOLID), this will be the TOPPERS/ASP3 kernel. As μITRON is traditionally only specified at the source-code level, the ABI is unique to each implementation, which is why `asp3` is included in the target names. More targets could be added later, as we support other base kernels (there are at least three at the point of writing) and are interested in supporting other processor architectures in the future. # C Compiler Although SOLID provides its own supported C/C++ build toolchain, GNU Arm Embedded Toolchain seems to work for the purpose of building Rust. # Unresolved Questions A μITRON4 kernel can support `Thread::unpark` natively, but it's not used by this commit's implementation because the underlying kernel feature is also used to implement `Condvar`, and it's unclear whether `std` should guarantee that parking tokens are not clobbered by other synchronization primitives. # Unsupported or Unimplemented Features Most features are implemented. The following features are not implemented due to the lack of native support: - `fs::File::{file_attr, truncate, duplicate, set_permissions}` - `fs::{symlink, link, canonicalize}` - Process creation - Command-line arguments Backtrace generation is not really a good fit for embedded targets, so it's intentionally left unimplemented. Unwinding is functional, however. ## Dynamic Linking Dynamic linking is not supported. The target platform supports dynamic linking, but enabling this in Rust causes several problems. - The linker invocation used to build the shared object of `std` is too long for the platform-provided linker to handle. - A linker script with specific requirements is required for the compiled shared object to be actually loadable. As such, we decided to disable dynamic linking for now. Regardless, the users can try to create shared objects by manually invoking the linker. ## Executable Building an executable is not supported as the notion of "executable files" isn't well-defined for these targets. [1] https://solid.kmckk.com/SOLID/ [2] http://ertl.jp/ITRON/SPEC/mitron4-e.html [3] https://en.wikipedia.org/wiki/ITRON_project [4] https://toppers.jp/
1 parent 293b8f2 commit da9ca41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4062
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use super::{RelocModel, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
let base = super::solid_base::opts("asp3");
5+
Target {
6+
llvm_target: "aarch64-unknown-none".to_string(),
7+
pointer_width: 64,
8+
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
9+
arch: "aarch64".to_string(),
10+
options: TargetOptions {
11+
linker: Some("aarch64-kmc-elf-gcc".to_owned()),
12+
features: "+neon,+fp-armv8".to_string(),
13+
relocation_model: RelocModel::Static,
14+
disable_redzone: true,
15+
max_atomic_width: Some(128),
16+
..base
17+
},
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use super::{RelocModel, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
let base = super::solid_base::opts("asp3");
5+
Target {
6+
llvm_target: "armv7a-none-eabi".to_string(),
7+
pointer_width: 32,
8+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
9+
arch: "arm".to_string(),
10+
options: TargetOptions {
11+
linker: Some("arm-kmc-eabi-gcc".to_owned()),
12+
features: "+v7,+soft-float,+thumb2,-neon".to_string(),
13+
relocation_model: RelocModel::Static,
14+
disable_redzone: true,
15+
max_atomic_width: Some(64),
16+
..base
17+
},
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use super::{RelocModel, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
let base = super::solid_base::opts("asp3");
5+
Target {
6+
llvm_target: "armv7a-none-eabihf".to_string(),
7+
pointer_width: 32,
8+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
9+
arch: "arm".to_string(),
10+
options: TargetOptions {
11+
linker: Some("arm-kmc-eabi-gcc".to_owned()),
12+
features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(),
13+
relocation_model: RelocModel::Static,
14+
disable_redzone: true,
15+
max_atomic_width: Some(64),
16+
..base
17+
},
18+
}
19+
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ mod netbsd_base;
7575
mod openbsd_base;
7676
mod redox_base;
7777
mod solaris_base;
78+
mod solid_base;
7879
mod thumb_base;
7980
mod uefi_msvc_base;
8081
mod vxworks_base;
@@ -932,6 +933,10 @@ supported_targets! {
932933
("powerpc-wrs-vxworks-spe", powerpc_wrs_vxworks_spe),
933934
("powerpc64-wrs-vxworks", powerpc64_wrs_vxworks),
934935

936+
("aarch64-kmc-solid_asp3", aarch64_kmc_solid_asp3),
937+
("armv7a-kmc-solid_asp3-eabi", armv7a_kmc_solid_asp3_eabi),
938+
("armv7a-kmc-solid_asp3-eabihf", armv7a_kmc_solid_asp3_eabihf),
939+
935940
("mipsel-sony-psp", mipsel_sony_psp),
936941
("mipsel-unknown-none", mipsel_unknown_none),
937942
("thumbv4t-none-eabi", thumbv4t_none_eabi),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use super::FramePointer;
2+
use crate::spec::TargetOptions;
3+
4+
pub fn opts(kernel: &str) -> TargetOptions {
5+
TargetOptions {
6+
os: format!("solid_{}", kernel),
7+
vendor: "kmc".to_string(),
8+
frame_pointer: FramePointer::NonLeaf,
9+
has_elf_tls: true,
10+
..Default::default()
11+
}
12+
}

library/panic_abort/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub unsafe extern "C-unwind" fn __rust_start_panic(_payload: *mut &mut dyn BoxMe
4444
libc::abort();
4545
}
4646
} else if #[cfg(any(target_os = "hermit",
47+
target_os = "solid_asp3",
4748
all(target_vendor = "fortanix", target_env = "sgx")
4849
))] {
4950
unsafe fn abort() -> ! {

library/panic_unwind/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ cfg_if::cfg_if! {
4545
} else if #[cfg(any(
4646
all(target_family = "windows", target_env = "gnu"),
4747
target_os = "psp",
48+
target_os = "solid_asp3",
4849
all(target_family = "unix", not(target_os = "espidf")),
4950
all(target_vendor = "fortanix", target_env = "sgx"),
5051
))] {

library/std/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn main() {
2727
|| target.contains("wasm32")
2828
|| target.contains("asmjs")
2929
|| target.contains("espidf")
30+
|| target.contains("solid")
3031
{
3132
// These platforms don't have any special requirements.
3233
} else {

library/std/src/os/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ pub mod redox;
138138
#[cfg(target_os = "solaris")]
139139
pub mod solaris;
140140

141+
#[cfg(target_os = "solid_asp3")]
142+
pub mod solid;
141143
#[cfg(target_os = "vxworks")]
142144
pub mod vxworks;
143145

library/std/src/os/solid/ffi.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//! SOLID-specific extension to the primitives in the `std::ffi` module
2+
//!
3+
//! # Examples
4+
//!
5+
//! ```
6+
//! use std::ffi::OsString;
7+
//! use std::os::solid::ffi::OsStringExt;
8+
//!
9+
//! let bytes = b"foo".to_vec();
10+
//!
11+
//! // OsStringExt::from_vec
12+
//! let os_string = OsString::from_vec(bytes);
13+
//! assert_eq!(os_string.to_str(), Some("foo"));
14+
//!
15+
//! // OsStringExt::into_vec
16+
//! let bytes = os_string.into_vec();
17+
//! assert_eq!(bytes, b"foo");
18+
//! ```
19+
//!
20+
//! ```
21+
//! use std::ffi::OsStr;
22+
//! use std::os::solid::ffi::OsStrExt;
23+
//!
24+
//! let bytes = b"foo";
25+
//!
26+
//! // OsStrExt::from_bytes
27+
//! let os_str = OsStr::from_bytes(bytes);
28+
//! assert_eq!(os_str.to_str(), Some("foo"));
29+
//!
30+
//! // OsStrExt::as_bytes
31+
//! let bytes = os_str.as_bytes();
32+
//! assert_eq!(bytes, b"foo");
33+
//! ```
34+
35+
#![stable(feature = "rust1", since = "1.0.0")]
36+
37+
#[path = "../unix/ffi/os_str.rs"]
38+
mod os_str;
39+
40+
#[stable(feature = "rust1", since = "1.0.0")]
41+
pub use self::os_str::{OsStrExt, OsStringExt};

0 commit comments

Comments
 (0)