Overview
Portix OS uses a Python-based build system (build.py) that orchestrates the entire compilation pipeline from assembly bootloader to Rust kernel. The build system supports multiple output formats and boot modes.
Build System Architecture
The build process consists of several stages:Assembly compilation
Compile the bootloader stages with NASM:
boot.asm→boot.bin(Stage 1, 512 bytes)stage2.asm→stage2.bin(Stage 2, 64 sectors)isr.asm→isr.o(Interrupt service routines)
Rust kernel compilation
Build the kernel with cargo:The kernel is compiled with
no_std, panic=abort, and custom linker script.Disk image creation
Combine bootloader and kernel into disk image:
- Write boot sector (LBA 0)
- Write stage2 (LBA 1-64)
- Write kernel (LBA 65+)
- Update stage2 with kernel LBA
Build Script Options
Thebuild.py script accepts several command-line arguments:
| Option | Description | Default |
|---|---|---|
--mode=MODE | Output format: raw, iso, vdi, vmdk, ventoy-sim | raw |
--run | Build and run in QEMU | Not set |
--size=MB | Disk image size in MB | 8 MB |
--debug | Enable debug symbols and logging | Not set |
--clean | Clean build artifacts before building | Not set |
--no-serial | Disable serial port logging | Not set |
Build Modes
- Raw Disk Image
- ISO Image
- VirtualBox VDI
- VMware VMDK
build/portix.img - a raw disk image that can be:- Written to USB with
dd - Booted in QEMU with
-drive format=raw,file=portix.img - Used with Rufus or Etcher
Build Process Details
Assembly Compilation
The bootloader is written in x86 assembly and compiled with NASM:The boot sector must be exactly 512 bytes and end with the signature
0x55AA.
Stage 2 is limited to 64 sectors (32 KB) to fit before the kernel.Kernel Compilation
The kernel uses a custom target specification (x86_64-portix.json):
- no_std: No standard library
- panic=abort: No unwinding
- disable-redzone: Required for interrupt handlers
- soft-float: No FPU/SSE in kernel space
Disk Layout
The disk image follows this structure:Advanced Build Options
Debug Build
Enable debug symbols and verbose logging:- Debug assertions in Rust code
- Serial port logging to
build/logs/serial.log - Extended error messages
Clean Build
Force a complete rebuild:build/directorytarget/directory- All cached artifacts
Custom Disk Size
Specify disk image size:Build Artifacts
After a successful build, you’ll find:Troubleshooting
Rust nightly not found
Rust nightly not found
Install Rust nightly and set as default:
NASM not found
NASM not found
Install NASM assembler:
- Linux:
sudo apt install nasm - macOS:
brew install nasm - Windows: Download from https://www.nasm.us/
objcopy not found
objcopy not found
Install LLVM binutils:
- Linux:
sudo apt install llvm - macOS:
brew install llvm - Windows: Install LLVM from https://llvm.org/
Build fails with linker error
Build fails with linker error
Ensure
rust-lld is available:ISO creation fails
ISO creation fails
Install one of these tools:
xorriso:sudo apt install xorrisopycdlib:pip install pycdlib
--mode=raw instead.Next Steps
Testing
Learn how to test your build in QEMU and VirtualBox
Contributing
Read the contribution guidelines