Building a Linux Kernel Natively on macOS: A Journey Through Compilation Hell

2025-07-03
Building a Linux Kernel Natively on macOS: A Journey Through Compilation Hell

This post details the author's experience building a Linux kernel (RISC-V architecture) natively on macOS. The journey was fraught with challenges: an outdated make version, macOS's ld being incompatible with Linux expectations, missing elf.h and byteswap.h headers, and version conflicts with uuid_t and sed. The author overcame these by using Homebrew to install updated toolchains (make, llvm, lld, libelf, gnu-sed) and creating patches to address header file discrepancies and type definition conflicts. The kernel was successfully built, with macOS showing faster build times than Docker for clean builds, but slower incremental builds. The author concludes that fixing build issues is an ongoing, iterative process similar to continuous integration.

Read more
Development

Starina: A Microkernel OS with a Hypervisor-as-a-Library Approach

2025-05-20
Starina: A Microkernel OS with a Hypervisor-as-a-Library Approach

This post introduces an innovative approach to Linux compatibility in the Starina operating system: integrating the virtual machine monitor (VMM) as a library within applications. Unlike traditional standalone VMMs, Starina's `starina_linux::Command` API lets developers run Linux programs similarly to `std::process::Command`, interacting with the VM via a virtual file system (virtio_fs). This design simplifies development and has the potential to achieve faster startup times than native Linux. Currently, basic file I/O is supported; future work includes adding networking, persistent storage, and enhanced containerization.

Read more
Development microkernel

Building a RISC-V Hypervisor in Starina OS: From Hello World to Booting Linux

2025-05-17
Building a RISC-V Hypervisor in Starina OS: From Hello World to Booting Linux

This post documents the author's journey building a lightweight RISC-V H-extension based hypervisor within the Starina operating system. Leveraging QEMU for RISC-V H-extension emulation, the author incrementally implemented guest mode entry, system call handling, a simple Hello World program, and finally, Linux kernel booting. Challenges including page table management, device tree setup, timer support, and MMIO were overcome, with detailed steps and solutions provided. The post concludes with a successful Linux boot within the Starina hypervisor.

Read more
Development