Files
darkforge/toolchain/README.md
Danny 029642ae5b Initial commit: DarkForge Linux — Phases 0-12
Complete from-scratch Linux distribution targeting AMD Ryzen 9 9950X3D +
NVIDIA RTX 5090 on ASUS ROG CROSSHAIR X870E HERO.

Deliverables:
- dpack: custom package manager in Rust (3,800 lines)
  - TOML package parser, dependency resolver, build sandbox
  - CRUX Pkgfile and Gentoo ebuild converters
  - Shared library conflict detection
- 124 package definitions across 4 repos (core/extra/desktop/gaming)
- 34 toolchain bootstrap scripts (LFS 13.0 adapted for Zen 5)
- Linux 6.19.8 kernel config (hardware-specific, fully commented)
- SysVinit init system with rc.d service scripts
- Live ISO builder (UEFI-only, squashfs+xorriso)
- Interactive installer (GPT partitioning, EFISTUB boot)
- Integration test checklist (docs/TESTING.md)

No systemd. No bootloader. No display manager.
Kernel boots via EFISTUB → auto-login → dwl Wayland compositor.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 11:30:40 +01:00

133 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# DarkForge Toolchain Bootstrap
Cross-compilation toolchain scripts that build the base system from scratch, following the Linux From Scratch (LFS 13.0) methodology with DarkForge-specific customizations.
## Overview
These scripts implement LFS Chapters 5-7, adapted for:
- **Target:** AMD Ryzen 9 9950X3D (Zen 5, `-march=znver5`)
- **Compiler:** GCC 15.2.0 (full znver5 support)
- **Target triplet:** `x86_64-darkforge-linux-gnu`
The build produces a self-hosting chroot environment capable of compiling everything else.
## Requirements
- A Linux host system (any recent distro)
- ~20GB free disk space
- Internet access (for downloading sources)
- Host tools: bash, gcc, g++, make, bison, gawk, m4, texinfo, xz, wget/curl
### Host System Verification
Check your host has the required tools:
```bash
# Verify essential tools are present
for cmd in bash gcc g++ make bison gawk m4 texinfo xz wget; do
command -v $cmd >/dev/null && echo "OK: $cmd" || echo "MISSING: $cmd"
done
```
## Build Process
### Step 1: Set up the environment
```bash
export LFS=/mnt/darkforge
# Create and mount your target partition
sudo mkdir -pv $LFS
sudo mount /dev/nvme0n1p3 $LFS # adjust device as needed
# Run the environment setup
sudo bash scripts/000-env-setup.sh
```
This creates the `lfs` user, directory structure, and environment variables.
### Step 2: Download sources
```bash
bash scripts/000a-download-sources.sh
```
Downloads all ~30 source tarballs to `$LFS/sources/`.
### Step 3: Build the cross-toolchain (Chapter 5)
```bash
bash scripts/build-all.sh cross
```
Builds: binutils (pass 1) → GCC (pass 1) → Linux headers → glibc → libstdc++
### Step 4: Build temporary tools (Chapter 6)
```bash
bash scripts/build-all.sh temp
```
Builds 17 packages: m4, ncurses, bash, coreutils, diffutils, file, findutils, gawk, grep, gzip, make, patch, sed, tar, xz, binutils (pass 2), GCC (pass 2).
### Step 5: Enter chroot and build native tools (Chapter 7)
```bash
sudo bash scripts/023-chroot-setup.sh
# Now inside the chroot:
bash /sources/toolchain-scripts/024-chroot-essentials.sh
bash /sources/toolchain-scripts/025-gettext.sh
# ... through 030-util-linux.sh
bash /sources/toolchain-scripts/031-cleanup.sh
```
### Step 6: Verify
The cleanup script runs a "Hello World" compilation test. If it passes, the toolchain is ready.
## Script Inventory
| Script | Phase | Description |
|--------|-------|-------------|
| `000-env-setup.sh` | Setup | Creates directories, lfs user, environment |
| `000a-download-sources.sh` | Setup | Downloads all source tarballs |
| `001-binutils-pass1.sh` | Ch.5 | Cross-assembler and linker |
| `002-gcc-pass1.sh` | Ch.5 | Cross-compiler (C/C++) |
| `003-linux-headers.sh` | Ch.5 | Linux API headers |
| `004-glibc.sh` | Ch.5 | GNU C Library (with sanity checks) |
| `005-libstdcxx.sh` | Ch.5 | C++ standard library |
| `006-m4.sh` `020-xz.sh` | Ch.6 | Temporary tools (15 packages) |
| `021-binutils-pass2.sh` | Ch.6 | Native binutils |
| `022-gcc-pass2.sh` | Ch.6 | Native GCC |
| `023-chroot-setup.sh` | Ch.7 | Mount virtual filesystems, enter chroot |
| `024-chroot-essentials.sh` | Ch.7 | Create /etc/passwd, /etc/group, etc. |
| `025-gettext.sh` `030-util-linux.sh` | Ch.7 | Native chroot tools |
| `031-cleanup.sh` | Ch.7 | Strip binaries, run exit criteria test |
| `build-all.sh` | Meta | Master build runner with logging |
## Version Manifest
See `VERSION_MANIFEST.md` for the exact version of every package used, with source URLs and rationale.
## Logs
Build logs are saved to `logs/<script-name>.log` by the master build runner.
## Troubleshooting
If a build fails:
1. Check the log file in `logs/`
2. The most common issue is a missing host dependency
3. The glibc sanity checks (script 004) are critical — if they fail, the entire toolchain is broken
4. GCC pass 1 is the longest build (~4 SBU on the 9950X3D with `-j32`)
## Repository
```
git@git.dannyhaslund.dk:danny8632/darkforge.git
```
Toolchain scripts live in the `toolchain/` directory of the main DarkForge repo.