This repository was archived by the owner on Mar 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 122
This repository was archived by the owner on Mar 7, 2021. It is now read-only.
Figure out how to make std work #121
Copy link
Copy link
Open
Description
There are a couple of annoying things about #![no_std], including:
- Cargo doesn't handle having different flags on a crate that's used as both a build-dependency and a runtime dependency (Features of dependencies are enabled if they're enabled in build-dependencies; breaks no_std libs rust-lang/cargo#5730, Build script using std can't compile rust-osdev/cargo-xbuild#10). This means that none of the dependencies of
bindgenthat are optionally-no-std are usable. Notably, this includes byteorder, which is both useful in its own right and an indirect dependency of serde-json-core. - Most no-std crates interpret that to mean no-alloc either, although allocation works totally fine for us. Regular serde-json is capable of handling dynamic structures (e.g., deserializing a
Vec); serde-json-core is not. - While in theory you could add a feature flag serde-json for no-std but yes-alloc (Support no_std serde-rs/json#362), in practice it seems all of its serialization uses the
std::io::Writetrait and theimpl Write for Vec<u8>implementation, so it would be a sizable rewrite to make the crate functional without std. - As noted in Are there things in libstd that we want? #38 and make C strings a little more ergonomic #16, there are other things we likely want from libstd, including hash maps, hash sets, an
std::ffi.
I think we should try to port over libstd, by making all the filesystem, subprocess, etc.operations just unconditionally return Err. (Bonus points if we can raise compile-time errors with cfg but that seems like a bigger delta against upstream libstd than I'd like.)
I'm not sure how to do that, though - xargo would have been the obvious answer in the past. I asked over in the rust-osdev Gitter if anyone has recommendations. And as #38 mentions, we'll probably want a bot to automatically rebase our version of it, until it gets upstreamed. (But I suspect this is a reasonable thing to want to upstream and other projects will want it?)
Metadata
Metadata
Assignees
Labels
No labels