#!/bin/bash # ============================================================================ # DarkForge Linux — Phase 0, Chapter 5: Libstdc++ (from GCC) # ============================================================================ # Purpose: Build the C++ standard library (libstdc++) for the target. # This was deferred from GCC Pass 1 because it depends on glibc, # which wasn't available then. Now that glibc is installed in the # target sysroot, we can build libstdc++. # Inputs: ${LFS}/sources/gcc-15.2.0.tar.xz (same source as GCC Pass 1) # Outputs: libstdc++ in ${LFS}/usr/lib/ # Assumes: GCC Pass 1 + Glibc complete # Ref: LFS 13.0 §5.6 # ============================================================================ set -euo pipefail source "${LFS}/sources/darkforge-env.sh" PACKAGE="gcc" VERSION="15.2.0" SRCDIR="${LFS}/sources" echo "=== Building libstdc++ from ${PACKAGE}-${VERSION} ===" cd "${SRCDIR}" tar -xf "${PACKAGE}-${VERSION}.tar.xz" cd "${PACKAGE}-${VERSION}" mkdir -v build cd build # Configure only the libstdc++ component # --host=$LFS_TGT: cross-compile for our target # --disable-multilib: no 32-bit support at this stage # --disable-nls: no internationalization # --disable-libstdcxx-pch: skip precompiled headers (saves time/space) # --with-gxx-include-dir: point to the cross-compiler's include path ../libstdc++-v3/configure \ --host="${LFS_TGT}" \ --build="$(../config.guess)" \ --prefix=/usr \ --disable-multilib \ --disable-nls \ --disable-libstdcxx-pch \ --with-gxx-include-dir="/tools/${LFS_TGT}/include/c++/${VERSION}" make make DESTDIR="${LFS}" install # Remove libtool archive files — they cause problems with cross-compilation rm -v "${LFS}/usr/lib/lib"{stdc++{,exp,fs},supc++}.la 2>/dev/null || true # Cleanup cd "${SRCDIR}" rm -rf "${PACKAGE}-${VERSION}" echo "=== libstdc++ from ${PACKAGE}-${VERSION} complete ==="