Description
Currently, std
contains platform-specific code throughout. This makes both
in-tree and out-of-tree ports harder. In-tree ports are harder because it's not
obvious what all needs to be implemented. Out-of-tree ports are harder because
they require frequent laborous rebasing due to an unclear interface. It's not
possible to port just a little bit to get your platform started, because
succesful compilation requires “everything” to be there.
The idea is to add a platform abstraction layer (PAL) to std
to separate
out platform-specific code from generic code. The exact shape of the desired
interface is unclear. The refactoring will likely need to be an incremental
process where the PAL interface gets more cleary defined step-by-step.
As part of this work, it should be possible to create a "mock" platform that
can be used to test the interface and as a starting point for implementing new
platforms.
Prior work:
- One extreme ultimate goal was described by brson in 2016.
- Experimentation by @panicbit has shown that the current API can't really be captured in traits.
- Tracking issue for location of facade crates rust-lang/rust#27783: Tracking issue for the creates beneath the facade (bullet point added by @Ericson2314)