Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Figure out how to make std work #121

Open
geofft opened this issue Aug 18, 2019 · 3 comments
Open

Figure out how to make std work #121

geofft opened this issue Aug 18, 2019 · 3 comments

Comments

@geofft
Copy link
Collaborator

geofft commented Aug 18, 2019

There are a couple of annoying things about #![no_std], including:

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?)

geofft added a commit that referenced this issue Aug 18, 2019
Depends on a byteorder crate locally patched to make std not a default
feature, see #121 for why.
geofft added a commit that referenced this issue Aug 19, 2019
Depends on a byteorder crate locally patched to make std not a default
feature, see #121 for why.
@geofft
Copy link
Collaborator Author

geofft commented Aug 23, 2019

From the other direction, if we wanted to spin out std::io into its own sysroot crate with a dependency on core and alloc, that looks tractable. std::io uses system bindings for these:

  • crate::sys in mod stdio, which we can leave in std::io
  • crate::sys in mod lazy, which is only used by mod stdio
  • crate::sys in mod error for functions interacting with the Repr::Os enum variant. Repr is this non-public enum which sits inside Error to hide the actual types:
enum Repr {
    Os(i32),
    Simple(ErrorKind),
    Custom(Box<Custom>),
}

We can refactor out the Simple and Custom variants into the standalone variant and transparently use it here without changing std::io's public API.

(It also uses crate::sys_common for a default buffer size, hard-coded as 8 * 1024 on all platforms. This isn't actually platform-specific, it'd just need to be moved around.)

@geofft
Copy link
Collaborator Author

geofft commented Aug 23, 2019

On the other hand, there are some platforms (cloudapi, sgx, wasi, wasm) that make extensive use of an unsupported error in their system-specific implementations, see git grep unsupported src/libstd/sys, so having a libstd in kernelspace that claims everything is unsupported isn't totally unprecedented.

@geofft
Copy link
Collaborator Author

geofft commented Aug 23, 2019

BTW the answer from Gitter is patches welcome to xbuild to compile a custom std, but also xargo should still work.

geofft added a commit that referenced this issue Aug 25, 2019
Depends on a byteorder crate locally patched to make std not a default
feature, see #121 for why.
geofft added a commit that referenced this issue Aug 25, 2019
Depends on a byteorder crate locally patched to make std not a default
feature, see #121 for why.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant