Files
darkforge/toolchain/scripts/002-gcc-pass1.sh
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

97 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 0, Chapter 5: GCC Pass 1
# ============================================================================
# Purpose: Build the cross-compiler (GCC) as the second component of the
# cross-toolchain. This produces a C/C++ compiler that runs on the
# host but generates code for the target (x86_64-darkforge-linux-gnu).
# No hardware-specific flags (-march=znver5) yet — those come later
# when we have a native compiler.
# Inputs: ${LFS}/sources/gcc-15.2.0.tar.xz, mpfr, gmp, mpc tarballs
# Outputs: Cross-GCC installed to ${LFS}/tools/
# Assumes: Binutils Pass 1 complete, running as 'lfs' user
# Ref: LFS 13.0 §5.3
# ============================================================================
set -euo pipefail
source "${LFS}/sources/darkforge-env.sh"
PACKAGE="gcc"
VERSION="15.2.0"
SRCDIR="${LFS}/sources"
echo "=== Building ${PACKAGE}-${VERSION} (Cross-Toolchain Pass 1) ==="
cd "${SRCDIR}"
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Extract and link GCC's arithmetic library dependencies
tar -xf ../mpfr-4.2.2.tar.xz
mv -v mpfr-4.2.2 mpfr
tar -xf ../gmp-6.3.0.tar.xz
mv -v gmp-6.3.0 gmp
tar -xf ../mpc-1.3.1.tar.gz
mv -v mpc-1.3.1 mpc
# Fix lib64 directory naming on x86_64
# GCC defaults to installing 64-bit libraries in lib64, but LFS/DarkForge
# uses a unified /usr/lib directory. This sed changes the default.
case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
;;
esac
mkdir -v build
cd build
# Configure cross-compiler
# --target=$LFS_TGT: cross-compile for our target
# --with-glibc-version=2.43: tell GCC which glibc version to expect
# --with-newlib: inhibit building libc-dependent code (no libc yet)
# --without-headers: don't look for system headers yet
# --enable-default-pie: position-independent executables by default (security)
# --enable-default-ssp: stack smashing protection by default (security)
# --disable-shared: static link GCC internal libraries
# --disable-multilib: no 32-bit support in the cross-compiler
# (multilib will be addressed later for Steam/Wine compatibility)
# --disable-threads: no threading support yet (no glibc/pthreads)
# --disable-lib*: disable libraries that aren't needed at this stage
# --enable-languages=c,c++: only C and C++ compilers needed
../configure \
--target="${LFS_TGT}" \
--prefix="${LFS}/tools" \
--with-glibc-version=2.43 \
--with-sysroot="${LFS}" \
--with-newlib \
--without-headers \
--enable-default-pie \
--enable-default-ssp \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++
make
make install
# Create the full version of the internal limits.h header
# GCC needs this to properly handle system limits.h
cd ..
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
"$(dirname "$("${LFS_TGT}-gcc" -print-libgcc-file-name)")/include/limits.h"
# Cleanup
cd "${SRCDIR}"
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} Pass 1 complete ==="