-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Redesign the interface to the unikernel HermitCore #65167
Conversation
- the old interface between HermitCore and the Rust Standard Library based on a small C library (newlib) - remove this interface and call directly the unikernel - remove the dependency to the HermitCore linker - use rust-lld as linker
Ping from triage |
Thanks for the PR @stlankes! This is quite a large amount of code coming in, but it looks like it's all in the Can you speak a little about this target, why it's being included in libstd, why it has a new directory for support, and what its maintenance story will look like going forward? |
@alexcrichton, you are right. Maybe I should explain our motivation. I am part of a research group for system software at a german university and use Rust in my operating system classes. We want to maintain and extend this part of libstd. The unikernel HermitCore is one of our projects. Unikernels are specialized, single-address-space machine images. Such kernels are typically used in the area of cloud computing. They shrink the attack surface and resource footprint of cloud services. The best known unikernel is maybe MirageOS. We already developed a version of HermitCore, which is part of libstd. However, it is mixture of C and Rust. Our objective is to remove C completely from our toolchain. C is in our opinion not valid to develop secure applications. The current version is only working within our hypervisor uhyve. A prototype is already working with @phil-opp bootimage, which converts a kernel into a valid boot image. Consequently, it runs on common hypervisors like qemu. A network is currently missing. We have also a prototype, which uses smoltcp as network stack. But it isn’t in a state to publish it. So, we have something in our pipeline. The current patch is already huge. This is our motivation to publish the current version and smaller extensions later. I hope that I have explained our motivation well. |
Ok thanks for the info! As I mentioned before we don't really have strict policies right now one way or another about how to organize libstd. It's generally left up to the reviewer and a few defacto ways that we manage a separate target in libstd. For example:
If that all sounds good, I'll review the integration points here and can r+ |
It is fine for me! Thanks for the support! |
src/libunwind/libunwind.rs
Outdated
__variant1, | ||
#[doc(hidden)] | ||
__variant2, | ||
} |
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.
Would it be possible to move these implementations to libc
?
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.
It is already in libc. I forgot only to remove my workaround. I will fix it.
@alexcrichton I follow your suggestions and revise my code. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
=> simplifies the maintenance of the interface
@alexcrichton Okay, I guess I was naive. I moved the C interface to special crate to simplify the maintenance. The crate isn't part of the whitelist. Do you add it on the whitelist or should I revert the last commit? |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Yes adding that to the whitelist should be fine, most new targets in Rust nowadays end up taking this strategy of moving the very low-level support to a separate crate that libstd then uses. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
⌛ Testing commit 805a330 with merge 5fa0e21b87fc68617b3bb0abd9288deef1b7e632... |
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
@alexcrichton What does the test failed? |
It's a network error. |
Redesign the interface to the unikernel HermitCore We are developing the unikernel HermitCore, where the kernel is written in Rust and is already part of the Rust Standard Library. The interface between the standard library and the kernel based on a small C library. With this pull request, we remove completely the dependency to C and use lld as linker. Currently, the kernel will be linked to the application as static library, which is published at https://github.com/hermitcore/libhermit-rs. We don’t longer support the C interface to the kernel. Consequently, we remove this part from the Rust Standard Library.
☀️ Test successful - checks-azure |
add basic HermitCore support within libtest This an extension to rust-lang#65167. The current pull request extend libtest to support HermitCore as target OS.
@alexcrichton Naive question. I need for my toolchain |
Ah sorry, I'm not quite sure, I haven't used that config option much myself. |
@alexcrichton No problem! |
@alexcrichton I have a version of RustyHermit, where I include my libos as crate instead of a static library. In this case, I am able to call directly Rust code from my kernel (e.g https://github.com/hermitcore/rust/blob/with-hermit/src/libstd/sys/hermit/mutex.rs#L12). However, I have to modify a few helper creates (log, rust-x86, rust-cupid,...). For instance, I modified log. Do you think that this a good idea? Can this be part of libstd? |
I think we'll want to continue to be pretty conservative with dependencies of the standard library, so we don't have a great way of adding new dependencies to libstd for third-party targets at this time unfortunately. |
No problem. I was expecting the answer.... |
Hermit: Remove floor symbol This symbol should be provided by Hermit. It was introduced in 2019 (rust-lang#65167). Since 2020, Hermit provides these math functions on its own (hermit-os/hermit-rs#37). I think moving this to Hermit was merely an oversight. Related: * hermit-os/kernel#654 * hermit-os/hermit-rs#406 CC: `@stlankes`
Hermit: Remove floor symbol This symbol should be provided by Hermit. It was introduced in 2019 (rust-lang/rust#65167). Since 2020, Hermit provides these math functions on its own (hermit-os/hermit-rs#37). I think moving this to Hermit was merely an oversight. Related: * hermit-os/kernel#654 * hermit-os/hermit-rs#406 CC: `@stlankes`
We are developing the unikernel HermitCore, where the kernel is written in Rust and is already part of the Rust Standard Library. The interface between the standard library and the kernel based on a small C library. With this pull request, we remove completely the dependency to C and use lld as linker. Currently, the kernel will be linked to the application as static library, which is published at https://github.com/hermitcore/libhermit-rs.
We don’t longer support the C interface to the kernel. Consequently, we remove this part from the Rust Standard Library.