1
Fork 0
rust/library/std/src/os
bors c3605f8c80 Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisa
STD support for the Nintendo 3DS

Rustc already supports compiling for the Nintendo 3DS using the `armv6k-nintendo-3ds` target (Tier 3). Until now though, only `core` and `alloc` were supported. This PR adds standard library support for the Nintendo 3DS. A notable exclusion is `std::thread` support, which will come in a follow-up PR as it requires more complicated changes.

This has been a joint effort by `@Meziu,` `@ian-h-chamberlain,` myself, and prior work by `@rust3ds` members.

### Background

The Nintendo 3DS (Horizon OS) is a mostly-UNIX looking system, with the caveat that it does not come with a full libc implementation out of the box. On the homebrew side (I'm not under NDA), the libc interface is partially implemented by the [devkitPro](https://devkitpro.org/wiki/devkitPro_pacman) toolchain and a user library like [`libctru`](https://github.com/devkitPro/libctru). This is important because there are [some possible legal barriers](https://github.com/rust-lang/rust/pull/88529#issuecomment-919938396) to linking directly to a library that uses the underlying platform APIs, since they might be considered a trade secret or under NDA.

To get around this, the standard library impl for the 3DS does not directly depend on any platform-level APIs. Instead, it expects standard libc functions to be linked in. The implementation of these libc functions is left to the user. Some functions are provided by the devkitPro toolchain, but in our testing, we used the following to fill in the other functions:
- [`libctru`] - provides more basic APIs, such as `nanosleep`. Linked in by way of [`ctru-sys`](https://github.com/Meziu/ctru-rs/tree/master/ctru-sys).
- [`pthread-3ds`](https://github.com/Meziu/pthread-3ds) - provides pthread APIs for `std::thread`. Implemented using [`libctru`].
- [`linker-fix-3ds`](https://github.com/Meziu/rust-linker-fix-3ds) - fulfills some other missing libc APIs. Implemented using [`libctru`].

For more details, see the `src/doc/rustc/src/platform-support/armv6k-nintendo-3ds.md` file added in this PR.

### Notes
We've already upstreamed changes to the [`libc`] crate to support this PR, as well as the upcoming threading PR. These changes have all been released as of 0.2.121, so we bump the crate version in this PR.
Edit: After some rebases, the version bump has already been merged so it doesn't appear in this PR.

A lot of the changes in this PR are straightforward, and follow in the footsteps of the ESP-IDF target: https://github.com/rust-lang/rust/pull/87666.

The 3DS does not support user space process spawning, so these APIs are unimplemented (similar to ESP-IDF).

[`libctru`]: https://github.com/devkitPro/libctru
[`libc`]: https://github.com/rust-lang/libc
2022-06-15 14:21:28 +00:00
..
android Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
dragonfly Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
emscripten Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
espidf Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
fd Add a stability attribute to WASI's try_clone(). 2022-06-14 14:46:22 -07:00
fortanix_sgx Stabilize asm! and global_asm! 2021-12-12 11:20:03 +00:00
freebsd Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
fuchsia Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
haiku Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
hermit Move OsStringExt and OsStrExt to std::os 2021-06-20 11:55:01 +02:00
horizon Update libc::stat field names 2022-06-13 20:44:58 -07:00
illumos Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
ios Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
l4re Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
linux Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
macos Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
netbsd Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
openbsd Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
raw Provide C FFI types via core::ffi, not just in std 2022-03-01 17:16:05 -08:00
redox Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
solaris Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
solid Add SOLID targets 2021-09-28 11:31:47 +09:00
unix Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisa 2022-06-15 14:21:28 +00:00
vxworks Take sys/vxworks/{fd,fs,io} from sys/unix instead. 2020-10-16 06:19:00 +02:00
wasi Hide Repr details from io::Error, and rework io::Error::new_const. 2022-02-04 18:47:29 -08:00
windows Implement stabilization of #[feature(io_safety)]. 2022-06-14 14:46:22 -07:00
mod.rs Horizon OS STD support 2022-06-13 20:44:39 -07:00