1. LFS‎ > ‎

5. Toolchain

created : 2010-01-27   updated : 2010-01-27
 
Binutils-2.19.1 - Pass 1
 
Approximate build time: 1 SBU
Required disk space: 248 MB
 
Always login as lfs and go to the sources directory first :
 cd $LFS/sources
Extract the binutils source code :
time tar jxvf binutils-2.19.1.tar.bz2
time taken :
 
real 0m33.722s
user 0m8.237s
sys  0m6.956s
The Binutils documentation recommends building Binutils outside of the source directory in a dedicated build directory:
 

cd $LFS/sources/binutils-2.19.1

mkdir -v ../binutils-build
cd ../binutils-build
 
Start and time the building process :
 
time {
../binutils-2.19.1/configure \
--target=$LFS_TGT --prefix=/tools \
--disable-nls --disable-werror &&
make &&
make install;
}
 
Time taken :
 
real 8m55.429s
user 3m26.409s
sys  4m11.020s
 
 
The meaning of the configure options:
--target=$LFS_TGT
Because the machine description in the LFS_TGT variable is slightly different than the value returned by the config.guess script, this switch will tell the configure script to adjust Binutil's build system for building a cross linker.
--prefix=/tools
This tells the configure script to prepare to install the Binutils programs in the /tools directory.
--disable-nls
This disables internationalization as i18n is not needed for the temporary tools.
--disable-werror
This prevents the build from stopping in the event that there are warnings from the host's compiler.
 
GCC-4.4.1 - Pass 1
The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.
Approximate build time: 5.0 SBU
Required disk space: 809 MB
GCC now requires the GMP and MPFR packages. As these packages may not be included in your host distribution, they will be built with GCC:
 
cd $LFS/sources
time tar -jxvf gcc-4.4.1.tar.bz2
cd gcc-4.4.1
time tar -jxf ../mpfr-2.4.1.tar.bz2
mv -v mpfr-2.4.1 mpfr
time tar -jxf ../gmp-4.3.1.tar.bz2
mv -v gmp-4.3.1 gmp
 
Time taken :
tar -jxvf gcc-4.4.1.tar.bz2
real 2m28.647s
user 0m26.478s
sys  0m33.390s
all other tasks are neglectable .
  
The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:
 
mkdir -v ../gcc-build
cd ../gcc-build
 
