Setting Up the Build Environment
Setting Up the Build Environment
A successful build requires a dedicated workspace directory on your host workstation, sanitized environment variables, and essential host build utilities.
Step 1: Workspace Directory Structure
Create a dedicated directory with adequate free storage (at least 30 GB):
$ export BYOL_ROOT="$HOME/byol-workspace"
$ mkdir -p "$BYOL_ROOT"/{sources,tools,sysroot,build,iso-staging}
$ cd "$BYOL_ROOT"Directory roles: - sources/: Pristine downloaded tarballs and patches. - tools/: The host-resident cross-compiler toolchain (x86_64-byol-linux-musl-gcc). - sysroot/: The target operating system root filesystem tree. - build/: Temporary scratch directories where packages are compiled. - iso-staging/: The layout used by xorriso to generate the final bootable ISO.
Step 2: Defining Target Triples & Environment Variables
Create an environment configuration file: env.sh:
# $BYOL_ROOT/env.sh
export BYOL_ROOT="$HOME/byol-workspace"
export ARCH="x86_64"
export TARGET="${ARCH}-byol-linux-musl"
export TOOLS="$BYOL_ROOT/tools"
export SYSROOT="$BYOL_ROOT/sysroot"
# Ensure our custom cross-compiler takes precedence over host tools
export PATH="$TOOLS/bin:$PATH"
# Sanitize compiler and linker environment
unset CFLAGS CXXFLAGS LDFLAGS
export LC_ALL=POSIX
# Parallel build speed
export MAKEFLAGS="-j$(nproc)"Source this file in every build terminal session:
$ source "$BYOL_ROOT/env.sh"Step 3: Downloading Source Archives
Download verified tarballs into $BYOL_ROOT/sources:
$ cd "$BYOL_ROOT/sources"
# 1. Linux Kernel
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.10.2.tar.xz
# 2. Binutils & GCC
wget https://ftp.gnu.org/gnu/binutils/binutils-2.42.tar.xz
wget https://ftp.gnu.org/gnu/gcc/gcc-14.1.0/gcc-14.1.0.tar.xz
wget https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz
wget https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz
wget https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz
# 3. musl C library
wget https://musl.libc.org/releases/musl-1.2.5.tar.gz
# 4. BusyBox
wget https://busybox.net/downloads/busybox-1.36.1.tar.bz2Verify SHA256 checksums before proceeding to ensure archive integrity.