Skip to content

Commit 71ad558

Browse files
committed
compiler: Add *-unikraft-linux-musl documentation
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
1 parent bb77aa8 commit 71ad558

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- [sparc-unknown-none-elf](./platform-support/sparc-unknown-none-elf.md)
4343
- [*-pc-windows-gnullvm](platform-support/pc-windows-gnullvm.md)
4444
- [\*-nto-qnx-\*](platform-support/nto-qnx.md)
45+
- [*-unikraft-linux-musl](platform-support/unikraft-linux-musl.md)
4546
- [*-unknown-hermit](platform-support/hermit.md)
4647
- [\*-unknown-netbsd\*](platform-support/netbsd.md)
4748
- [*-unknown-openbsd](platform-support/openbsd.md)

src/doc/rustc/src/platform-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ target | std | host | notes
326326
[`x86_64-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | ✓ |
327327
`x86_64-pc-windows-msvc` | * | | 64-bit Windows XP support
328328
`x86_64-sun-solaris` | ? | | Deprecated target for 64-bit Solaris 10/11, illumos
329+
[`x86_64-unikraft-linux-musl`](platform-support/unikraft-linux-musl.md) | ✓ | | 64-bit Unikraft with musl
329330
`x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD
330331
`x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku
331332
[`x86_64-unknown-hermit`](platform-support/hermit.md) | ✓ | | x86_64 Hermit
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# `*-unikraft-linux-musl`
2+
3+
**Tier: 3**
4+
5+
Targets for the [Unikraft] Unikernel Development Kit (with musl).
6+
7+
[Unikraft]: https://unikraft.org/
8+
9+
Target triplets available so far:
10+
11+
- `x86_64-unikraft-linux-musl`
12+
13+
## Target maintainers
14+
15+
- Martin Kröning ([@mkroening](https://github.com/mkroening))
16+
17+
## Requirements
18+
19+
These targets only support cross-compilation.
20+
The targets do support std.
21+
22+
Unikraft pretends to behave exactly like Linux.
23+
How much of that functionality is available depends on the individual unikernel configuration.
24+
For example, the basic Unikraft + musl config does not support `poll` or networking out of the box.
25+
That functionality requires enabling [`LIBPOSIX_EVENT`] or [lwIP] respectively.
26+
27+
[`LIBPOSIX_EVENT`]: https://github.com/unikraft/unikraft/blob/RELEASE-0.13.1/lib/posix-event/Config.uk
28+
[lwIP]: https://github.com/unikraft/lib-lwip
29+
30+
The Unikraft targets follow Linux's `extern "C"` calling convention.
31+
32+
For these targets, `rustc` does not perform the final linking step.
33+
Instead, the Unikraft build system will produce the final Unikernel image for the selected platform (e.g., KVM, Linux user space, and Xen).
34+
35+
## Building the targets
36+
37+
You can build Rust with support for the targets by adding it to the `target` list in `config.toml`:
38+
39+
```toml
40+
[build]
41+
build-stage = 1
42+
target = [ "x86_64-unikraft-linux-musl" ]
43+
```
44+
45+
## Building Rust programs
46+
47+
Rust does not yet ship pre-compiled artifacts for these targets.
48+
To compile for these targets, you will either need to build Rust with the targets enabled
49+
(see “Building the targets” above), or build your own copy of `core` by using `build-std` or similar.
50+
51+
Linking requires a [KraftKit] shim.
52+
See [unikraft/kraftkit#612] for more information.
53+
54+
[KraftKit]: https://github.com/unikraft/kraftkit
55+
[unikraft/kraftkit#612]: https://github.com/unikraft/kraftkit/issues/612
56+
57+
## Testing
58+
59+
The targets do support running binaries in the form of unikernel images.
60+
How the unikernel image is run depends on the specific platform (e.g., KVM, Linux user space, and Xen).
61+
The targets do not support running the Rust test suite.
62+
63+
## Cross-compilation toolchains and C code
64+
65+
The targets do support C code.
66+
To build compatible C code, you have to use the same compiler and flags as does the Unikraft build system for your specific configuration.
67+
The easiest way to achieve that, is to build the C code with the Unikraft build system when building your unikernel image.

0 commit comments

Comments
 (0)