Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC: Make libstd a facade #40
Conversation
thestinger
reviewed
Apr 8, 2014
|
|
||
| # Unresolved questions | ||
|
|
||
| * Compile times. It's possible that having so many upstream crates for each rust |
This comment has been minimized.
This comment has been minimized.
thestinger
Apr 8, 2014
The duplicate compilation of inline and/or generic functions hurts a lot too.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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 |
brendanzab
reviewed
Apr 8, 2014
| * librustrt: libmini liballoc liblibc | ||
| * libsync: libmini liballoc liblibc librustrt | ||
| * libstd: everything above | ||
|
|
This comment has been minimized.
This comment has been minimized.
bstrie
reviewed
Apr 8, 2014
| ### `libmini` | ||
|
|
||
| > **Note**: The name `libmini` warrants bikeshedding. Please consider it a | ||
| > placeholder for the name of this library. |
This comment has been minimized.
This comment has been minimized.
bstrie
Apr 8, 2014
Contributor
If we're bikeshedding, I propose libcore. Historical precedent, and you even use the word "core" in the next sentence.
This comment has been minimized.
This comment has been minimized.
bstrie
reviewed
Apr 8, 2014
| being said, libmini would certainly create many literal strings (for error | ||
| messages and such). This may be adequately circumvented by having literal | ||
| strings create a value of type `&'static [u8]` if the string lang item is not | ||
| present. While difficult to work with, this may get us 90% of the way there. |
This comment has been minimized.
This comment has been minimized.
bstrie
Apr 8, 2014
Contributor
You say above that strings "will no longer be a language item", yet here "if the string lang item is not present".
This comment has been minimized.
This comment has been minimized.
alexcrichton
Apr 10, 2014
Author
Member
I've clarified the wording for the first mention to be a "language feature" rather than a "language item"
andrew-d
reviewed
Apr 9, 2014
| to no overhead required in terms of dependencies. | ||
|
|
||
| Neither `print!` nor `format!` macros to be a part of this library, but the | ||
| `write!` macro to be present. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'm concerned at the potential ramifications of leaving out strings from libmini. Perhaps traitsplosion would be acceptable in this case? |
This comment has been minimized.
This comment has been minimized.
Tobba
commented
Apr 9, 2014
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
Tobba
commented
Apr 9, 2014
|
I'm pretty sure the Failure section specifically mentions that libmini requires weak lang items for failure in .unwrap? |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
Tobba
commented
Apr 9, 2014
|
Implementing weak lang items for only a single function instead of a generic solution sounds like a bad idea to me. |
This comment has been minimized.
This comment has been minimized.
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). |
This comment has been minimized.
This comment has been minimized.
Tobba
commented
Apr 10, 2014
|
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. |
This comment has been minimized.
This comment has been minimized.
|
libcore is indeed clear and self-explanatory. libmetal would be very neat, the metal upon which rust forms. |
This comment has been minimized.
This comment has been minimized.
bjadamson
commented
Apr 14, 2014
This would end up being really sad for the kernel developers! |
This comment has been minimized.
This comment has been minimized.
mcpherrinm
commented
Apr 15, 2014
|
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. |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Apr 20, 2014
|
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 |
This comment has been minimized.
This comment has been minimized.
libmini/libprim is a good name, libcore is a better name, |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Apr 23, 2014
|
|
ghost
referenced this pull request
Apr 25, 2014
Closed
Add support for alternative C libraries #7283
brson
merged commit b7f346e
into
rust-lang:master
Apr 29, 2014
This comment has been minimized.
This comment has been minimized.
|
Accepted as RFC 12, per https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-04-29 |
This comment has been minimized.
This comment has been minimized.
|
I talked to @thestinger on IRC, and he was ok with naming the innermost library "libcore", so I will likely call it that. |

alexcrichton commentedApr 8, 2014
No description provided.