-
-
Notifications
You must be signed in to change notification settings - Fork 5
Building
NyxOS builds with a stock GCC targeting -m64 freestanding — no cross-compiler is strictly required, though x86_64-elf-gcc works too. The primary development environment is Windows with WSL: build.ps1 shells into WSL to run make, and run.ps1 launches QEMU on the Windows side.
See also: Architecture, Boot Process, Networking Stack, Version History
| Tool | Notes |
|---|---|
| GCC | Host gcc with -m64, or x86_64-elf-gcc
|
| NASM | Assembles boot.asm, crt0.asm, the AP trampoline and the ISR stubs |
| GNU ld | Linked with -T linker.ld
|
| grub-mkrescue + xorriso | Builds the bootable ISO (grub-pc-bin on Debian/Ubuntu) |
| QEMU | 7.0+ recommended (qemu-system-x86_64) |
| Python 3 | Regenerates the initramfs |
On Debian/Ubuntu or WSL:
sudo apt install build-essential nasm grub-pc-bin grub-common xorriso qemu-system-x86 python3.\build.ps1Compiles the kernel through WSL, reports the size of kernel/nyx-kernel.bin, then generates NyxOS.iso with grub-mkrescue. Add -Clean to force a full rebuild.
.\run.ps1Boots the ISO in QEMU. Modes and options:
| Invocation | Effect |
|---|---|
.\run.ps1 |
SDL display, serial log to qemu_serial.txt (default) |
.\run.ps1 -Mode serial |
-nographic, serial on stdio — the kernel shell |
.\run.ps1 -Mode net |
SDL display plus an RTL8139 NIC (-nic user,model=rtl8139) |
.\run.ps1 -Mode debug |
SDL display plus -d cpu_reset,int
|
-Cpus <n> |
CPU count, default 4 (see SMP) |
-Sound |
Attaches an SB16 device (implied by -Mode net) |
The guest gets 512 MB and -cpu qemu64. If ext2-test.img is present it is attached as -hda; NyxOS auto-mounts it at /mnt, which is also where doom1.wad must live for DOOM to start.
make -C kernelThis builds the kernel and every user/*.elf — all: depends on $(USER_ELFS) as well as nyx-kernel.bin. Then:
qemu-system-x86_64 -cdrom NyxOS.iso -m 512M -smp 4 -no-reboot -cpu qemu64 \
-hda ext2-test.img -nic user,model=rtl8139 -serial stdiomake -C kernel # build kernel + user ELFs
make -C kernel clean # remove objects, .d files and binariesCompiler flags:
-std=gnu99 -ffreestanding -Os -Wall -Wextra
-nostdlib -nostartfiles -nodefaultlibs
-fno-stack-protector -fno-pie -m64
-mno-red-zone -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
-mcmodel=large -ffunction-sections -fdata-sections -MMD -MP -I.
-mno-red-zone is mandatory: interrupt handlers would otherwise clobber the 128-byte red zone below RSP. -mcmodel=large is what lets kernel code at 0xFFFFFF80_00000000 reference its own symbols.
The build is expected to be warning-free. If make emits warnings, that is a regression.
Three separate bugs in this Makefile once shipped stale kernels silently, and the fixes are worth knowing about:
-
.DEFAULT_GOAL := allis set before-include. Each auto-generated.dfile starts with a rule likekernel.o: kernel.c …; because-includesits above theall:target, the first included rule would otherwise hijack the default goal, so a baremakebuilt onlykernel.oand never relinked. -
-MMD -MPheader dependencies. Every object now depends on every header it includes, so editing a macro intcp.hrebuildstcp.o. Previously onlykernel.hwas tracked, and a header-only change left stale objects — which masked a real capacity fix as a phantom "Heisenbug". -
linker.ldis a prerequisite ofnyx-kernel.bin. Editing the section layout now forces a relink.
If you suspect a stale build, make -C kernel clean is the reliable answer.
User ELFs are built by the same Makefile from user/. Each is linked as:
ld -nostdlib -m elf_x86_64 -e _start -Ttext 0x10000 \
-o prog.elf crt0.o --just-symbols=libc.so prog.o
--just-symbols=libc.so resolves libc symbols against the prelinked shared library without copying its code in — libc exists once in memory and is mapped into every process. A userspace program compiles with:
-std=gnu99 -Os -ffreestanding -nostdlib -m64 -mno-red-zone -I../user
See Userspace for the ABI and the available library surface.
The root filesystem is a CPIO (newc) archive embedded in the kernel as a C byte array. Regenerate it after adding or changing files:
python3 tools/mkinitramfs.py kernel/initramfs_data.h cBoth build.ps1 and run.ps1 generate iso/boot/grub/grub.cfg and call:
grub-mkrescue -o NyxOS.iso iso/| Symptom | Cause / fix |
|---|---|
gcc: command not found |
Install GCC, or set CC in kernel/Makefile
|
nasm: command not found |
sudo apt install nasm |
grub-mkrescue: not found |
sudo apt install grub-pc-bin grub-common xorriso |
| ISO builds but QEMU shows the GRUB rescue prompt |
grub-mkrescue needs xorriso; check its stderr, which build.ps1 suppresses |
| Changes don't take effect | Stale build — make -C kernel clean and rebuild |
| Triple fault on boot | Run -Mode debug (-d cpu_reset,int) and read the last interrupt vector; usual causes are bad page tables, an unloaded IDT, or a boot-stack overflow |
| Desktop never appears | VBE mode set failed; check the serial log for VBE mode set failed — the kernel falls back to the text shell |
| DOOM exits immediately |
/mnt/doom1.wad is missing; attach ext2-test.img
|
| No network | Boot with -Mode net (or add -nic user,model=rtl8139); check ifconfig for a DHCP lease |
qemu-system-x86_64 not found |
run.ps1 probes the usual install paths; add QEMU to PATH if it lives elsewhere |
-
Serial log. In
guiandnetmodes everything the kernel prints goes toqemu_serial.txt. This is the first place to look. -
Interrupt trace.
-Mode debugadds-d cpu_reset,int. Unlike serialprintf, this does not perturb timing, which is how several race conditions in this codebase were actually found. -
Kernel shell.
-Mode serialgives an interactive kernel shell over stdio withmem,ps,cpus,hexdumpand the whole self-test suite. See Shell. -
Self-tests. The kernel ships known-answer tests for most cryptographic and image code —
x25519test,gcmtest,p256test,p384test,rsatest,sha512test,chaintest,csprngtest,deflatetest,pngtest,bmptest,giftest— pluscowtest,tlbtest,smpstressandmtdemofor the kernel core.
NyxOS v6.4.363 · GPL v2 · GitHub · uselessalter on Discord · nyxos@inbox.lv
NyxOS Wiki
Getting started
Kernel
Storage & network
Graphics & apps
Userspace
HOWTO
- HOWTO-Add-a-system-call
- HOWTO-Write-a-userspace-program
- HOWTO-Add-a-shell-command
- HOWTO-Add-a-GUI-application
Reference
- Syscall-Reference
- Command-Reference
- Hardware-Reference
- Format-Reference
- Kernel-Data-Structures
- Source-Tree-Reference
Project