
Linux From Scratch - Version 7.0
32
Chapter 5. Constructing a Temporary System
5.1. Introduction
This chapter shows how to build a minimal Linux system. This system will contain just enough tools to start
constructing the final LFS system in Chapter 6 and allow a working environment with more user convenience than
a minimum environment would.
There are two steps in building this minimal system. The first step is to build a new and host-independent toolchain
(compiler, assembler, linker, libraries, and a few useful utilities). The second step uses this toolchain to build the
other essential tools.
The files compiled in this chapter will be installed under the $LFS/tools directory to keep them separate from the
files installed in the next chapter and the host production directories. Since the packages compiled here are temporary,
we do not want them to pollute the soon-to-be LFS system.
5.2. Toolchain Technical Notes
This section explains some of the rationale and technical details behind the overall build method. It is not essential to
immediately understand everything in this section. Most of this information will be clearer after performing an actual
build. This section can be referred to at any time during the process.
The overall goal of Chapter 5 is to produce a temporary area that contains a known-good set of tools that can be
isolated from the host system. By using chroot, the commands in the remaining chapters will be contained within
that environment, ensuring a clean, trouble-free build of the target LFS system. The build process has been designed
to minimize the risks for new readers and to provide the most educational value at the same time.
Important
Before continuing, be aware of the name of the working platform, often referred to as the target triplet. A
simple way to determine the name of the target triplet is to run the config.guess script that comes with the
source for many packages. Unpack the Binutils sources and run the script: ./config.guess and note
the output. For example, for a modern 32-bit Intel processor the output will likely be i686-pc-linux-gnu.
Also be aware of the name of the platform's dynamic linker, often referred to as the dynamic loader (not to
be confused with the standard linker ld that is part of Binutils). The dynamic linker provided by Glibc finds
and loads the shared libraries needed by a program, prepares the program to run, and then runs it. The name
of the dynamic linker for a 32-bit Intel machine will be ld-linux.so.2. A sure-fire way to determine
the name of the dynamic linker is to inspect a random binary from the host system by running: readelf
-l <name of binary> | grep interpreter and noting the output. The authoritative reference
covering all platforms is in the shlib-versions file in the root of the Glibc source tree.
Some key technical points of how the Chapter 5 build method works:
• Slightly adjusting the name of the working platform, by changing the "vendor" field target triplet by way of
the LFS_TGT variable, ensures that the first build of Binutils and GCC produces a compatible cross-linker and
cross-compiler. Instead of producing binaries for another architecture, the cross-linker and cross-compiler will
produce binaries compatible with the current hardware.
Kommentare zu diesen Handbüchern