-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add x86_64-unikraft-linux-musl
target
#113411
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bb77aa8
compiler: Add `x86_64-unikraft-linux-musl` target
mkroening 71ad558
compiler: Add `*-unikraft-linux-musl` documentation
mkroening 2b8a284
bootstrap: Don't bundle musl on Unikraft
mkroening 7485e9c
`unix::init`: Handle `ENOSYS` from `poll` on Unikraft.
mkroening 5538047
`unix::init`: Don't use `signal` on Unikraft.
mkroening File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
compiler/rustc_target/src/spec/unikraft_linux_musl_base.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::spec::{cvs, PanicStrategy, RelocModel, TargetOptions}; | ||
|
||
pub fn opts() -> TargetOptions { | ||
TargetOptions { | ||
os: "linux".into(), | ||
env: "musl".into(), | ||
vendor: "unikraft".into(), | ||
linker: Some("kraftld".into()), | ||
relocation_model: RelocModel::Static, | ||
families: cvs!["unix"], | ||
has_thread_local: true, | ||
panic_strategy: PanicStrategy::Abort, | ||
..Default::default() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
compiler/rustc_target/src/spec/x86_64_unikraft_linux_musl.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "x86_64-unknown-linux-musl".into(), | ||
pointer_width: 64, | ||
arch: "x86_64".into(), | ||
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
.into(), | ||
options: TargetOptions { | ||
cpu: "x86-64".into(), | ||
plt_by_default: false, | ||
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]), | ||
max_atomic_width: Some(64), | ||
stack_probes: StackProbeType::X86, | ||
..super::unikraft_linux_musl_base::opts() | ||
}, | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# `*-unikraft-linux-musl` | ||
|
||
**Tier: 3** | ||
|
||
Targets for the [Unikraft] Unikernel Development Kit (with musl). | ||
|
||
[Unikraft]: https://unikraft.org/ | ||
|
||
Target triplets available so far: | ||
|
||
- `x86_64-unikraft-linux-musl` | ||
|
||
## Target maintainers | ||
|
||
- Martin Kröning ([@mkroening](https://github.com/mkroening)) | ||
|
||
## Requirements | ||
|
||
These targets only support cross-compilation. | ||
The targets do support std. | ||
|
||
Unikraft pretends to behave exactly like Linux. | ||
How much of that functionality is available depends on the individual unikernel configuration. | ||
For example, the basic Unikraft + musl config does not support `poll` or networking out of the box. | ||
That functionality requires enabling [`LIBPOSIX_EVENT`] or [lwIP] respectively. | ||
|
||
[`LIBPOSIX_EVENT`]: https://github.com/unikraft/unikraft/blob/RELEASE-0.13.1/lib/posix-event/Config.uk | ||
[lwIP]: https://github.com/unikraft/lib-lwip | ||
|
||
The Unikraft targets follow Linux's `extern "C"` calling convention. | ||
|
||
For these targets, `rustc` does not perform the final linking step. | ||
Instead, the Unikraft build system will produce the final Unikernel image for the selected platform (e.g., KVM, Linux user space, and Xen). | ||
|
||
## Building the targets | ||
|
||
You can build Rust with support for the targets by adding it to the `target` list in `config.toml`: | ||
|
||
```toml | ||
[build] | ||
build-stage = 1 | ||
target = [ "x86_64-unikraft-linux-musl" ] | ||
``` | ||
|
||
## Building Rust programs | ||
|
||
Rust does not yet ship pre-compiled artifacts for these targets. | ||
To compile for these targets, you will either need to build Rust with the targets enabled | ||
(see “Building the targets” above), or build your own copy of `core` by using `build-std` or similar. | ||
|
||
Linking requires a [KraftKit] shim. | ||
See [unikraft/kraftkit#612] for more information. | ||
|
||
[KraftKit]: https://github.com/unikraft/kraftkit | ||
[unikraft/kraftkit#612]: https://github.com/unikraft/kraftkit/issues/612 | ||
|
||
## Testing | ||
|
||
The targets do support running binaries in the form of unikernel images. | ||
How the unikernel image is run depends on the specific platform (e.g., KVM, Linux user space, and Xen). | ||
The targets do not support running the Rust test suite. | ||
|
||
## Cross-compilation toolchains and C code | ||
|
||
The targets do support C code. | ||
To build compatible C code, you have to use the same compiler and flags as does the Unikraft build system for your specific configuration. | ||
The easiest way to achieve that, is to build the C code with the Unikraft build system when building your unikernel image. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.