-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Make libstd a facade #40
Conversation
|
||
# Unresolved questions | ||
|
||
* Compile times. It's possible that having so many upstream crates for each rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The duplicate compilation of inline and/or generic functions hurts a lot too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll add a comment to this section.
I like this. What would happen to the other crates currently in the rust repo that you didn't mention? Could they be moved out into separate repositories once the cargo situation is nicer? On a bikeshedding note, I would prefer |
* librustrt: libmini liballoc liblibc | ||
* libsync: libmini liballoc liblibc librustrt | ||
* libstd: everything above | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned at the potential ramifications of leaving out strings from libmini. Perhaps traitsplosion would be acceptable in this case? |
Since libmini would already require weak lang items, I feel we might want to expand that system in some way so we could make liballoc pluggable instead of everything directly linking to a specific allocator (unless pluggability is already a part of the plan for liballoc, the description is a bit vague right now). This would make it possible to use libcollections, and by extension libtext, inside of a kernel, which would certainly be nice. |
libmini doesn't require weak lang items. it just wouldn't have code that requires those lang items. if you don't use them, they aren't required. |
I'm pretty sure the Failure section specifically mentions that libmini requires weak lang items for failure in .unwrap? |
I interpreted that paragraph as saying that the failure function itself will be the only "weak lang item", and that the full generalization of the feature would not be implemented. |
Implementing weak lang items for only a single function instead of a generic solution sounds like a bad idea to me. |
I believe that for now nothing will change, and cargo is their path to moving out of the repo.
This is mostly a limitation of not knowing anything about allocation rather than a worry about traits. If we continue to keep the #[lang = "str"]
pub struct Str([u8]); This type doesn't necessarily imply any allocations, and perhaps all of the non-allocating methods could be defined in libmini and traits may be able to add some allocating-ness later on (depending on how many methods allocate). If we don't go with the
I agree that this is a bit worrisome, and that was my general idea about how to do so. This is covered by the "libc is so core" unresolved question at the end, and I think that with libstd being a facade it will be possible to change this in the future without many backwards compatibility hazards (these crate structures will all be experimental, just not the reexported contents).
I did not intend to generalize the idea of "weak lang items" all lang items, but rather just failure and possibly allocation. I'm not entirely sure what a generic solution would look like because many lang items are not functions (such as the traits), but this is definitely an open question about whether singling out failure/allocation is the correct way to go.
I'm not entirely sure if this will ever be possible, because liballoc is built on the assumption that allocation never fails, which isn't quite true for kernel environments. User-space environments that aren't powered by libc, however, would benefit from this abstraction (switching out the default allocator). |
There has been some talk about weak "global" statics, which would make possibly make the libnative/libgreen situation a bit nicer and would allow for a proper pluggable liballoc. My proposal for weak fn lang items would be that their symbols are given special names, and default to being an external symbol in libraries. Then the compiler can complain at compile time of the application in case any are missing. Something similar could probably be applied for those weak statics. |
libcore is indeed clear and self-explanatory. libmetal would be very neat, the metal upon which rust forms. |
This would end up being really sad for the kernel developers! |
I'm pretty concerned about the fact that collections will require libc. It seems essential to me that providing a substitute allocator that doesn't depend on libc will allow libcollections and text to be used in a libc-free land. Having a more minimal "Host OS" requirement for allocation and such seems more amenable to me, like newlib's "OS stubs" https://sourceware.org/newlib/libc.html#Stubs -- a significantly smaller API to implement than all of libc. |
Is it the wrong direction to go in to use weak fns and a split up like this Similar to how libmini would have Option.unwrap fail unless something like |
libmini/libprim is a good name, libcore is a better name, |
|
Accepted as RFC 12, per https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-04-29 |
I talked to @thestinger on IRC, and he was ok with naming the innermost library "libcore", so I will likely call it that. |
Update doc-comment refering to poll() returning None
Rendered