1.2. pass1-gcc-11.2.0

#!/bin/sh
# Copyright © 1999-2022 Gerard Beekmans
# Copyright © 2017-2022 Random Crew
# Distributed under the terms of MIT License.


MY_P="${P#pass1-}"
MY_PD="${MY_P}"

Additional source handling

src_postfetch()
{
    tar xf ${ANYSRCDIR}/mpfr-4.1.0.tar.xz
    mv mpfr-4.1.0 mpfr
    tar xf ${ANYSRCDIR}/gmp-6.2.1.tar.xz
    mv gmp-6.2.1 gmp
    tar xf ${ANYSRCDIR}/mpc-1.2.1.tar.gz
    mv mpc-1.2.1 mpc
}

Configuration

The same version of gcc is used in several versions of LFS and is configured with different version of glibc API.

src_config()
{
    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

    case ${LFS_VERSION} in
        11.1)
            glibc_version='2.35'
        ;;
        11.0)
            glibc_version='2.11'
        ;;
        *)
            glibc_version='2.11'
        ;;
    esac

    ../configure                                       \
        --target=${LFS_TGT}                            \
        --prefix=${LFS}/${PASS1PREFIX}                 \
        --with-glibc-version=${glibc_version}          \
        --with-sysroot=${LFS}                          \
        --with-newlib                                  \
        --without-headers                              \
        --enable-initfini-array                        \
        --disable-nls                                  \
        --disable-shared                               \
        --disable-multilib                             \
        --disable-decimal-float                        \
        --disable-threads                              \
        --disable-libatomic                            \
        --disable-libgomp                              \
        --disable-libquadmath                          \
        --disable-libssp                               \
        --disable-libvtv                               \
        --disable-libstdcxx                            \
        --enable-languages=c,c++
}

Compilation

src_compile()
{
    make ${MAKEOPTS}
}

Installation

$LFS_TGT-gcc is called not from default path, but explicitly from $D/$PREFIX. At the moment $LFS_TGT-gcc is not installed into the filesystem, as installation goes into D first.

src_install()
{
    make install ${MAKEOPTS} DESTDIR=${D}

    cd ..
    cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
        `dirname $( ${D}/${LFS}/${PASS1PREFIX}/bin/${LFS_TGT}-gcc \
        -print-libgcc-file-name )`/install-tools/include/limits.h
}

Links

url.lfs:
url.lfs.stage1: https://linuxfromscratch.org/lfs/view/11.1/chapter05/gcc-pass1.html