Building SlayerOS
This guide explains how to build SlayerOS from source code. The build process creates a bootable ISO image that can be run in a virtual machine or installed on physical hardware.
Prerequisites
Before building SlayerOS, ensure you have the following tools installed:
- GCC/G++ (10.0 or newer) with x86_64 cross-compilation support
- NASM (Assembly compiler)
- xorriso (For creating ISO images)
- make (Build automation tool)
- git (Version control)
- qemu (For testing, optional)
Ubuntu/Debian
sudo apt update
sudo apt install build-essential nasm xorriso make git qemu-system-x86Arch Linux
sudo pacman -S base-devel nasm libisoburn make git qemumacOS (using Homebrew)
brew install x86_64-elf-gcc nasm xorriso make git qemuWindows (using WSL)
Install WSL with Ubuntu, then follow the Ubuntu instructions above.
Getting the Source Code
Clone the repository with submodules:
git clone --recursive https://github.com/slayer-os/SlayerOS.git
cd SlayerOSIf you already cloned without --recursive, initialize the submodules:
git submodule update --init --recursiveBuild Process
SlayerOS uses a Makefile-based build system with several targets:
Building the Kernel
To build just the kernel binary:
make kernelThis compiles the kernel source code and produces build/slay.kernel.
Building the ISO
To build a bootable ISO image:
make isoThis builds the kernel, sets up the ISO directory structure with the Limine bootloader, and creates build/slay.iso.
Building Everything
To build everything (kernel, libraries, and ISO):
make allCleaning the Build
To remove all build artifacts:
make cleanBuild System Structure
The build system consists of several components:
Main Makefile
The root Makefile coordinates the entire build process:
- Compiles the kernel source files
- Builds the LibC and drivers libraries
- Creates the ISO image with Limine
Base Makefile Fragment
misc/make/base.mk defines common variables:
- Compiler and linker flags
- Include paths
- QEMU options for testing
Linker Script
misc/linkage.ld controls how the kernel is linked:
- Defines memory layout
- Places sections (.text, .data, .bss)
- Sets the entry point
Custom Build Options
Debug Build
To build with debug symbols and assertions enabled:
make DEBUG=1Optimization Level
To change the optimization level:
make OPT_LEVEL=0 # No optimization (for debugging)
make OPT_LEVEL=2 # Default
make OPT_LEVEL=3 # Maximum optimizationCustom QEMU Options
To pass custom options to QEMU when testing:
make run QEMU_EXTRA="-m 1G -smp 2"Running the OS
In QEMU
To run the OS in QEMU after building:
make runWith GDB Debugging
To run with GDB debugging enabled:
make debugIn another terminal:
make gdbOn Real Hardware
To create a bootable USB drive (be careful with the device name):
sudo dd if=build/slay.iso of=/dev/sdX bs=4M status=progressTroubleshooting
Common Build Issues
Missing dependencies
- Error:
command not found - Solution: Install the missing tool
- Error:
Submodule issues
- Error:
No such file or directory: 'limine/limine-bios.sys' - Solution: Run
git submodule update --init --recursive
- Error:
Compilation errors
- Check compiler version:
g++ --version - Ensure you have the correct cross-compiler if needed
- Check compiler version:
ISO creation fails
- Verify xorriso is installed
- Check disk space
Getting Help
If you encounter issues not covered here:
- Check the GitHub repository issues
- Join the community Discord
- Open a new issue with detailed information about the problem