Prepare GCC for compilation:
   .configure  (don't type it yet, see all in one below)
Compile :
   make (don't type it yet)
install :
   make install (don't type it yet)
 
All in one with timing :
 
time {
../gcc-4.4.1/configure \
--target=$LFS_TGT --prefix=/tools \
--disable-nls --disable-shared --disable-multilib \
--disable-decimal-float --disable-threads \
--disable-libmudflap --disable-libssp \
--disable-libgomp --enable-languages=c &&
make &&
make install;
}
 
time taken :
real 33m52.180s
user 16m26.710s
sys  13m15.502s
 
 
The meaning of the configure options:
--disable-shared
This switch forces GCC to link its internal libraries statically. We do this to avoid possible issues with the host system.
--disable-decimal-float, --disable-threads, --disable-libmudflap, --disablelibssp,--disable-libgomp
These switches disable support for the decimal floating point extension, threading, libmudflap, libssp and libgomp respectively. These features will fail to compile when building a cross-compiler and are not necessary for the task of cross-compiling the temporary libc.
--disable-multilib
On x86_64, LFS does not yet support a multilib configuration. This switch is harmless for x86.
--enable-languages=c
This option ensures that only the C compiler is built. This is the only language needed now.
 
Using --disable-shared means that the libgcc_eh.a file isn't created and installed. The Glibc package depends on this library as it uses -lgcc_eh within its build system. This dependency can be satisfied by creating a symlink to libgcc.a, since that file will end up containing the objects normally contained in libgcc_eh.a:
 
ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
sed 's/libgcc/&_eh/'` 
 
Linux-2.6.30.2 API Headers
The Linux API Headers expose the kernel's API for use by Glibc.
Approximate build time: 0.1 SBU
Required disk space: 403 MB
 
Extract the source :
 
cd $LFS/sources
time tar -jxvf linux-2.6.30.2.tar.bz2
 
Time taken :
real 2m8.103s
user 0m36.630s
sys  0m17.253s
 
 
Make sure there are no stale files and dependencies lying around from previous activity:
 
cd linux-2.6.30.2
make mrproper
 
Now test and extract the user-visible kernel headers from the source. They are placed in an intermediate local directory and copied to the needed location because the extraction process removes any existing files in the target directory.
 
make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include 
 
Altogether :
cd $LFS/sources/linux-2.6.30.2
time {
make mrproper &&
make headers_check &&
make INSTALL_HDR_PATH=dest headers_install &&
cp -rv dest/include/* /tools/include;
}
 
Time taken :
real 0m53.920s
user 0m12.561s
sys  0m27.502s
 
Glibc-2.10.1
The Glibc package contains the main C library. This library provides the basic routines for allocating memory, searching directories, opening and closing files, reading and writing files, string handling, pattern matching, arithmetic, and so on.
Approximate build time: 6.9 SBU
Required disk space: 371 MB
 
Extract source :
 
cd $LFS/sources
time tar -jxvf glibc-2.10.1.tar.bz2
cd glibc-2.10.1
 
Time taken :
real 0m28.972s
user 0m8.813s
sys  0m5.196s
 
 
Fix an error in the constants that get passed to the futex system call in some cases, causing certain pthread_mutex operations to fail:
 
cp -v nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S{,.orig}
sed -e 's/FUTEX_WAIT\( | FUTEX_CLOCK_REALTIME, reg\)/FUTEX_WAIT_BITSET\1/' \
<nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S.orig \
>nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
 
The Glibc documentation recommends building Glibc outside of the source directory in a dedicated build directory:
 
mkdir -v ../glibc-build
cd ../glibc-build
 
Because Glibc no longer supports i386, its developers say to use the compiler flag -march=i486 when building it for x86 machines. There are several ways to accomplish that, but testing shows that the flag is best placed inside the build variable “CFLAGS”. Instead of overriding completely what Glibc's internal build system uses for CFLAGS, append the new flag to the existing contents of CFLAGS by making use of the special file configparms. The -mtune=native flag is also necessary to reset a reasonable value for -mtune that is changed when setting -march.
 
case `uname -m` in
i?86) echo "CFLAGS += -march=i486 -mtune=native" > configparms ;;
esac
 
Configure and compile and install : 
time {
../glibc-2.10.1/configure --prefix=/tools \
--host=$LFS_TGT --build=$(../glibc-2.10.1/scripts/config.guess) \
--disable-profile --enable-add-ons \
--enable-kernel=2.6.18 --with-headers=/tools/include \
libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes &&
make &&
make install;
}
 
Time taken :
real 36m17.155s
user 17m32.154s
sys  12m7.389s
 
 
Adjusting the Toolchain
Now that the temporary C libraries have been installed, all tools compiled in the rest of this chapter should be linked against these libraries. In order to accomplish this, the cross-compiler's specs file needs to be adjusted to point to the new dynamic linker in /tools.
 
This is done by dumping the compiler's “specs” file to a location where it will look for it by default. A simple sed substitution then alters the dynamic linker that GCC will use. The principle here is to find all references to the dynamic linker file in /lib or possibly /lib64 if the host system is 64-bit capable, and adjust them to point to the new location in /tools.
For the sake of accuracy, it is recommended to use a copy-and-paste method when issuing the following command. Be sure to visually inspect the specs file to verify that it has properly adjusted all references to the dynamic linker location.
 
SPECS=`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/specs
$LFS_TGT-gcc -dumpspecs | sed \
-e 's@/lib\(64\)\?/ld@/tools&@g' \
-e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS
echo "New specs file is: $SPECS"
unset SPECS
 
Testing :
echo 'main(){}' > dummy.c
$LFS_TGT-gcc -B/tools/lib dummy.c
readelf -l a.out | grep ': /tools'
 
There should be no error. And the last output would be " [Requesting program interpreter: /tools/lib/ld-linux.so.2]"
Clean up :

 

rm -v dummy.c a.out
 
 
Binutils-2.19.1 - Pass 2
The Binutils package contains a linker, an assembler, and other tools for handling object files.
Approximate build time: 1.3 SBU
Required disk space: 259 MB
 
Clean up pass 1 file and get ready for pass 2.
 
cd $LFS/sources
rm -rf binutils-2.19.1
rm -rf binutils-build
tar jxvf binutils-2.19.1.tar.bz2
cd binutils-2.19.1
 
Create a separate build directory again:
 
mkdir -v ../binutils-build
cd ../binutils-build
 
Build :
time {
CC="$LFS_TGT-gcc -B/tools/lib/" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../binutils-2.19.1/configure --prefix=/tools \
--disable-nls --with-lib-path=/tools/lib &&
make &&
make install;
}
 
The meaning of the new configure options:
CC="$LFS_TGT-gcc -B/tools/lib/" AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib
Because this is really a native build of Binutils, setting these variables ensures that the build system uses the cross-compiler and associated tools instead of the ones on the host system.
--with-lib-path=/tools/lib
This tells the configure script to specify the library search path during the compilation of Binutils, resulting in /tools/lib being passed to the linker. This prevents the linker from searching through library directories on the host.
 
Time taken :
real 8m33.392s
user 3m8.660s
sys  4m6.891s
 
Now prepare the linker for the “Re-adjusting” phase in the next chapter:
 
time {
make -C ld clean &&
make -C ld LIB_PATH=/usr/lib:/lib &&
cp -v ld/ld-new /tools/bin ;
}
 
The meaning of the make parameters:
-C ld clean
This tells the make program to remove all compiled files in the ld subdirectory.
-C ld LIB_PATH=/usr/lib:/lib
This option rebuilds everything in the ld subdirectory. Specifying the LIB_PATH Makefile variable on the command line allows us to override the default value of the temporary tools and point it to the proper final path.
The value of this variable specifies the linker's default library search path.
Time taken :
real 0m18.222s
user 0m8.753s
sys  0m6.572s
 
GCC-4.4.1 - Pass 2
The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.
 
Approximate build time: 9.0 SBU
Required disk space: 1003 MB
 
Preparation :
cd $LFS/sources
rm -rf gcc-4.4.1
rm -rf gcc-build
tar -jxvf gcc-4.4.1.tar.bz2
cd gcc-4.4.1
 
Versions of GCC later than 4.3 will treat this build as if it were a relocated compiler and disallow searching for startfiles in the location specified by --prefix. Since this will not be a relocated compiler, and the startfiles in /tools are crucial to building a working compiler linked to the libs in /tools, apply the following patch which partially reverts GCC to its old behavior:
 
patch -Np1 -i ../gcc-4.4.1-startfiles_fix-1.patch
 
Under normal circumstances the GCC fixincludes script is run in order to fix potentially broken header files. As GCC-4.4.1 and Glibc-2.10.1 have already been installed at this point, and their respective header files are known to not require fixing, the fixincludes script is not required. In fact, running this script may actually pollute the build environment by installing fixed headers from the host system into GCC's private include directory. The running of the fixincludes script can be suppressed by issuing the following commands:
 
cp -v gcc/Makefile.in{,.orig}
sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in
 
For x86 machines, a bootstrap build of GCC uses the -fomit-frame-pointer compiler flag. Non-bootstrap builds omit this flag by default, and the goal should be to produce a compiler that is exactly the same as if it were bootstrapped. Apply the following sed command to force the build to use the flag:
 
cp -v gcc/Makefile.in{,.tmp}
sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \
> gcc/Makefile.in
 
The following command will change the location of GCC's default dynamic linker to use the one installed in /tools. It also removes /usr/include from GCC's include search path. Doing this now rather than adjusting the specs file after installation ensures that the new dynamic linker is used during the actual build of GCC. That is, all of the binaries created during the build will link against the new Glibc. Issue:
 
for file in \
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
cp -uv $file{,.orig}
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
-e 's@/usr@/tools@g' $file.orig > $file
echo '
#undef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR 0
#define STANDARD_STARTFILE_PREFIX_1 ""
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
touch $file.orig
done
 
On x86_64, unsetting the multilib spec for GCC ensures that it won't attempt to link against libraries on the host:
 
case $(uname -m) in
x86_64)
for file in $(find gcc/config -name t-linux64) ; do \
cp -v $file{,.orig}
sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file
done
;;
esac
 
As in the first build of GCC it requires the GMP and MPFR packages. Unpack the tarballs and move them into the required directory names:
 
tar -jxf ../mpfr-2.4.1.tar.bz2
mv -v mpfr-2.4.1 mpfr
tar -jxf ../gmp-4.3.1.tar.bz2
mv -v gmp-4.3.1 gmp
 
Create a separate build directory again:
 
mkdir -v ../gcc-build
cd ../gcc-build
 
Build :
time {
CC="$LFS_TGT-gcc -B/tools/lib/" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../gcc-4.4.1/configure --prefix=/tools \
--with-local-prefix=/tools --enable-clocale=gnu \
--enable-shared --enable-threads=posix \
--enable-__cxa_atexit --enable-languages=c,c++ \
--disable-libstdcxx-pch --disable-multilib \
--disable-bootstrap &&
make &&
make install;
}
 
The meaning of the new configure options:
--enable-clocale=gnu
This option ensures the correct locale model is selected for the C++ libraries under all circumstances. If the configure script finds the de_DE locale installed, it will select the correct gnu locale model. However, if the de_DE locale is not installed, there is the risk of building Application Binary Interface (ABI)-incompatible C++ libraries because the incorrect generic locale model may be selected.
--enable-threads=posix
This enables C++ exception handling for multi-threaded code.
--enable-__cxa_atexit
This option allows use of __cxa_atexit, rather than atexit, to register C++ destructors for local statics and global objects. This option is essential for fully standards-compliant handling of destructors. It also affects the C++ ABI, and therefore results in C++ shared libraries and C++ programs that are interoperable with other Linux distributions.
--enable-languages=c,c++
This option ensures that both the C and C++ compilers are built.
--disable-libstdcxx-pch
Do not build the pre-compiled header (PCH) for libstdc++. It takes up a lot of space, and we have no use for it.
--disable-bootstrap
For native builds of GCC, the default is to do a "bootstrap" build. This does not just compile GCC, but compiles it several times. It uses the programs compiled in a first round to compile itself a second time, and then again a third time. The second and third iterations are compared to make sure it can reproduce itself flawlessly. This also implies that it was compiled correctly. However, the LFS build method should provide a solid compiler without the need to bootstrap each time.
 
Time taken :
real 47m55.195s
user 23m8.379s
sys  18m16.957s
 
As a finishing touch, create a symlink. Many programs and scripts run cc instead of gcc, which is used to keep programs generic and therefore usable on all kinds of UNIX systems where the GNU C compiler is not always installed. Running cc leaves the system administrator free to decide which C compiler to install:
ln -vs gcc /tools/bin/cc
 
Testing again :
echo 'main(){}' > dummy.c
cc dummy.c
readelf -l a.out | grep ': /tools'
If everything is working correctly, there should be no errors, and the output of the last command will be of the form:
[Requesting program interpreter: /tools/lib/ld-linux.so.2]
 
clean up :
rm -v dummy.c a.out
 
Tcl-8.5.7
The Tcl package contains the Tool Command Language.

Approximate build time: 0.5 SBU
Required disk space: 32 MB
 
Unpack the source :
cd $LFS/sources
time tar -zxvf tcl8.5.7-src.tar.gz
cd tcl8.5.7
 
Build and install :
time {
cd unix &&
./configure --prefix=/tools &&
make &&
make install;
}
 
Time taken :
real 2m36.610s
user 1m16.257s
sys  1m2.940s
Make the installed library writable so debugging symbols can be removed later:
chmod -v u+w /tools/lib/libtcl8.5.so
Install Tcl's headers. The next package, Expect, requires them to build.
make install-private-headers

Now make a necessary symbolic link:
ln -sv tclsh8.5 /tools/bin/tclsh
 
Expect-5.43.0
The Expect package contains a program for carrying out scripted dialogues with other interactive programs.

Approximate build time: 0.1 SBU
Required disk space: 4.1 MB
 
Unpack source :
cd $LFS/sources
time tar -zxvf expect-5.43.0.tar.gz
cd expect-5.43
 
First, fix a bug that can result in false failures during the GCC test suite run:
patch -Np1 -i ../expect-5.43.0-spawn-1.patch

Next, fix a bug that is a result of recent Tcl changes:
patch -Np1 -i ../expect-5.43.0-tcl_8.5.5_fix-1.patch

Next, force Expect's configure script to use /bin/stty instead of a /usr/local/bin/stty it may find on the host system. This will ensure that our testsuite tools remain sane for the final builds of our toolchain:
cp -v configure{,.orig}
sed 's:/usr/local/bin:/bin:' configure.orig > configure
 
build and install :
 
time {
./configure --prefix=/tools --with-tcl=/tools/lib \
--with-tclinclude=/tools/include --with-x=no &&
make &&
make SCRIPTS="" install;
}
 
The meaning of the configure options:
--with-tcl=/tools/lib
This ensures that the configure script finds the Tcl installation in the temporary tools location instead of possibly locating an existing one on the host system.
--with-tclinclude=/tools/include
This explicitly tells Expect where to find Tcl's internal headers. Using this option avoids conditions where configure fails because it cannot automatically discover the location of Tcl's headers.
--with-x=no
This tells the configure script not to search for Tk (the Tcl GUI component) or the X Window System libraries, both of which may reside on the host system but will not exist in the temporary environment.
 
The meaning of the make parameter:
SCRIPTS=""
This prevents installation of the supplementary Expect scripts, which are not needed.
Time taken :
real 0m29.863s
user 0m9.829s
sys  0m13.525s
DejaGNU-1.4.4
The DejaGNU package contains a framework for testing other programs.

Approximate build time: less than 0.1 SBU
Required disk space: 6.1 MB
 
Unpack the source :
 
cd $LFS/sources
tar -zxvf dejagnu-1.4.4.tar.gz
cd dejagnu-1.4.4
 
Build and install :
 
time {
./configure --prefix=/tools &&
make install;
}
 
Time taken:
real 0m28.028s
user 0m5.880s
sys  0m14.677s
 
 
Ncurses-5.7
The Ncurses package contains libraries for terminal-independent handling of character screens.
Approximate build time: 0.7 SBU
Required disk space: 30 MB
 
Unpack the source :
 
cd $LFS/sources
tar -zxvf ncurses-5.7.tar.gz
cd ncurses-5.7
 
Build and install :
 
time {
./configure --prefix=/tools --with-shared \
--without-debug --without-ada --enable-overwrite &&
make &&
make install ;
}
 
The meaning of the configure options:
--without-ada
This ensures that Ncurses does not build support for the Ada compiler which may be present on the host but will not be available once we enter the chroot environment.
--enable-overwrite
This tells Ncurses to install its header files into /tools/include, instead of /tools/include/ ncurses, to ensure that other packages can find the Ncurses headers successfully.
Time taken :
real 4m55.040s
user 1m58.375s
sys  1m45.035s
Bash-4.0
The Bash package contains the Bourne-Again SHell.

Approximate build time: 0.5 SBU
Required disk space: 35 MB
Unpack source and go to source folder :
 
cd $LFS/sources
time tar -zxvf bash-4.0.tar.gz
cd bash-4.0
 
Apply fixes for several bugs discovered since the initial release of Bash-4.0:
patch -Np1 -i ../bash-4.0-fixes-3.patch

Build :
 
time {
./configure --prefix=/tools --without-bash-malloc &&
make &&
make install ;
}
 
The meaning of the configure options:
--without-bash-malloc
This option turns off the use of Bash's memory allocation (malloc) function which is known to cause segmentation faults. By turning this option off, Bash will use the malloc functions from Glibc which are more stable.
Time taken :
real    5m27.423s
user    1m26.257s
sys     1m29.794s

Make a link for the programs that use sh for a shell:
ln -vs bash /tools/bin/sh

 
Bzip2-1.0.5
The Bzip2 package contains programs for compressing and decompressing files. Compressing text files with bzip2 yields a much better compression percentage than with the traditional gzip.

Approximate build time: less than 0.1 SBU
Required disk space: 4.8 MB
 
Unpack source :
 
cd $LFS/sources
tar -zxvf bzip2-1.0.5.tar.gz
cd bzip2-1.0.5
 
Build and install :
 
time {
make &&
make PREFIX=/tools install ;
}
 
time taken :
real    0m13.573s
user    0m6.176s
sys     0m2.140s
Coreutils-7.4
The Coreutils package contains utilities for showing and setting the basic system characteristics.

Approximate build time: 0.7 SBU
Required disk space: 88 MB
 
Unpack source :
 
cd $LFS/sources
tar -zxvf coreutils-7.4.tar.gz
cd coreutils-7.4

 
 
Build and install :
 
time {
./configure --prefix=/tools --enable-install-program=hostname &&
make &&
make install ;
}
 
The meaning of the configure options:

--enable-install-program=hostname

This enables the hostname binary to be built and installed – it is disabled by default but is required by the Perl test suite.

Time taken :
real    8m23.233s
user    2m13.936s
sys     2m18.037s
The above command refuses to install su because the program cannot be installed setuid root as a non-privileged user. By manually installing it with a different name, we can use it for running tests in the final system as a nonprivileged user and we keep a possibly useful su from our host first in our PATH. Install it with:
cp -v src/su /tools/bin/su-tools
 
 
Diffutils-2.8.1
The Diffutils package contains programs that show the differences between files or directories.

Approximate build time: 0.1 SBU
Required disk space: 6.1 MB
Unpack source :
 
cd $LFS/sources
tar -zxvf diffutils-2.8.1.tar.gz
cd diffutils-2.8.1
 
Build and install :
 
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    1m49.335s
user    0m23.457s
sys     0m33.490s
 
Findutils-4.4.2
The Findutils package contains programs to find files. These programs are provided to recursively search through a directory tree and to create, maintain, and search a database (often faster than the recursive find, but unreliable if the database has not been recently updated).

Approximate build time: 0.3 SBU
Required disk space: 20 MB

Unpack source :
 
cd $LFS/sources
tar -zxvf findutils-4.4.2.tar.gz
cd findutils-4.4.2

Prepare Findutils for compilation:
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
 
Time taken :
real    3m55.280s
user    0m52.707s
sys     1m14.973s
 
Gawk-3.1.7
The Gawk package contains programs for manipulating text files.

Approximate build time: 0.2 SBU
Required disk space: 19 MB
Unpack source :
 
cd $LFS/sources
tar jxvf gawk-3.1.7.tar.bz2
cd gawk-3.1.7
 
 
Build and install :
 
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    3m36.583s
user    0m50.047s
sys     1m8.484s
 
 
Gettext-0.17
The Gettext package contains utilities for internationalization and localization. These allow programs to be compiled with NLS (Native Language Support), enabling them to output messages in the user's native language.
Approximate build time: 0.8 SBU
Required disk space: 82 MB
 
Unpack source :
 
cd $LFS/sources
tar -zxvf gettext-0.17.tar.gz
cd gettext-0.17


For our temporary set of tools, we only need to build and install one binary from Gettext.
Build and install:
time {
cd gettext-tools &&
./configure --prefix=/tools --disable-shared &&
make -C gnulib-lib &&
make -C src msgfmt &&
cp -v src/msgfmt /tools/bin ;
}
 
The meaning of the configure option:
--disable-shared
We do not need to install any of the shared Gettext libraries at this time, therefore there is no need to build them.
Time taken :
real    12m9.558s
user    2m42.346s
sys     4m10.368s
 
Grep-2.5.4
The Grep package contains programs for searching through files.

Approximate build time: 0.1 SBU
Required disk space: 6.7 MB
Unpack source :
 
cd $LFS/sources
tar -jxvf grep-2.5.4.tar.bz2
cd grep-2.5.4

Build and install :
time {
./configure --prefix=/tools \
--disable-perl-regexp \
--without-included-regex &&
make &&
make install ;
}
 
The meaning of the configure switches:
--disable-perl-regexp
This ensures that the grep program does not get linked against a Perl Compatible Regular Expression (PCRE) library that may be present on the host but will not be available once we enter the chroot environment.
--without-included-regex
The configure check for Glibc's regex library is broken when building against Glibc-2.10.1. This switch forces the use of Glibc's regex library.
 
Time taken :
real    1m37.361s
user    0m19.689s
sys     0m32.750s
 
 
Gzip-1.3.12
The Gzip package contains programs for compressing and decompressing files.

Approximate build time: less than 0.1 SBU
Required disk space: 3.3 MB

Unpack source :
 
cd $LFS/sources
tar -zxvf gzip-1.3.12.tar.gz
cd gzip-1.3.12

 
 
The version of the function “futimens” used by Gzip is incompatible with the version that current Glibc provides, so we'll rename the function:
for file in gzip.c lib/utimens.{c,h} ; do \
cp -v $file{,.orig}
sed 's/futimens/gl_&/' $file.orig > $file
done

Build and install :
 
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    1m7.773s
user    0m13.281s
sys     0m22.437s
 
M4-1.4.13
The M4 package contains a macro processor.
 
Approximate build time: 0.2 SBU
Required disk space: 11.6 MB
 
Unpack source :
cd $LFS/sources
tar -jxvf m4-1.4.13.tar.bz2
cd m4-1.4.13

Build and install :
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    2m40.375s
user    0m36.534s
sys     0m48.079s
 
Make-3.81
The Make package contains a program for compiling packages.
 
Approximate build time: 0.1 SBU
Required disk space: 9.6 MB
 
Unpack source :
cd $LFS/sources
tar -jxvf make-3.81.tar.bz2
cd make-3.81
 
Build and install :
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    1m45.469s
user    0m23.557s
sys     0m34.106s
 
Patch-2.5.9
The Patch package contains a program for modifying or creating files by applying a “patch” file typically created by the diff program.
 
Approximate build time: less than 0.1 SBU
Required disk space: 1.9 MB
 
Unpack source :
cd $LFS/sources
tar -zxvf patch-2.5.9.tar.gz
cd patch-2.5.9
 
Apply a patch that fixes a bug whereby patch fails to apply patches whose lines contain trailing carriage return characters:
patch -Np1 -i ../patch-2.5.9-fixes-1.patch
 
Build and install :
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    1m8.924s
user    0m15.617s
sys     0m21.777s
 
 
Perl-5.10.0
The Perl package contains the Practical Extraction and Report Language.
 
Approximate build time: 0.8 SBU
Required disk space: 106 MB
 
Unpack source :
cd $LFS/sources
tar -zxvf perl-5.10.0.tar.gz
cd perl-5.10.0
 
First apply the following patch to address security issues and adapt some hard-wired paths to the C library:
patch -Np1 -i ../perl-5.10.0-consolidated-1.patch
 
Build and install :
time {
sh Configure -des -Dprefix=/tools \
-Dstatic_ext='Data/Dumper Fcntl IO POSIX' &&
make perl utilities ext/Errno/pm_to_blib &&
cp -v perl pod/pod2man /tools/bin &&
mkdir -pv /tools/lib/perl5/5.10.0 &&
cp -Rv lib/* /tools/lib/perl5/5.10.0 ;
}
 
The meaning of the configure options:
-Dstatic_ext='Data/Dumper Fcntl IO POSIX'
This tells Perl to build the minimum set of static extensions needed for installing and testing the Coreutils and Glibc packages.
 
Time taken :
real    6m36.005s
user    2m14.280s
sys     1m31.374s
 
Note :
http://cpan.org/src/perl-5.10.0.tar.gz was not available.
I have to get it from the other LFS mirror :
wget ftp://ftp.lfs-matrix.net/pub/lfs/lfs-packages/6.4/perl-5.10.0.tar.gz
 
 
 
Sed-4.2.1
The Sed package contains a stream editor.
 
Approximate build time: 0.1 SBU
Required disk space: 8.0 MB
 
Unpack source :
cd $LFS/sources
tar -jxvf sed-4.2.1.tar.bz2
cd sed-4.2.1
 
Build and install :
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    2m4.360s
user    0m25.134s
sys     0m40.003s
 
Tar-1.22
The Tar package contains an archiving program.
 
Approximate build time: 0.3 SBU
Required disk space: 20.9 MB
 
Unpack source :
cd $LFS/source
tar jxvf tar-1.22.tar.bz2
cd tar-1.22
 
Build and install:
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    4m25.238s
user    0m58.460s
sys     1m17.833s
 
Texinfo-4.13a
The Texinfo package contains programs for reading, writing, and converting info pages.
 
Approximate build time: 0.2 SBU
Required disk space: 20 MB
 
Unpack source :
cd $LFS/source
tar -zxvf texinfo-4.13a.tar.gz
cd texinfo-4.13

Build and install :
time {
./configure --prefix=/tools &&
make &&
make install ;
}
 
Time taken :
real    2m48.233s
user    0m44.947s
sys     0m45.995s
 
Changing Ownership

Note :
The commands in the remainder of this book must be performed while logged in as user root and no longer as user lfs. Also, double check that $LFS is set in root's environment.
 
Checking $LFS: (login as root)
echo $LFS
 
Setting $LFS:
export LFS=/mnt/lfs

Currently, the $LFS/tools directory is owned by the user lfs, a user that exists only on the host system. If the $LFS/tools directory is kept as is, the files are owned by a user ID without a corresponding account. This is dangerous because a user account created later could get this same user ID and would own the $LFS/tools directory and all the files therein, thus exposing these files to possible malicious manipulation.

To avoid this issue,  change the ownership of the $LFS/tools directory to user root by running the following command:
chown -R root:root $LFS/tools
 
backup tools : (useful for building other LFS packages later)
cd $LFS
tar -cjvf tools.tar.bz2 tools
 
 
Comments