example of a native application for unikraft microkernels, built with a zig library
Go to file
2024-07-09 13:53:14 -07:00
ziggy add build script so zig build works (sort of) as expected 2024-07-08 21:53:02 -07:00
.config.helloworld_qemu-x86_64 add build script so zig build works (sort of) as expected 2024-07-08 21:53:02 -07:00
.gitignore add more build files to .gitignore 2024-07-08 19:52:43 -07:00
build.zig try to clean up empty directories (this does not always work...) 2024-07-09 13:53:06 -07:00
build.zig.zon add build script so zig build works (sort of) as expected 2024-07-08 21:53:02 -07:00
helloworld.c initial working example as made hacking around 2024-07-08 19:51:48 -07:00
Kraftfile initial working example as made hacking around 2024-07-08 19:51:48 -07:00
LICENSE initial working example as made hacking around 2024-07-08 19:51:48 -07:00
Makefile.uk add build script so zig build works (sort of) as expected 2024-07-08 21:53:02 -07:00
README.md update README 2024-07-09 13:53:14 -07:00
undefined.c initial working example as made hacking around 2024-07-08 19:51:48 -07:00

Native Unikraft Microkernel Build for Zig libraries

Building

Everything assumes Linux on x86_64, though some trivial changes should allow aarch64. Install the following:

Then run zig build run and everything will compile and run. The zig source code is all in the ziggy directory. This is all prototype level code at this point.

Reproducibility

This build is not reproducible at the moment. The problem is that we need v0.17.0 or higher (this may be an issue with QEMU installed version, so YMMV). Kraftfile is designed to pin to a specific version, but as of this writing, versions of unikraft core post 0.16.1 are not listed in https://manifests.kraftkit.sh/unikraft.yaml, and as a result cannot be used, so we are forced to use "stable" as the version.

undefined.c

This file aims to fill in all the undefined symbols that are referenced when a zig project links libC (necessary for unikraft kernel development). However, this is very incomplete. The .config.hellowworld_qemu-x86_64 file, usually managed by the invocation of the TUI started by kraft menu, will add/remove features that result in various libc symbols being implemented. A few #ifdef statements exist currently, but even the few that are in there aren't quite right...this file is mostly a "hack around until it works" effort.

Knowing that this is an initial effort, care was put into making sure that when a symbol is actually used at runtime, the unikernel will crash after posting a message indicating the specific function call that was involved. This is designed to either a) correct the configuration using kraft menu or b) provide an implementation directly in undefined.c. In some cases, I prefer the implementation in undefined.c, most specifically the write function, which will output stderr messages in red.

Notes

The build script basically runs these commands:

(cd ziggy && zig build)
LIBZIGGY=$(pwd)/ziggy/zig-out/lib/libziggy.a kraft build --plat qemu --arch x86_64 --log-level debug --log-type basic
kraft run --plat qemu --arch x86_64