Files
darkforge/toolchain/scripts/118-binutils.sh
2026-03-20 15:09:30 +01:00

59 lines
2.0 KiB
Bash

#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.21: Binutils (FINAL NATIVE)
# ============================================================================
# Purpose: Build the FINAL native binutils (assembler, linker, etc.)
# This replaces the cross-build binutils for the target system.
# Version 2.46.0 — matches Phase 0 toolchain bootstrap.
# Inputs: /sources/binutils-2.46.0.tar.xz
# Outputs: as, ld, ar, ranlib, objdump, nm, etc. in /usr/bin
# Ref: LFS 13.0 §8.21
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="binutils"
VERSION="2.46.0"
echo "=== Building FINAL NATIVE ${PACKAGE}-${VERSION} (Phase 3 — CRITICAL) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Verify that we're using Zen 5 flags from the environment
echo "Build flags: CFLAGS='${CFLAGS}' CXXFLAGS='${CXXFLAGS}' LDFLAGS='${LDFLAGS}'"
mkdir -v build
cd build
# Configure native binutils with full features for the target system
# --enable-gold: include the gold linker (faster, supports LTO)
# --enable-ld=default: use GNU ld as default (more compatible than gold for now)
# --enable-plugins: support linker plugins for LTO
# --disable-werror: don't fail on compiler warnings
# --with-system-zlib: use system zlib for compression
../configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--enable-gold \
--enable-ld=default \
--enable-plugins \
--disable-werror \
--with-system-zlib
make
make install
# Install LTO support
install -Dm644 ../include/plugin-api.h /usr/include/plugin-api.h
# Verify binutils installation
echo "Binutils version: $(ld --version | head -1)"
echo "as version: $(as --version | head -1)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== FINAL NATIVE ${PACKAGE}-${VERSION} complete ==="