Building the Kernel
The NØNOS kernel is a bare-metal x86_64 binary compiled with a custom target specification. This page covers the kernel build process in detail.
Overview
┌────────────────────────────────────────────────────────────────┐
│ KERNEL BUILD FLOW │
├────────────────────────────────────────────────────────────────┤
│ │
│ Source Code Build System Output │
│ ─────────── ──────────── ────── │
│ │
│ ┌─────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ .rs │────────▶│ Cargo │───────▶│ ELF64 │ │
│ │ files │ │ + build.rs │ │ Binary │ │
│ └─────────┘ └─────────────┘ └────── ──────┘ │
│ │ │
│ ┌─────────┐ │ │ │
│ │ PQClean │───────────────┘ │ │
│ │ (C) │ ML-KEM-768 ▼ │
│ └─────────┘ ┌─────────────┐ │
│ │ Ed25519 │ │
│ ┌─────────┐ │ Signing │ │
│ │ Signing │───────────────────────────────▶ │ │
│ │ Key │ └──────┬──────┘ │
│ └─────────┘ │ │
│ ▼ │
│ ┌─────────────┐ │
│ │ kernel.bin │ │
│ │ 221 KB │ │
│ └─────────────┘ │
│ │
└────────────────────────────────────────────────────────────────┘Build Command
Or build everything at once:
Build Configuration
The kernel build uses several critical flags:
-Zbuild-std=core,alloc
Compile core and alloc from source for no_std
-Zbuild-std-features=compiler-builtins-mem
Include memcpy, memset, memcmp intrinsics
--release
Enable optimizations, strip debug info
--target x86_64-nonos.json
Use custom bare-metal target
Custom Target Specification
The kernel uses x86_64-nonos.json, a custom target that defines:
Key decisions:
No red zone | Required for interrupt handlers
Software float | No SSE/MMX in kernel context
Abort on panic | No unwinding in bare-metal
Build Process
1. Cargo Compilation
1. Cargo CompilationCargo compiles all Rust code using the nightly toolchain with build-std to generate a freestanding binary.
2. PQClean Integration
2. PQClean IntegrationThe build.rs script compiles post-quantum cryptography from PQClean:
ML-KEM-768 | Key encapsulation (FIPS 203)
ML-DSA-65 | Digital signatures (FIPS 204)
These are compiled as static libraries and linked into the kernel.
3. Manifest Generation
3. Manifest Generationbuild.rs generates a manifest embedded in the .nonos.manifest section:
4. Signing
4. SigningThe kernel is signed with Ed25519:
Compute BLAKE3 hash of kernel binary (excluding signature section)
Sign hash with private key from
SIGNING_KEYenvironment variableEmbed 64-byte signature in
.nonos.sigsection
Output Binary
Format
ELF64 x86_64
Size
~221 KB (stripped)
Load Address
0x100000 (1 MB)
Entry Point
kernel_main
Sections
.text, .rodata, .data, .bss, .nonos.manifest, .nonos.sig
Platform-Specific Configuration
macOS
The Makefile sets SDK paths for cross-compilation:
Linux
No additional configuration required. Ensure build-essential is installed.
Signing Key Management
Development
Auto-generated dev_signing_key.bin
CI/CD
SIGNING_KEY environment variable
Production
Hardware security module or secure key storage
For production key generation, see Key Generation.
Verification
Verify the build succeeded:
Troubleshooting
requires nightly
rustup default nightly
can't find crate for core
rustup component add rust-src
linker not found
rustup component add llvm-tools-preview
macOS linker errors
xcode-select --install
Next
NextBuilding the Bootloader | Compile the UEFI bootloader
Running in QEMU | Test your build
Symbols & Debugging | Debug with GDB
Last updated
Was this helpful?


