Uh oh!
There was an error while loading. Please reload this page.
RFC: Split out OS-specific bits in the runtime to help support freestanding targets. - #185
RFC: Split out OS-specific bits in the runtime to help support freestanding targets.#185miselin wants to merge 1 commit into
Conversation
brson
commented
Jul 25, 2014
I like the general idea of creating a platform abstraction crate for the standard library. |
alexcrichton
commented
Jul 25, 2014
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. |
miselin
commented
Jul 25, 2014
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 |
miselin
commented
Jul 25, 2014
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. |
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. |
miselin
commented
Jul 25, 2014
@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 |
thestinger
commented
Jul 25, 2014
It doesn't belong in |
pczarn
commented
Jul 25, 2014
It might belong in between |
Ericson2314
commented
Jul 28, 2014
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! |
Ericson2314
commented
Jul 28, 2014
Not be self-promoting, but my proposal here mentions this issue http://discuss.rust-lang.org/t/traits-ml-modules/272 . |
brson
commented
Jul 28, 2014
@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. |
pczarn
commented
Jul 28, 2014
For reference, this is the most relevant part of the dependency graph. gist / Old source |
bharrisau
commented
Jul 28, 2014
That is a bit out of date. Pretty sure |
pczarn
commented
Jul 28, 2014
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 |
miselin
commented
Jul 29, 2014
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 |
bharrisau
commented
Jul 29, 2014
Sorry - wrong RFC. I was lazy. |
miselin
commented
Jul 29, 2014
An initial POC of this is now in my fork of the Rust repo. |
bharrisau
commented
Jul 29, 2014
The only allocation is a raw call to malloc in |
miselin
commented
Jul 29, 2014
I have updated the POC branch in my fork. I have done a trivial removal of |
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 |
miselin
commented
Jul 29, 2014
I've updated the POC branch with work so far on having I am thinking about updating the RFC to add something like an |
pczarn
commented
Jul 29, 2014
I'm assuming support for custom allocators in the future. I don't think |
miselin
commented
Jul 29, 2014
@pczarn what timeline is there for custom allocators? (@alexcrichton, @brson might also have an idea?) |
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. |
bharrisau
commented
Jul 29, 2014
@miselin It looks like the main issue you are having breaking the dependency between |
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 |
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 |
miselin
commented
Jul 31, 2014
@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...
|
bharrisau
commented
Jul 31, 2014
And From my quick look, |
bharrisau
commented
Jul 31, 2014
It's starting to form into 4 layers
|
miselin
commented
Jul 31, 2014
I completely missed where Yes, I agree. That is the goal - modify/create |
miselin
commented
Jul 31, 2014
If |
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 |
miselin
commented
Jul 31, 2014
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. |
Ericson2314
commented
Jul 31, 2014
@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? |
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. |
miselin
commented
Aug 1, 2014
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 |
Ericson2314
commented
Aug 1, 2014
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. |
alexchandel
commented
Aug 2, 2014
I'd be in favor of having separate And without these, |
alexchandel
commented
Aug 2, 2014
@bharrisau Even though rlibc doesn't replace libc, why can't we still make these language items? |
miselin
commented
Aug 2, 2014
@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 |
Ericson2314
commented
Aug 3, 2014
@miselin I meant remove libc from the other creates. We are well on our way to limiting usage of libc and |
Ericson2314
commented
Aug 3, 2014
Another POC, basically taking As I see it, moving the io stuff out of So
|
miselin
commented
Aug 3, 2014
@Ericson2314 I had a quick look, but it seems like One of the things What are your thoughts on this? |
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. |
Ericson2314
commented
Aug 4, 2014
@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.
|
miselin
commented
Aug 4, 2014
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." |
alexcrichton
commented
Sep 18, 2014
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! |


Readable/formatted/published version.