mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-02 19:58:26 +00:00
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/
108 lines
3.3 KiB
Rust
108 lines
3.3 KiB
Rust
//! Implementation of panics via stack unwinding
|
|
//!
|
|
//! This crate is an implementation of panics in Rust using "most native" stack
|
|
//! unwinding mechanism of the platform this is being compiled for. This
|
|
//! essentially gets categorized into three buckets currently:
|
|
//!
|
|
//! 1. MSVC targets use SEH in the `seh.rs` file.
|
|
//! 2. Emscripten uses C++ exceptions in the `emcc.rs` file.
|
|
//! 3. All other targets use libunwind/libgcc in the `gcc.rs` file.
|
|
//!
|
|
//! More documentation about each implementation can be found in the respective
|
|
//! module.
|
|
|
|
#![no_std]
|
|
#![unstable(feature = "panic_unwind", issue = "32837")]
|
|
#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
|
|
#![feature(core_intrinsics)]
|
|
#![feature(lang_items)]
|
|
#![feature(nll)]
|
|
#![feature(panic_unwind)]
|
|
#![feature(staged_api)]
|
|
#![feature(std_internals)]
|
|
#![feature(abi_thiscall)]
|
|
#![feature(rustc_attrs)]
|
|
#![panic_runtime]
|
|
#![feature(panic_runtime)]
|
|
#![feature(c_unwind)]
|
|
// `real_imp` is unused with Miri, so silence warnings.
|
|
#![cfg_attr(miri, allow(dead_code))]
|
|
|
|
use alloc::boxed::Box;
|
|
use core::any::Any;
|
|
use core::panic::BoxMeUp;
|
|
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(target_os = "emscripten")] {
|
|
#[path = "emcc.rs"]
|
|
mod real_imp;
|
|
} else if #[cfg(target_os = "hermit")] {
|
|
#[path = "hermit.rs"]
|
|
mod real_imp;
|
|
} else if #[cfg(target_env = "msvc")] {
|
|
#[path = "seh.rs"]
|
|
mod real_imp;
|
|
} else if #[cfg(any(
|
|
all(target_family = "windows", target_env = "gnu"),
|
|
target_os = "psp",
|
|
target_os = "solid_asp3",
|
|
all(target_family = "unix", not(target_os = "espidf")),
|
|
all(target_vendor = "fortanix", target_env = "sgx"),
|
|
))] {
|
|
// Rust runtime's startup objects depend on these symbols, so make them public.
|
|
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
|
|
pub use real_imp::eh_frame_registry::*;
|
|
#[path = "gcc.rs"]
|
|
mod real_imp;
|
|
} else {
|
|
// Targets that don't support unwinding.
|
|
// - arch=wasm32
|
|
// - os=none ("bare metal" targets)
|
|
// - os=uefi
|
|
// - os=espidf
|
|
// - nvptx64-nvidia-cuda
|
|
// - arch=avr
|
|
#[path = "dummy.rs"]
|
|
mod real_imp;
|
|
}
|
|
}
|
|
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(miri)] {
|
|
// Use the Miri runtime.
|
|
// We still need to also load the normal runtime above, as rustc expects certain lang
|
|
// items from there to be defined.
|
|
#[path = "miri.rs"]
|
|
mod imp;
|
|
} else {
|
|
// Use the real runtime.
|
|
use real_imp as imp;
|
|
}
|
|
}
|
|
|
|
extern "C" {
|
|
/// Handler in libstd called when a panic object is dropped outside of
|
|
/// `catch_unwind`.
|
|
fn __rust_drop_panic() -> !;
|
|
|
|
/// Handler in libstd called when a foreign exception is caught.
|
|
fn __rust_foreign_exception() -> !;
|
|
}
|
|
|
|
mod dwarf;
|
|
|
|
#[rustc_std_internal_symbol]
|
|
#[allow(improper_ctypes_definitions)]
|
|
pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static) {
|
|
Box::into_raw(imp::cleanup(payload))
|
|
}
|
|
|
|
// Entry point for raising an exception, just delegates to the platform-specific
|
|
// implementation.
|
|
#[rustc_std_internal_symbol]
|
|
pub unsafe extern "C-unwind" fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32 {
|
|
let payload = Box::from_raw((*payload).take_box());
|
|
|
|
imp::panic(payload)
|
|
}
|