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: Split out OS-specific bits in the runtime to help support freestanding targets. #185
Conversation
This comment has been minimized.
This comment has been minimized.
|
I like the general idea of creating a platform abstraction crate for the standard library. |
This comment has been minimized.
This comment has been minimized.
|
When initially extracting libcore, I found it quite helpful to have a mostly-working copy of libcore before drafting an RFC just to see what would actually work and what would have to be left behind. It may be beneficial to have a mostly-working version of what you would like for this as well. I, too, like the concept of centralizing platform-specific bits. It may be tough to abstract over unix/windows in all situations. If you're abstracting over I/O, for example, the interface is likely just libnative. For things like threads and mutexes, however, it can be useful to have a centralized location for them and they all have basically the same interface. |
This comment has been minimized.
This comment has been minimized.
|
I wonder then if perhaps the more 'correct' solution is to integrate these bits into libnative, rather than creating a new crate for the purpose. Moving things like |
This comment has been minimized.
This comment has been minimized.
|
RE the libcore mention - I can definitely start working on doing this splitting work to see what can be done easily and what requires more sweeping changes. If we can agree on the correct crate for this work to be done in (os, native, rustrt, etc), I can work on this. |
This comment has been minimized.
This comment has been minimized.
pczarn
commented
Jul 25, 2014
|
Will this new crate live in between libcore and liballoc? If so, using liballoc on a new system might require I imagine it wouldn't because the interface can be incomplete. |
This comment has been minimized.
This comment has been minimized.
|
@pczarn you raise a really good point, though with the current interface, writing a custom Ignoring the concept of custom allocators, which could (maybe?) solve the dependency there, I think moving the raw system allocation glue to |
This comment has been minimized.
This comment has been minimized.
thestinger
commented
Jul 25, 2014
|
It doesn't belong in |
This comment has been minimized.
This comment has been minimized.
pczarn
commented
Jul 25, 2014
|
It might belong in between |
This comment has been minimized.
This comment has been minimized.
|
On IRC I was thinking of the benefits of having multiple OS crates. Probably the most basic argument is to avoid adding extra dependencies to things that don't need it. Obviously liballoc need not relay on IO. More importantly though I'll take an OS crate over the current situation. libstd facade was a big step in the right direction, but something along these lines is needed to finish it! |
This comment has been minimized.
This comment has been minimized.
|
Not be self-promoting, but my proposal here mentions this issue http://discuss.rust-lang.org/t/traits-ml-modules/272 . |
This comment has been minimized.
This comment has been minimized.
|
@miselin Integrating into libnative will not work I think because of the dependencies. libnative is the last thing linked when building a Rust exe - nothing depends on it. |
This comment has been minimized.
This comment has been minimized.
pczarn
commented
Jul 28, 2014
|
For reference, this is the most relevant part of the dependency graph. gist / Old source |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 28, 2014
|
That is a bit out of date. Pretty sure |
This comment has been minimized.
This comment has been minimized.
pczarn
commented
Jul 28, 2014
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 29, 2014
|
And just to be aware - there is technically some OS specific stuff still hidden in LLVM frame lowering for segmented stack prologues (stack limits). Until something like #131 comes in anyway. Edit: Wrong rfc |
This comment has been minimized.
This comment has been minimized.
|
The LLVM-specific stuff certainly still exists, but yes - RFC #131 would solve that problem in a much better way. @pczarn - the problem with the location of |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 29, 2014
|
Sorry - wrong RFC. I was lazy. |
This comment has been minimized.
This comment has been minimized.
|
An initial POC of this is now in my fork of the Rust repo. |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 29, 2014
|
The only allocation is a raw call to malloc in |
This comment has been minimized.
This comment has been minimized.
|
I have updated the POC branch in my fork. I have done a trivial removal of |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 29, 2014
|
You'll probably need to look at Edit: Transmute to raw pointer is the same as forget. But you will need to |
This comment has been minimized.
This comment has been minimized.
|
I've updated the POC branch with work so far on having I am thinking about updating the RFC to add something like an |
This comment has been minimized.
This comment has been minimized.
pczarn
commented
Jul 29, 2014
|
I'm assuming support for custom allocators in the future. I don't think |
This comment has been minimized.
This comment has been minimized.
|
@pczarn what timeline is there for custom allocators? (@alexcrichton, @brson might also have an idea?) |
This comment has been minimized.
This comment has been minimized.
pczarn
commented
Jul 29, 2014
|
@miselin, the design won't be finished before 1.0, and not long after that, either... I guess. Actually, a pluggable default allocator is important to break the dependency on OS-specific heap. |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 29, 2014
|
@miselin It looks like the main issue you are having breaking the dependency between |
This comment has been minimized.
This comment has been minimized.
ryanra
commented
Jul 30, 2014
|
As @miselin and I were talking about on IRC, there are some potential pitfalls if a freestanding implementation for In general, the problem stems from an inability to specify dependencies within My preference would be to break up a potential |
This comment has been minimized.
This comment has been minimized.
mneumann
commented
Jul 30, 2014
|
As I just ported Rust to DragonFlyBSD, I am all in favor for this idea. Having target_os specific code scattered all around in different places is a bad thing IMHO, and you quickly can shoot yourself in the shoe when you forget something. Having a single "libos" makes testing for that specific target OS a lot easier I guess. For the library part (not rustc itself), I had to make target specific changes to The hardest part though is porting |
This comment has been minimized.
This comment has been minimized.
|
@ryanra one of my other problems with multiple OS crates is that it solves a problem for freestanding purposes that no other target ever has to worry about (because each other target has an established set of system libraries). I acknowledge the recursion problem this can cause, but I think creating N crates isn't the right solution. @bharrisau yup. I think we can get away with depending on things like I can certainly keep working on moving things into I did a quick check just now on a couple crates, and...
|
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 31, 2014
|
And From my quick look, |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 31, 2014
|
It's starting to form into 4 layers
|
This comment has been minimized.
This comment has been minimized.
|
I completely missed where Yes, I agree. That is the goal - modify/create |
This comment has been minimized.
This comment has been minimized.
|
If |
This comment has been minimized.
This comment has been minimized.
bharrisau
commented
Jul 31, 2014
|
In some ways, Some things will have an 'optimised' solution in Windows or Linux, but might still be doable in standard ANSI C. In that case, you can probably leave the |
This comment has been minimized.
This comment has been minimized.
|
I've updated the RFC with results from a quick scan over the code base. The POC branch has been updated to reflect the name EDIT: Relinking POC branch because it is now quite a few comments back. |
This comment has been minimized.
This comment has been minimized.
|
@ryanra Sorry I meant to say that is the best that can be done for a single OS create -- I originally advocated for multiple crates too. So if Also, if the platform implementations for existing OSes implement their own syscalls (which would be faster too) need anything that's not a wrap of a native library depend on libc? |
This comment has been minimized.
This comment has been minimized.
errordeveloper
commented
Aug 1, 2014
I don't think this is neither easy nor feasible, considering that the way of making a syscall on Linux differs depending on CPU architectures to start with. |
This comment has been minimized.
This comment has been minimized.
|
I've updated the RFC again. I'll put the most important part of the latest change here in this thread, which is what I've come up with so far in doing the POC: The outcome of this POC so far indicates that, with the
@Ericson2314 I'm not sure there is another place to move EDIT: or you could use |
This comment has been minimized.
This comment has been minimized.
|
I've been looking over the @miselin's proof of concept. My basic opinion is most code that uses This is a lot less feasible for Also a couple of random points:
I forked miselin's work to explore these ideas and will post links when ready. |
This comment has been minimized.
This comment has been minimized.
alexchandel
commented
Aug 2, 2014
|
I'd be in favor of having separate And without these, |
This comment has been minimized.
This comment has been minimized.
alexchandel
commented
Aug 2, 2014
|
@bharrisau Even though rlibc doesn't replace libc, why can't we still make these language items? |
This comment has been minimized.
This comment has been minimized.
|
@alexchandel with multiple crates, are you wanting to cherry-pick the crates that you do implement in this case? (eg, "I don't care about file I/O, so I won't write @Ericson2314 I think being able to remove the existence of |
This comment has been minimized.
This comment has been minimized.
|
@miselin I meant remove libc from the other creates. We are well on our way to limiting usage of libc and |
This comment has been minimized.
This comment has been minimized.
|
Another POC, basically taking As I see it, moving the io stuff out of So
|
This comment has been minimized.
This comment has been minimized.
|
@Ericson2314 I had a quick look, but it seems like One of the things What are your thoughts on this? |
This comment has been minimized.
This comment has been minimized.
errordeveloper
commented
Aug 3, 2014
|
I definitely agree with @alexchandel. In most of my recent projects we have embedded systems that do have networking, but have pretty much no use for filesystem. |
This comment has been minimized.
This comment has been minimized.
|
@miselin I agree that is a good goal. The problem is that the OS bits of rustc both depend and are dependent on the more portable bits. I'll try next to move the platform-agnostic stuff out of librustrt, but I'm not sure how far I'll get.
|
This comment has been minimized.
This comment has been minimized.
|
For what it's worth, my statement before should actually probably be "to abstract away all of the platform specifics, in a crate (or crates) that can be trivially implemented outside of the Rust source tree." |
aturon
referenced this pull request
Sep 10, 2014
Merged
RFC: Remove runtime system, and move libgreen into an external library #230
alexcrichton
force-pushed the
rust-lang:master
branch
from
6357402
to
e0acdf4
Sep 11, 2014
aturon
force-pushed the
rust-lang:master
branch
from
4c0bebf
to
b1d1bfd
Sep 16, 2014
nrc
assigned
alexcrichton
Sep 18, 2014
This comment has been minimized.
This comment has been minimized.
|
The planned state of the runtime, I/O interfaces, and synchronization primitives has shifted significantly from when this was open. With #230 now accepted, it's likely that the number of layers of abstraction between the standard library and the system you're running on is going to be greatly reduced. As a result, this RFC has since become a little out of date and may need significant re-wording to take into account #230. Additionally, there's quite a bit of discussion here which may need to get re-incorporated into the RFC. These will definitely be part of the driving principles of the rearchitecting of the runtime, however! Consequently, I'm going to close this for now, in the spirit of having as few in-flight RFCs for modifying the runtime as possible. I suspect that many of the concerns in this RFC will be addressed when #230 is completed, as well! Thanks again for the RFC, and I'm sure that the progress on #230 will definitely welcome comments throughout! |


miselin commentedJul 25, 2014
Readable/formatted/published version.