Sorry for taking awhile to get back to you, but I’m quite interested to hear more about this! I’m a little surprised that you see the need for such a large refactoring of the standard library, it’s been designed quite carefully up to now with many of the use cases you’re mentioning in mind, so I’m at least not under the impression that it’s due for a refactoring. I totally agree on the sentiment that Rust should run everywhere, however, and would love to ensure that the process is as seamless as possible!
I want to take a second a drill a bit more into some of the pain points you’re running into. Organizations like what you’re mentioning have been suggested in the past, but in my opinion it largely boils down to shuffling code around and not being a net win in terms of ease of portability, but I could be wrong!
Cargo and crates.io integration with less-capable platforms
I very much want to use Cargo as a build system (as you’re aware), but we need to tread carefully here. Right now a stable compiler cannot build the standard library (due to unstable features), and this is not an easy hurdle to overcome. We’ve got efforts in the works to at least get precompiled std binaries for more platforms than just Linux/Windows/OSX, but I do realize that won’t get us quite all the way there.
Other than that, however, this is in my opinion “done” in terms of rustc/cargo implementation work. Cross compilation has always been first-class in both the compiler and Cargo and much of the infrastructure is already there to add support for new platforms.
Clearly define a platform-independent API that provides all functionality libstd needs without exposing any implementation details.
I’m not sure I understand this in terms of an implementation detail goal, isn’t std::{io, fs, ...} this exact API? The implementation is free to use whatever it wants, but it seems like perhaps overkill to have yet another layer of abstraction which other platforms can plug into.
I think this plays a lot into the message of “making libstd easier to port”, but it’s fundamentally just a lot of functionality that needs to get into the right place. The language has all the necessary tools via #[cfg] and the standard library should be quite amenable to adding new platforms as in theory all of the platform-specific meaty code is in std::sys (there’s certainly some cleanup that could happen here though!).
I’m not sure it’s a necessarily desirable goal to remove all #[cfg] in the standard library, they’ve all gotta be somewhere right? I would love to minimize them to the absolute smallest set possible, but getting down to 0 seems like it may be overkill.
Migrate as much as possible away from rust_builtin (low prio, but would be nice)
I agree! We’ve basically already done this except for a few small pieces, and it’s just up to anyone to take care of the rest, however 
Overall I think before diving down into more implementation-detail related questions, we may want to refine a criper set of goals for something like this. For example:
- Why is the current organization insufficient? How would a new structure improve these problems while retaining the same pros of today?
- What are precisely the problems this is trying to solve? This’ll help flesh out precisely where the pain points are today, and perhaps allow us to see some less invasive solutions.
- etc
This is basically the kind of thought process that goes into writing an RFC, and I definitely think that a major restructuring of the standard library will require an RFC (regardless of it being a private implementation detail). Excited to see progress here though!