2.5. adjust-toolchain

This pseudo-package does adjusting the toolchain without editing the filesystem directly.

It creates modificated spec files for gcc, which would be installed on top of the old ones. Their location is calculated through gcc --print-libgcc-file-name, as in original LFS. Here these files are located additionally inside D to create independent package.

The main additional trick here is reading the old unchrooted path to temporary tools from special file:

former_root="$(cat /var/lib/formerbase)"

That file was written in another pseudo-package basefiles. The path must be removed from specs as well.

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

Configuration

src_config()
{
    return
}

Compilation

src_compile()
{
    return
}

Installation

src_install()
{
    mkdir -p ${D}/${PASS1PREFIX}/bin/
    mkdir -p ${D}/${PASS1PREFIX}/$(uname -m)-pc-linux-gnu/bin/
    cp ${PASS1PREFIX}/bin/ld ${D}/${PASS1PREFIX}/bin/ld-old
    cp ${PASS1PREFIX}/bin/ld-new ${D}/${PASS1PREFIX}/bin/ld
    ln -s ${PASS1PREFIX}/bin/ld ${D}/${PASS1PREFIX}/$(uname -m)-pc-linux-gnu/bin/ld

    gcc_path="$(dirname $(gcc --print-libgcc-file-name) )"
    mkdir -p ${D}/${gcc_path}
    former_root="$(cat /var/lib/formerbase)"
    gcc -dumpspecs | sed \
        -e "s@${PASS1PREFIX}@@g" \
        -e "s@${former_root}@@g" \
        -e "/\*startfile_prefix_spec:/{n;s@.*@${PREFIX}/lib/ @}" \
        -e "/\*cpp:/{n;s@\$@ -isystem ${PREFIX}/include@}" >      \
        ${D}/${gcc_path}/specs
}

Build code

adjust-toolchain.build

Other files

meta.txt
text

Links

url.lfs: https://linuxfromscratch.org/lfs/view/9.1/chapter06/adjusting.html