From efcb3933433838b71f3a4a53ec1ac6d899aaec0b Mon Sep 17 00:00:00 2001 From: Pierre Labastie Date: Sun, 3 May 2020 21:02:51 +0000 Subject: Make the new book git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/cross-chap5@11831 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter01/how.xml | 37 ++-- chapter02/stages.xml | 22 +- chapter04/abouttestsuites.xml | 12 +- chapter04/addinguser.xml | 4 +- chapter04/chapter04.xml | 2 +- chapter04/creatingminlayout.xml | 32 +++ chapter04/introduction.xml | 2 +- chapter04/settingenviron.xml | 8 +- chapter05/bash.xml | 23 +- chapter05/binutils-pass1.xml | 32 +-- chapter05/binutils-pass2.xml | 86 +------- chapter05/bison.xml | 24 +- chapter05/bzip2.xml | 35 ++- chapter05/changingowner.xml | 30 +-- chapter05/chapter05.xml | 25 ++- chapter05/chroot.xml | 65 ++++++ chapter05/coreutils.xml | 32 +-- chapter05/createfiles.xml | 196 +++++++++++++++++ chapter05/creatingdirs.xml | 59 +++++ chapter05/dejagnu.xml | 9 +- chapter05/diffutils.xml | 10 +- chapter05/expect.xml | 56 ++--- chapter05/file.xml | 23 +- chapter05/findutils.xml | 21 +- chapter05/flex.xml | 30 ++- chapter05/gawk.xml | 16 +- chapter05/gcc-pass1.xml | 120 ++-------- chapter05/gcc-pass2.xml | 151 ++++--------- chapter05/generalinstructions.xml | 4 +- chapter05/gettext.xml | 17 +- chapter05/glibc.xml | 109 ++++++---- chapter05/grep.xml | 12 +- chapter05/gzip.xml | 12 +- chapter05/introduction.xml | 6 +- chapter05/kernfs.xml | 115 ++++++++++ chapter05/libstdc++-pass2.xml | 114 ++++++++++ chapter05/libstdc++.xml | 31 +-- chapter05/linux-headers.xml | 148 ++++++++++++- chapter05/m4.xml | 13 +- chapter05/make.xml | 29 +-- chapter05/ncurses.xml | 77 ++++--- chapter05/patch.xml | 12 +- chapter05/perl.xml | 30 +-- chapter05/python.xml | 23 +- chapter05/sed.xml | 12 +- chapter05/stripping.xml | 17 +- chapter05/tar.xml | 13 +- chapter05/tcl.xml | 66 ++++-- chapter05/texinfo.xml | 16 +- chapter05/toolchaintechnotes.xml | 445 ++++++++++++++++++++++++++------------ chapter05/util-linux.xml | 71 +++--- chapter05/xz.xml | 23 +- chapter06/acl.xml | 3 +- chapter06/attr.xml | 6 +- chapter06/bc.xml | 60 +---- chapter06/bzip2.xml | 5 +- chapter06/chapter06.xml | 8 +- chapter06/check.xml | 6 +- chapter06/chroot.xml | 63 ------ chapter06/coreutils.xml | 3 +- chapter06/createfiles.xml | 365 ------------------------------- chapter06/creatingdirs.xml | 65 ------ chapter06/e2fsprogs.xml | 22 +- chapter06/flex.xml | 2 +- chapter06/gcc.xml | 27 +-- chapter06/glibc.xml | 42 ++-- chapter06/introduction.xml | 9 - chapter06/kbd.xml | 23 +- chapter06/kernfs.xml | 115 ---------- chapter06/libpipeline.xml | 16 -- chapter06/linux-headers.xml | 209 ------------------ chapter06/readline.xml | 6 +- chapter06/revisedchroot.xml | 15 +- chapter06/sed.xml | 14 +- chapter06/shadow.xml | 3 +- chapter06/strippingagain.xml | 34 +-- chapter06/systemd.xml | 6 +- chapter06/util-linux.xml | 12 - chapter08/kernel.xml | 2 +- 79 files changed, 1675 insertions(+), 2043 deletions(-) create mode 100644 chapter04/creatingminlayout.xml create mode 100644 chapter05/chroot.xml create mode 100644 chapter05/createfiles.xml create mode 100644 chapter05/creatingdirs.xml create mode 100644 chapter05/kernfs.xml create mode 100644 chapter05/libstdc++-pass2.xml delete mode 100644 chapter06/chroot.xml delete mode 100644 chapter06/createfiles.xml delete mode 100644 chapter06/creatingdirs.xml delete mode 100644 chapter06/kernfs.xml delete mode 100644 chapter06/linux-headers.xml diff --git a/chapter01/how.xml b/chapter01/how.xml index 3a8942dba..4d283d0c9 100644 --- a/chapter01/how.xml +++ b/chapter01/how.xml @@ -46,12 +46,10 @@ important issues you need be aware of before beginning to work your way through and beyond. - explains the - installation of a number of packages that will form the basic - development suite (or toolchain) which is used to build the actual - system in . Some of these - packages are needed to resolve circular dependencies—for example, - to compile a compiler, you need a compiler. + explains the installation of + a number of packages that are needed to resolve circular + dependencies—for example, to compile a compiler, you need a compiler. + or to unpack the tar package, you need tar. also shows you how to build a first pass of the toolchain, including Binutils and GCC (first pass @@ -66,20 +64,21 @@ kernel. This effort to isolate the new system from the host distribution may - seem excessive. A full technical explanation as to why this is done is provided in - . + seem excessive. A full technical explanation as to why this is done is + provided in . - In , the full LFS system is - built. The chroot (change root) program is used to enter - a virtual environment and start a new shell whose root directory will be - set to the LFS partition. This is very similar to rebooting and instructing - the kernel to mount the LFS partition as the root partition. The system - does not actually reboot, but instead uses chroot because - creating a bootable system requires additional work which is not necessary - just yet. The major advantage is that chrooting allows you - to continue using the host system while LFS is being built. While waiting - for package compilations to complete, you can continue using your computer as - normal. + begins with installing the + remaining packages needed to build and test the final toolchain. Then, the + full LFS system is built. But first, the chroot (change + root) program is used to enter a virtual environment and start a new shell + whose root directory will be set to the LFS partition. This is very similar + to rebooting and instructing the kernel to mount the LFS partition as the + root partition. The system does not actually reboot, but instead uses + chroot because creating a bootable system requires + additional work which is not necessary just yet. The major advantage is + that chrooting allows you to continue using the host system + while LFS is being built. While waiting for package compilations to + complete, you can continue using your computer as normal. To finish the installation, the basic system configuration is set up in , and the kernel and boot loader are set diff --git a/chapter02/stages.xml b/chapter02/stages.xml index 30e820213..6ca265991 100644 --- a/chapter02/stages.xml +++ b/chapter02/stages.xml @@ -25,9 +25,9 @@ - Procedures done as the root user after Section 2.4 need to - have the LFS environment variable set FOR THE ROOT - USER. + Procedures done as the root user after Section 2.4 need to + have the LFS environment variable set FOR THE ROOT + USER. @@ -37,14 +37,20 @@ - The /mnt/lfs partition must be mounted. + The /mnt/lfs partition must be mounted. - ALL instructions in Chapter 5 - must be done by user lfs. - A su - lfs needs to be done before any - task in Chapter 5. + This chapter includes three parts. The first one, from + Binutils Pass1 to Stripping + must be done by user lfs. A + su - lfs needs to be done before any task in this + part. The second part, from Changing Ownership to + Entering the Chroot Environment must be done as the + root user, with LFS set for the root user. The third part, from + Creating Directories to the end of the chapter, is done + in the chroot environment. The same procedures as for chapter 6 + apply. diff --git a/chapter04/abouttestsuites.xml b/chapter04/abouttestsuites.xml index 1b2e0d68f..780216181 100644 --- a/chapter04/abouttestsuites.xml +++ b/chapter04/abouttestsuites.xml @@ -25,15 +25,9 @@ are strongly recommended. - Experience has shown that there is little to be gained from running - the test suites in . There can be - no escaping the fact that the host system always exerts some influence on - the tests in that chapter, often causing inexplicable failures. Because - the tools built in are temporary - and eventually discarded, we do not recommend running the test suites in - for the average reader. The - instructions for running those test suites are provided for the benefit of - testers and developers, but they are strictly optional. + Running the test suites in + is impossible, since the programs are compiled with a cross-compiler, + so are not supposed to be able to run on the build host. A common issue with running the test suites for Binutils and GCC diff --git a/chapter04/addinguser.xml b/chapter04/addinguser.xml index a26aa55a2..24cdb3aab 100644 --- a/chapter04/addinguser.xml +++ b/chapter04/addinguser.xml @@ -77,10 +77,10 @@ useradd -s /bin/bash -g lfs -m -k /dev/null lfs passwd lfs Grant lfs full access to - $LFS/tools by making + all directories under $LFS by making lfs the directory owner: -chown -v lfs $LFS/tools +chown -v lfs $LFS/{usr,lib,var,etc,bin,sbin,lib64,tools} If a separate working directory was created as suggested, give user lfs ownership of this diff --git a/chapter04/chapter04.xml b/chapter04/chapter04.xml index 3e44ce94f..5ad2d22db 100644 --- a/chapter04/chapter04.xml +++ b/chapter04/chapter04.xml @@ -13,7 +13,7 @@ - + diff --git a/chapter04/creatingminlayout.xml b/chapter04/creatingminlayout.xml new file mode 100644 index 000000000..44cca8d22 --- /dev/null +++ b/chapter04/creatingminlayout.xml @@ -0,0 +1,32 @@ + + + %general-entities; +]> + + + + + Creating the Minimal directory layout in LFS filesystem + + The first task performed in the LFS partition is to create a minimal + directory hierarchy so that programs compiled in may be installed in their final + location. This is needed so that those temporary programs be overwritten + when rebuilding them in . + + Create the required directory layout by running the following as + root: + +mkdir -pv $LFS/{usr,lib,var,etc,bin,sbin,lib64} + + Programs in will be compiled + with a cross-compiler (more details in section ). In order to separate this + cross-compiler from the other programs, it will be installed in a special + directory. Create this directory with: + +mkdir -pv $LFS/tools + + diff --git a/chapter04/introduction.xml b/chapter04/introduction.xml index f1ac91989..c54c67f8c 100644 --- a/chapter04/introduction.xml +++ b/chapter04/introduction.xml @@ -11,7 +11,7 @@ Introduction In this chapter, we will perform a few additional tasks to prepare - for building the temporary system. We will create a directory in + for building the temporary system. We will create a set of directories in $LFS for the installation of the temporary tools, add an unprivileged user to reduce risk, and create an appropriate build environment for that user. We will also diff --git a/chapter04/settingenviron.xml b/chapter04/settingenviron.xml index 512d30d10..86d10bf05 100644 --- a/chapter04/settingenviron.xml +++ b/chapter04/settingenviron.xml @@ -43,7 +43,7 @@ umask 022 LFS=/mnt/lfs LC_ALL=POSIX LFS_TGT=$(uname -m)-lfs-linux-gnu -PATH=/tools/bin:/bin:/usr/bin +PATH=$LFS/tools/bin:/bin:/usr/bin export LFS LC_ALL LFS_TGT PATH EOF @@ -61,7 +61,7 @@ EOF be used as soon as they are installed. By switching off the hash function, the shell will always search the PATH when a program is to be run. As such, the shell will find the newly compiled tools in - $LFS/tools as soon as they are + ~/tools as soon as they are available without remembering a previous version of the same program in a different location. @@ -108,9 +108,9 @@ EOF - PATH=/tools/bin:/bin:/usr/bin + PATH=$LFS/tools/bin:/bin:/usr/bin - By putting /tools/bin ahead of the + By putting $LFS/tools/bin ahead of the standard PATH, all the programs installed in are picked up by the shell immediately after their installation. This, combined with turning off hashing, limits the risk diff --git a/chapter05/bash.xml b/chapter05/bash.xml index 21df197e7..ee1fb574e 100644 --- a/chapter05/bash.xml +++ b/chapter05/bash.xml @@ -42,15 +42,13 @@ Installation of Bash - Prepare Bash for compilation: -./configure --prefix=/tools --without-bash-malloc +./configure --prefix=/usr \ + --build=$(support/config.guess) \ + --host=$LFS_TGT \ + --without-bash-malloc The meaning of the configure options: @@ -72,21 +70,18 @@ make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Bash test suite anyway, issue the following command: - + Install the package: -make tests +make DESTDIR=$LFS install - Install the package: + Move the excutable to where it is expected to be: -make install +mv $LFS/usr/bin/bash $LFS/bin/bash Make a link for the programs that use sh for a shell: -ln -sv bash /tools/bin/sh +ln -sv bash $LFS/bin/sh diff --git a/chapter05/binutils-pass1.xml b/chapter05/binutils-pass1.xml index b54941a23..8658cfcfe 100644 --- a/chapter05/binutils-pass1.xml +++ b/chapter05/binutils-pass1.xml @@ -66,15 +66,14 @@ cd build command like this: time { ./configure ... && ... && make install; }. - + Now prepare Binutils for compilation: -../configure --prefix=/tools \ +../configure --prefix=$LFS/tools \ --with-sysroot=$LFS \ - --with-lib-path=/tools/lib \ --target=$LFS_TGT \ --disable-nls \ --disable-werror @@ -83,11 +82,11 @@ cd build The meaning of the configure options: - --prefix=/tools + --prefix=$LFS/tools This tells the configure script to prepare to install the - Binutils programs in the /tools - directory. + Binutils programs in the $LFS/tools directory. @@ -98,15 +97,15 @@ cd build $LFS for the target system libraries as needed. - + --target=$LFS_TGT @@ -140,19 +139,6 @@ cd build make - Compilation is now complete. Ordinarily we would now run the - test suite, but at this early stage the test suite framework (Tcl, - Expect, and DejaGNU) is not yet in place. The benefits of running the - tests at this point are minimal since the programs from this - first pass will soon be replaced by those from the second. - - If building on x86_64, create a symlink to ensure the sanity of - the toolchain: - -case $(uname -m) in - x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;; -esac - Install the package: make install diff --git a/chapter05/binutils-pass2.xml b/chapter05/binutils-pass2.xml index 4e3dcb9f6..5d0fd7e6d 100644 --- a/chapter05/binutils-pass2.xml +++ b/chapter05/binutils-pass2.xml @@ -50,52 +50,24 @@ cd build Prepare Binutils for compilation: -CC=$LFS_TGT-gcc \ -AR=$LFS_TGT-ar \ -RANLIB=$LFS_TGT-ranlib \ -../configure \ - --prefix=/tools \ +../configure \ + --prefix=/usr \ + --build=$(../config.guess) \ + --host=$LFS_TGT \ --disable-nls \ - --disable-werror \ - --with-lib-path=/tools/lib \ - --with-sysroot + --enable-shared \ + --disable-werror The meaning of the new configure options: - CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib + --host=$LFS_TGT - 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. - - - - - --with-sysroot - - This defines a default (non-existent) sysroot directory - /tools/$LFS_TGT/sys-root. - It is useful when looking for shared objects which are required by - other shared objects explicitly included on the linker's command - line. Those objects are searched into the directories listed in - <sysroot>/etc/ld.so.conf, and failing - that, into the linker search path, which is right. If this switch - is not given, /etc/ld.so.conf on the host - is used, that is, programs may be linked to libraries on - the host, which we want to avoid. + This tells the configure script that we want to build + this pass of binutils for the $LFS_TGT machine, using our just + built cross-compiler. This prevents the linker from searching + through library directories on the host. @@ -107,41 +79,7 @@ RANLIB=$LFS_TGT-ranlib \ Install the package: -make install - - Now prepare the linker for the Re-adjusting phase in - the next chapter: - -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. This - preparation is used in the next chapter. - - - - +make DESTDIR=$LFS install diff --git a/chapter05/bison.xml b/chapter05/bison.xml index 98c8cdc35..e6ed2a7f8 100644 --- a/chapter05/bison.xml +++ b/chapter05/bison.xml @@ -45,19 +45,31 @@ Prepare Bison for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --build=$(build-aux/config.guess) \ + --host=$LFS_TGT \ + --docdir=/usr/share/doc/bison-&bison-version; - Compile the package: + + The meaning of the new configure option: -make + + --docdir=/usr/share/doc/bison-&bison-version; + + This tells the build system to install bison documentation + into a versioned directory. + + - To test the results, issue: + -make check + Compile the package: + +make Install the package: -make install +make DESTDIR=$LFS install diff --git a/chapter05/bzip2.xml b/chapter05/bzip2.xml index 4f1e3aab9..828b7fc0f 100644 --- a/chapter05/bzip2.xml +++ b/chapter05/bzip2.xml @@ -43,12 +43,26 @@ Installation of Bzip2 + Apply a patch that will install the documentation for this + package: + +patch -Np1 -i ../&bzip2-docs-patch; + + The following command ensures installation of symbolic links are + relative: + +sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile + + Ensure the man pages are installed into the correct location: + +sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile + The Bzip2 package does not contain a configure script. There are two Makefile, one for the shared library, and the other for the static library. Since we need both, We do the compilation in two stages. First the shared library: -make -f Makefile-libbz2_so +make CC=$LFS_TGT-gcc -f Makefile-libbz2_so make clean @@ -69,20 +83,27 @@ make clean Compile and test the package with: -make +make CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib Install the package: -make PREFIX=/tools install -cp -v bzip2-shared /tools/bin/bzip2 -cp -av libbz2.so* /tools/lib -ln -sv libbz2.so.1.0 /tools/lib/libbz2.so +make PREFIX=$LFS/usr install + + Install the shared bzip2 binary into the + /bin directory, make some necessary + symbolic links, and clean up: + +cp -v bzip2-shared $LFS/bin/bzip2 +cp -av libbz2.so* $LFS/lib +ln -sv ../../lib/libbz2.so.1.0 $LFS/usr/lib/libbz2.so +rm -v $LFS/usr/bin/{bunzip2,bzcat,bzip2} +ln -sv bzip2 $LFS/bin/bunzip2 +ln -sv bzip2 $LFS/bin/bzcat - <para>Details on this package are located in <xref linkend="contents-bzip2" role="."/></para> diff --git a/chapter05/changingowner.xml b/chapter05/changingowner.xml index 96a15b027..43a902821 100644 --- a/chapter05/changingowner.xml +++ b/chapter05/changingowner.xml @@ -18,36 +18,24 @@ class="username">root</systemitem>'s environment.</para> </note> - <para>Currently, the <filename class="directory">$LFS/tools</filename> directory + <para>Currently, the whole directory hierarchy in <filename + class="directory">$LFS</filename> is owned by the user <systemitem class="username">lfs</systemitem>, a user - that exists only on the host system. If the <filename - class="directory">$LFS/tools</filename> directory is kept as is, the files are + that exists only on the host system. If the directories under <filename + class="directory">$LFS</filename> are kept as they are, 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 - <filename class="directory">$LFS/tools</filename> directory and all the files - therein, thus exposing these files to possible malicious manipulation.</para> + a user account created later could get this same user ID and would own all + the files under <filename class="directory">$LFS</filename>, thus exposing + these files to possible malicious manipulation.</para> <para>To avoid this issue, you could add the <systemitem class="username">lfs</systemitem> user to the new LFS system later when creating the <filename>/etc/passwd</filename> file, taking care to assign it the same user and group IDs as on the host system. Better yet, change the - ownership of the <filename class="directory">$LFS/tools</filename> directory to + ownership of the <filename class="directory">$LFS/*</filename> directories to user <systemitem class="username">root</systemitem> by running the following command:</para> -<screen><userinput>chown -R root:root $LFS/tools</userinput></screen> - - <para>Although the <filename class="directory">$LFS/tools</filename> directory - can be deleted once the LFS system has been finished, it can be retained to build - additional LFS systems <emphasis>of the same book version</emphasis>. How best - to backup <filename class="directory">$LFS/tools</filename> is a matter of - personal preference.</para> - - <caution> - <para>If you intend to keep the temporary tools for use in building future LFS - systems, <emphasis>now</emphasis> is the time to back them up. Subsequent - commands in chapter 6 will alter the tools currently in place, rendering them - useless for future builds.</para> - </caution> +<screen><userinput>chown -R root:root $LFS/{usr,lib,var,etc,bin,sbin,lib64,tools}</userinput></screen> </sect1> diff --git a/chapter05/chapter05.xml b/chapter05/chapter05.xml index 2d02f9a2e..771ba53cc 100644 --- a/chapter05/chapter05.xml +++ b/chapter05/chapter05.xml @@ -19,11 +19,6 @@ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="libstdc++.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils-pass2.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="expect.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dejagnu.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="m4.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ncurses.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="bash.xml"/> @@ -35,19 +30,29 @@ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="findutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gawk.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gettext.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="grep.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gzip.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="make.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="patch.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="perl.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="python.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sed.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tar.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="texinfo.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="util-linux.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="xz.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils-pass2.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="stripping.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="changingowner.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="kernfs.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="chroot.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creatingdirs.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="createfiles.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="libstdc++-pass2.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gettext.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="perl.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="python.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="texinfo.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="util-linux.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="expect.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dejagnu.xml"/> </chapter> diff --git a/chapter05/chroot.xml b/chapter05/chroot.xml new file mode 100644 index 000000000..5b6310af7 --- /dev/null +++ b/chapter05/chroot.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" + "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ + <!ENTITY % general-entities SYSTEM "../general.ent"> + %general-entities; +]> + +<sect1 id="ch-tools-chroot"> + <?dbhtml filename="chroot.html"?> + + <title>Entering the Chroot Environment + + Now that all the packages which depend on themselves for being built + are on the system, it is time to enter the chroot environment to finish + installing the remaining temporary tools. This environment will be in use + also for installing the final system. As user root, run the following command to enter the + realm that is, at the moment, populated with only the temporary tools: + +chroot "$LFS" /usr/bin/env -i \ + HOME=/root \ + TERM="$TERM" \ + PS1='(lfs chroot) \u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash --login +h + + The -i option given to the env + command will clear all variables of the chroot environment. After that, only + the HOME, TERM, PS1, and + PATH variables are set again. The + TERM=$TERM construct will set the TERM + variable inside chroot to the same value as outside chroot. This variable is + needed for programs like vim and less + to operate properly. If other variables are needed, such as + CFLAGS or CXXFLAGS, this is a good place to set + them again. + + From this point on, there is no need to use the + LFS variable anymore, because all work will be restricted + to the LFS file system. This is because the Bash shell is told that + $LFS is now the root + (/) directory. + + Notice that /tools/bin is not + anymore in the PATH. This means that a temporary tool will no longer be + used once its final version is installed. This occurs when the shell does not + remember the locations of executed binaries—for this + reason, hashing is switched off by passing the +h option + to bash. + + Note that the bash prompt will say + I have no name! This is normal because the + /etc/passwd file has not been created yet. + + + It is important that all the commands throughout the remainder of this + chapter and the following chapters are run from within the chroot + environment. If you leave this environment for any reason (rebooting for + example), ensure that the virtual kernel filesystems are mounted as + explained in and and enter chroot again before continuing + with the installation. + + + diff --git a/chapter05/coreutils.xml b/chapter05/coreutils.xml index 6f56a4108..f1e380f7e 100644 --- a/chapter05/coreutils.xml +++ b/chapter05/coreutils.xml @@ -45,7 +45,11 @@ Prepare Coreutils for compilation: -./configure --prefix=/tools --enable-install-program=hostname +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(build-aux/config.guess) \ + --enable-install-program=hostname \ + --enable-no-install-program=kill,uptime The meaning of the configure options: @@ -64,20 +68,9 @@ make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Coreutils test suite anyway, issue the following command: - -make RUN_EXPENSIVE_TESTS=yes check - - The RUN_EXPENSIVE_TESTS=yes parameter tells the - test suite to run several additional tests that are considered - relatively expensive (in terms of CPU power and memory usage) on some - platforms, but generally are not a problem on Linux. - Install the package: -make install +make DESTDIR=$LFS install + Move programs to their final expected locations. Although this is + not necessary in this temporary environment, we must do so because some + programs harcode executable locations: + +mv -v $LFS/usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} $LFS/bin +mv -v $LFS/usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} $LFS/bin +mv -v $LFS/usr/bin/{rmdir,stty,sync,true,uname} $LFS/bin +mv -v $LFS/usr/bin/chroot $LFS/usr/sbin +mkdir -pv $LFS/usr/share/man/man8 +mv -v $LFS/usr/share/man/man1/chroot.1 $LFS/usr/share/man/man8/chroot.8 +sed -i s/\"1\"/\"8\"/1 $LFS/usr/share/man/man8/chroot.8 +mv -v $LFS/usr/bin/{head,nice,sleep,touch} $LFS/bin + diff --git a/chapter05/createfiles.xml b/chapter05/createfiles.xml new file mode 100644 index 000000000..c762c50b9 --- /dev/null +++ b/chapter05/createfiles.xml @@ -0,0 +1,196 @@ + + + %general-entities; +]> + + + + + Creating Essential Files and Symlinks + + + /etc/passwd + + + + /etc/group + + + + /var/run/utmp + + + + /var/log/btmp + + + + /var/log/lastlog + + + + /var/log/wtmp + + + Historically, Linux maintains a list of the mounted file systems in the + file /etc/mtab. Modern kernels maintain this list + internally and exposes it to the user via the /proc filesystem. To satisfy utilities that + expect the presence of /etc/mtab, create the following + symbolic link: + +ln -sv /proc/self/mounts /etc/mtab + + In order for user root to be + able to login and for the name root to be recognized, there + must be relevant entries in the /etc/passwd and + /etc/group files. + + Create the /etc/passwd file by running the following + command: + +cat > /etc/passwd << "EOF" +root:x:0:0:root:/root:/bin/bash +bin:x:1:1:bin:/dev/null:/bin/false +daemon:x:6:6:Daemon User:/dev/null:/bin/false +messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false +nobody:x:99:99:Unprivileged User:/dev/null:/bin/false +EOF + +cat > /etc/passwd << "EOF" +root:x:0:0:root:/root:/bin/bash +bin:x:1:1:bin:/dev/null:/bin/false +daemon:x:6:6:Daemon User:/dev/null:/bin/false +messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false +systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false +systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false +systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false +systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false +systemd-network:x:76:76:systemd Network Management:/:/bin/false +systemd-resolve:x:77:77:systemd Resolver:/:/bin/false +systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false +systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false +nobody:x:99:99:Unprivileged User:/dev/null:/bin/false +EOF + + The actual password for root + (the x used here is just a placeholder) will be set later. + + Create the /etc/group file by running the following + command: + +cat > /etc/group << "EOF" +root:x:0: +bin:x:1:daemon +sys:x:2: +kmem:x:3: +tape:x:4: +tty:x:5: +daemon:x:6: +floppy:x:7: +disk:x:8: +lp:x:9: +dialout:x:10: +audio:x:11: +video:x:12: +utmp:x:13: +usb:x:14: +cdrom:x:15: +adm:x:16: +messagebus:x:18: +input:x:24: +mail:x:34: +kvm:x:61: +wheel:x:97: +nogroup:x:99: +users:x:999: +EOF + +cat > /etc/group << "EOF" +root:x:0: +bin:x:1:daemon +sys:x:2: +kmem:x:3: +tape:x:4: +tty:x:5: +daemon:x:6: +floppy:x:7: +disk:x:8: +lp:x:9: +dialout:x:10: +audio:x:11: +video:x:12: +utmp:x:13: +usb:x:14: +cdrom:x:15: +adm:x:16: +messagebus:x:18: +systemd-journal:x:23: +input:x:24: +mail:x:34: +kvm:x:61: +systemd-bus-proxy:x:72: +systemd-journal-gateway:x:73: +systemd-journal-remote:x:74: +systemd-journal-upload:x:75: +systemd-network:x:76: +systemd-resolve:x:77: +systemd-timesync:x:78: +systemd-coredump:x:79: +wheel:x:97: +nogroup:x:99: +users:x:999: +EOF + + The created groups are not part of any standard—they are groups + decided on in part by the requirements of the Udev configuration in the next + chapter, and in part by common convention employed by a number of existing + Linux distributions. In addition, some test suites rely on specific users + or groups. The Linux Standard Base (LSB, available at ) recommends only that, besides the group + root with a Group ID (GID) of 0, + a group bin with a GID of 1 be + present. All other group names and GIDs can be chosen freely by the system + administrator since well-written programs do not depend on GID numbers, but + rather use the group's name. + + To remove the I have no name! prompt, start a new + shell. Since the + /etc/passwd and /etc/group + files have been created, user name and group name resolution will now + work: + +exec /bin/bash --login +h + + Note the use of the +h directive. This tells + bash not to use its internal path hashing. Without this + directive, bash would remember the paths to binaries it has + executed. To ensure the use of the newly compiled binaries as soon as they are + installed, the +h directive will be used for the duration + of this chapter. + + The login, agetty, and + init programs (and others) use a number of log + files to record information such as who was logged into the system and + when. However, these programs will not write to the log files if they + do not already exist. Initialize the log files and give them + proper permissions: + +touch /var/log/{btmp,lastlog,faillog,wtmp} +chgrp -v utmp /var/log/lastlog +chmod -v 664 /var/log/lastlog +chmod -v 600 /var/log/btmp + + The /var/log/wtmp file records all logins and + logouts. The /var/log/lastlog file records when each + user last logged in. The /var/log/faillog file records + failed login attempts. The /var/log/btmp file records + the bad login attempts. + + The /run/utmp file records the users that + are currently logged in. This file is created dynamically in the boot + scripts. + + diff --git a/chapter05/creatingdirs.xml b/chapter05/creatingdirs.xml new file mode 100644 index 000000000..359717ff7 --- /dev/null +++ b/chapter05/creatingdirs.xml @@ -0,0 +1,59 @@ + + + %general-entities; +]> + + + + + Creating Directories + + It is time to create the full structure in the LFS file system. Create + a standard directory tree by issuing the following commands: + +mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt} +mkdir -pv /{media/{floppy,cdrom},srv,var} +install -dv -m 0750 /root +install -dv -m 1777 /tmp /var/tmp +mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src} +mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man} +mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo} +mkdir -pv /usr/{,local/}share/man/man{1..8} + +mkdir -v /var/{log,mail,spool} +ln -sv /run /var/run +ln -sv /run/lock /var/lock +mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local} + + Directories are, by default, created with permission mode 755, but + this is not desirable for all directories. In the commands above, two + changes are made—one to the home directory of user root, and another to the directories for + temporary files. + + The first mode change ensures that not just anybody can enter + the /root directory—the + same as a normal user would do with his or her home directory. The + second mode change makes sure that any user can write to the + /tmp and /var/tmp directories, but cannot remove + another user's files from them. The latter is prohibited by the so-called + sticky bit, the highest bit (1) in the 1777 bit mask. + + + FHS Compliance Note + + The directory tree is based on the Filesystem Hierarchy Standard + (FHS) (available at ). The FHS also specifies + the optional existence of some directories such as /usr/local/games and /usr/share/games. We create only the + directories that are needed. However, feel free to create these + directories. + + + + diff --git a/chapter05/dejagnu.xml b/chapter05/dejagnu.xml index a821e9bba..8f1ab7648 100644 --- a/chapter05/dejagnu.xml +++ b/chapter05/dejagnu.xml @@ -44,11 +44,16 @@ Prepare DejaGNU for compilation: -./configure --prefix=/tools +./configure --prefix=/usr +makeinfo --html --no-split -o doc/dejagnu.html doc/dejagnu.texi +makeinfo --plaintext -o doc/dejagnu.txt doc/dejagnu.texi Build and install the package: -make install +make install +install -v -dm755 /usr/share/doc/dejagnu-&dejagnu-version; +install -v -m644 doc/dejagnu.{html,txt} \ + /usr/share/doc/dejagnu-&dejagnu-version; To test the results, issue: diff --git a/chapter05/diffutils.xml b/chapter05/diffutils.xml index 62ba35874..194fe4607 100644 --- a/chapter05/diffutils.xml +++ b/chapter05/diffutils.xml @@ -45,21 +45,15 @@ Prepare Diffutils for compilation: -./configure --prefix=/tools +./configure --prefix=/usr --host=$LFS_TGT Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Diffutils test suite anyway, issue the following command: - -make check - Install the package: -make install +make DESTDIR=$LFS install diff --git a/chapter05/expect.xml b/chapter05/expect.xml index a2cc67d0e..20b227ea5 100644 --- a/chapter05/expect.xml +++ b/chapter05/expect.xml @@ -48,34 +48,29 @@ Installation of Expect - First, 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 test suite tools remain sane for the final builds of our - toolchain: + Prepare Expect for compilation: -cp -v configure{,.orig} -sed 's:/usr/local/bin:/bin:' configure.orig > configure - - Now prepare Expect for compilation: - -./configure --prefix=/tools \ - --with-tcl=/tools/lib \ - --with-tclinclude=/tools/include + +./configure --prefix=/usr \ + --with-tcl=/usr/lib \ + --enable-shared \ + --mandir=/usr/share/man \ + --with-tclinclude=/usr/include The meaning of the configure options: - --with-tcl=/tools/lib + --with-tcl=/usr/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. + This parameter is needed to tell the + configure where the + tclConfig.sh is located. - --with-tclinclude=/tools/include + --with-tclinclude=/usr/include This explicitly tells Expect where to find Tcl's internal headers. Using this option avoids conditions where @@ -90,33 +85,10 @@ sed 's:/usr/local/bin:/bin:' configure.orig > configure make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Expect test suite anyway, issue the following command: - -make test - - Note that the Expect test suite is known to experience failures under - certain host conditions that are not within our control. Therefore, - test suite failures here are not surprising and are not considered - critical. - Install the package: -make SCRIPTS="" install - - - The meaning of the make parameter: - - - SCRIPTS="" - - This prevents installation of the supplementary Expect - scripts, which are not needed. - - - - +make install +ln -svf expect&expect-version;/libexpect&expect-version;.so /usr/lib diff --git a/chapter05/file.xml b/chapter05/file.xml index 9fcfd1e6f..5a821d180 100644 --- a/chapter05/file.xml +++ b/chapter05/file.xml @@ -45,29 +45,28 @@ Prepare File for compilation: -./configure --prefix=/tools - +./configure --prefix=/usr \ + --host=$LFS_TGT + + Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the File test suite anyway, issue the following command: - -make check - Install the package: -make install +make DESTDIR=$LFS install - - <para>Details on this package are located in - <xref linkend="contents-file" role="."/></para> + <para>Details on this package are located in<!-- TODO + <xref linkend="contents-file" role="."/> --></para> </sect2> diff --git a/chapter05/findutils.xml b/chapter05/findutils.xml index 064a9e848..073c1640c 100644 --- a/chapter05/findutils.xml +++ b/chapter05/findutils.xml @@ -42,30 +42,25 @@ <sect2 role="installation"> <title>Installation of Findutils - Prepare Findutils for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(build-aux/config.guess) Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Findutils test suite anyway, issue the following command: + Install the package: -make check +make DESTDIR=$LFS install - Install the package: + Move the excutable to its final expected location: -make install +mv -v $LFS/usr/bin/find $LFS/bin +sed -i 's|find:=${BINDIR}|find:=/bin|' $LFS/usr/bin/updatedb diff --git a/chapter05/flex.xml b/chapter05/flex.xml index 5e1afa194..5761e82e5 100644 --- a/chapter05/flex.xml +++ b/chapter05/flex.xml @@ -45,19 +45,37 @@ Prepare Flex for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(build-aux/config.guess) \ + --disable-bootstrap \ + --docdir=/usr/share/doc/flex-&flex-version; + + + The meaning of the new configure option: + + + --disable-bootstrap + + Normally, building flex is done in two stages. A first + programs, which is used to generate the source of a second one, + which is then compiled. When using cross-compilation, the first + program is generated on the build systemd. However, due to a bug + in configure, the presence of some funciton is tested only on the + host system. If this function is not found on the build system, the + build fails. This can be prevented by disabling the two stage + build. + + + Compile the package: make - To test the results, issue: - -make check - Install the package: -make install +make DESTDIR=$LFS install diff --git a/chapter05/gawk.xml b/chapter05/gawk.xml index adcd2ea15..d5b5d6d8d 100644 --- a/chapter05/gawk.xml +++ b/chapter05/gawk.xml @@ -43,23 +43,23 @@ Installation of Gawk + First, ensure some unneeded files are not installed: + +sed -i 's/extras//' Makefile.in + Prepare Gawk for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(./config.guess) Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Gawk test suite anyway, issue the following command: - -make check - Install the package: -make install +make DESTDIR=$LFS install diff --git a/chapter05/gcc-pass1.xml b/chapter05/gcc-pass1.xml index d209cd44f..1bd308f09 100644 --- a/chapter05/gcc-pass1.xml +++ b/chapter05/gcc-pass1.xml @@ -43,7 +43,7 @@ Installation of Cross GCC - GCC now requires the GMP, MPFR and MPC packages. As these packages may + GCC requires the GMP, MPFR and MPC packages. As these packages may not be included in your host distribution, they will be built with GCC. Unpack each package into the GCC source directory and rename the resulting directories so the GCC build procedures will automatically @@ -62,42 +62,7 @@ mv -v gmp-&gmp-version; gmp tar -xf ../mpc-&mpc-version;.tar.gz mv -v mpc-&mpc-version; mpc - 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. - Issue: - -for file in gcc/config/{linux,i386/linux{,64}}.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_STARTFILE_PREFIX_1 -#undef STANDARD_STARTFILE_PREFIX_2 -#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" -#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file - touch $file.orig -done - - In case the above seems hard to follow, let's break it down a bit. - First we copy the files gcc/config/linux.h, - gcc/config/i386/linux.h, and - gcc/config/i386/linux64.h to a file of - the same name but with an added suffix of .orig. Then the - first sed expression prepends /tools to every instance of - /lib/ld, /lib64/ld or - /lib32/ld, while the second one replaces hard-coded - instances of /usr. Next, we add our define statements which - alter the default startfile prefix to the end of the file. Note that the - trailing / in /tools/lib/ is required. - Finally, we use touch to update the timestamp on the - copied files. When used in conjunction with cp -u, this - prevents unexpected changes to the original files in case the commands are - inadvertently run twice. - - Finally, on x86_64 hosts, set the default directory name for + On x86_64 hosts, set the default directory name for 64-bit libraries to lib: case $(uname -m) in @@ -107,19 +72,6 @@ done ;; esac - - - The GCC documentation recommends building GCC in a dedicated build directory: @@ -130,13 +82,12 @@ cd build ../configure \ --target=$LFS_TGT \ - --prefix=/tools \ + --prefix=$LFS/tools \ --with-glibc-version=2.11 \ --with-sysroot=$LFS \ --with-newlib \ --without-headers \ - --with-local-prefix=/tools \ - --with-native-system-header-dir=/tools/include \ + --enable-initfini-array \ --disable-nls \ --disable-shared \ --disable-multilib \ @@ -180,36 +131,12 @@ cd build - - --with-local-prefix=/tools - - The local prefix is the location in the system that GCC will search - for locally installed include files. The default is /usr/local. - Setting this to /tools helps keep the host location of - /usr/local out of this GCC's search path. - - - - - --with-native-system-header-dir=/tools/include - - By default, GCC searches /usr/include for - system headers. In conjunction with the sysroot switch, this would - normally translate to $LFS/usr/include. However - the headers that will be installed in the next two sections will go - to $LFS/tools/include. This switch ensures that - gcc will find them correctly. In the second pass of GCC, this same - switch will ensure that no headers from the host system are - found. - - - --disable-shared This switch forces GCC to link its internal libraries - statically. We do this to avoid possible issues with the host - system. + statically. We need this because the shared libraries require glibc, + which is not yet installed on the target system. @@ -249,26 +176,25 @@ cd build make - Compilation is now complete. At this point, the test suite would - normally be run, but, as mentioned before, the test suite framework is - not in place yet. The benefits of running the tests at this point - are minimal since the programs from this first pass will soon be - replaced. - Install the package: -make install - + make install + + This build of GCC has installed a couple of internal system + headers. Normally one of them, limits.h, would in turn + include the corresponding system limits.h header, in + this case, $LFS/usr/include/limits.h. However, at the + time of this build of gcc $LFS/usr/include/limits.h + does not exist, so the internal header that has just been installed is a + partial, self-contained file and does not include the extended features of + the system header. This is adequate for building glibc, but the full + internal header will be needed later. Create a full version of the internal + header using a command that is identical to what the GCC build system does + in normal circumstances: + +cd .. +cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ + `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h diff --git a/chapter05/gcc-pass2.xml b/chapter05/gcc-pass2.xml index ca2a06f1c..98e3b2127 100644 --- a/chapter05/gcc-pass2.xml +++ b/chapter05/gcc-pass2.xml @@ -54,23 +54,6 @@ mv -v gmp-&gmp-version; gmp tar -xf ../mpc-&mpc-version;.tar.gz mv -v mpc-&mpc-version; mpc - Once again, change the location of GCC's default dynamic linker to - use the one installed in /tools. - -for file in gcc/config/{linux,i386/linux{,64}}.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_STARTFILE_PREFIX_1 -#undef STANDARD_STARTFILE_PREFIX_2 -#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" -#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file - touch $file.orig -done - If building on x86_64, change the default directory name for 64-bit libraries to lib: @@ -81,84 +64,62 @@ done ;; esac - Our first build of GCC has installed a couple of internal system - headers. Normally one of them, limits.h, will in turn - include the corresponding system limits.h header, in - this case, /tools/include/limits.h. However, at the - time of the first build of gcc /tools/include/limits.h - did not exist, so the internal header that GCC installed is a partial, - self-contained file and does not include the extended features of the - system header. This was adequate for building the temporary libc, but this - build of GCC now requires the full internal header. Create a full version - of the internal header using a command that is identical to what the GCC - build system does in normal circumstances: - -cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ - `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h - Create a separate build directory again: mkdir -v build cd build + Create a symlink that allos libgcc to be built with posix threads + support: + +mkdir -pv $LFS_TGT/libgcc +ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h + Before starting to build GCC, remember to unset any environment variables that override the default optimization flags. Now prepare GCC for compilation: -CC=$LFS_TGT-gcc \ -CXX=$LFS_TGT-g++ \ -AR=$LFS_TGT-ar \ -RANLIB=$LFS_TGT-ranlib \ -../configure \ - --prefix=/tools \ - --with-local-prefix=/tools \ - --with-native-system-header-dir=/tools/include \ - --enable-languages=c,c++ \ - --disable-libstdcxx-pch \ +../configure \ + --build=$(../config.guess) \ + --host=$LFS_TGT \ + --prefix=/usr \ + CC_FOR_TARGET=$LFS_TGT-gcc \ + --with-build-sysroot=$LFS \ + --enable-initfini-array \ + --disable-nls \ --disable-multilib \ - --disable-bootstrap \ - --disable-libgomp + --disable-decimal-float \ + --disable-libatomic \ + --disable-libgomp \ + --disable-libquadmath \ + --disable-libssp \ + --disable-libvtv \ + --disable-libstdcxx \ + --enable-languages=c,c++ - The meaning of the new configure options: - - - --enable-languages=c,c++ - - This option ensures that both the C and C++ compilers are - built. - - + The meaning of the new configure options: - --disable-libstdcxx-pch + -with-build-sysroot=$LFS - Do not build the pre-compiled header (PCH) for - libstdc++. It takes up a - lot of space, and we have no use for it. + Normally, using --host= ensures that + a cross-compiler is used for building gcc, and that compiler knows + that it has to look for headers and libraries in $LFS. But the build system of GCC uses + other tools, which are not aware of this location. This switch is + needed to have them find the needed files in $LFS, and not on the host. - --disable-bootstrap + --enable-initfini-array - 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. + This option is automatically enabled when building a native + compiler with a native compiler on x86. But here, we build with + a cross compiler, so we need to explicitely set this option. @@ -170,7 +131,7 @@ RANLIB=$LFS_TGT-ranlib \ Install the package: -make install +make DESTDIR=$LFS install As a finishing touch, create a symlink. Many programs and scripts run cc instead of gcc, which is @@ -179,45 +140,7 @@ RANLIB=$LFS_TGT-ranlib \ cc leaves the system administrator free to decide which C compiler to install: -ln -sv gcc /tools/bin/cc - - - At this point, it is imperative to stop and ensure that the basic - functions (compiling and linking) of the new toolchain are working as - expected. To perform a sanity check, run the following commands: - -echo 'int 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/lib64/ld-linux-x86-64.so.2] - - Note that the dynamic linker will be /tools/lib/ld-linux.so.2 - for 32-bit machines. - - If the output is not shown as above or there was no output at all, - then something is wrong. Investigate and retrace the steps to find out - where the problem is and correct it. This issue must be resolved before - continuing on. First, perform the sanity check again, using - gcc instead of cc. If this works, - then the /tools/bin/cc symlink is - missing. Install the symlink as per above. - Next, ensure that the PATH is correct. This - can be checked by running echo $PATH and verifying that - /tools/bin is at the head of the - list. If the PATH is wrong it could mean that you are not - logged in as user lfs or that - something went wrong back in - - Once all is well, clean up the test files: - -rm -v dummy.c a.out - - +ln -sv gcc $LFS/usr/bin/cc diff --git a/chapter05/generalinstructions.xml b/chapter05/generalinstructions.xml index bf1ec6112..05b88b98c 100644 --- a/chapter05/generalinstructions.xml +++ b/chapter05/generalinstructions.xml @@ -81,9 +81,9 @@ Place all the sources and patches in a directory that will be accessible from the chroot environment such as - /mnt/lfs/sources/. Do + /mnt/lfs/sources/. Change to the sources directory. diff --git a/chapter05/gettext.xml b/chapter05/gettext.xml index ff064cb7e..a3baed723 100644 --- a/chapter05/gettext.xml +++ b/chapter05/gettext.xml @@ -52,16 +52,7 @@ The meaning of the configure option: - + --disable-shared @@ -76,14 +67,10 @@ make - - Due to the limited environment, running the test suite at this stage - is not recommended. - Install the msgfmt, msgmerge and xgettext programs: -cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /tools/bin +cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin diff --git a/chapter05/glibc.xml b/chapter05/glibc.xml index d8a4f6733..5213c23e5 100644 --- a/chapter05/glibc.xml +++ b/chapter05/glibc.xml @@ -43,6 +43,19 @@ Installation of Glibc + First, create two symbolic links, which are needed for proper + operation of the dynamic library loader: + +ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64 +ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3 + + Some of the Glibc programs use the non-FHS compliant + /var/db directory to store their + runtime data. Apply the following patch to make such programs store their + runtime data in the FHS-compliant locations: + +patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch + The Glibc documentation recommends building Glibc in a dedicated build directory: @@ -52,11 +65,12 @@ cd build Next, prepare Glibc for compilation: ../configure \ - --prefix=/tools \ + --prefix=/usr \ --host=$LFS_TGT \ --build=$(../scripts/config.guess) \ --enable-kernel=&min-kernel; \ - --with-headers=/tools/include + --with-headers=$LFS/usr/include \ + libc_cv_slibdir=/lib @@ -68,7 +82,7 @@ cd build --host=$LFS_TGT, --build=$(../scripts/config.guess) The combined effect of these switches is that Glibc's build system - configures itself to cross-compile, using the cross-linker and + configures itself to be cross-compiled, using the cross-linker and cross-compiler in /tools. @@ -83,26 +97,22 @@ cd build - --with-headers=/tools/include + --with-headers=$LFS/usr/include This tells Glibc to compile itself against the headers recently - installed to the tools directory, so that it knows exactly what + installed to the usr/include directory, so that it knows exactly what features the kernel has and can optimize itself accordingly. - - diff --git a/chapter05/kernfs.xml b/chapter05/kernfs.xml new file mode 100644 index 000000000..b82ac4e7b --- /dev/null +++ b/chapter05/kernfs.xml @@ -0,0 +1,115 @@ + + + %general-entities; +]> + + + + + Preparing Virtual Kernel File Systems + + + /dev/* + + + Various file systems exported by the kernel are used to communicate to + and from the kernel itself. These file systems are virtual in that no disk + space is used for them. The content of the file systems resides in + memory. + + Begin by creating directories onto which the file systems will be + mounted: + +mkdir -pv $LFS/{dev,proc,sys,run} + + + Creating Initial Device Nodes + + When the kernel boots the system, it requires the presence of a few + device nodes, in particular the console and null devices. The device nodes must be created + on the hard disk so that they are available before udevd + has been started, and additionally when Linux is started with + init=/bin/bash. Create the devices by running the + following commands: + +mknod -m 600 $LFS/dev/console c 5 1 +mknod -m 666 $LFS/dev/null c 1 3 + + + + + Mounting and Populating /dev + + The recommended method of populating the /dev directory with devices is to mount a + virtual filesystem (such as tmpfs) on the /dev directory, and allow the devices to be + created dynamically on that virtual filesystem as they are detected or + accessed. Device creation is generally done during the boot process + by Udev. Since this new system does not yet have Udev and has not yet + been booted, it is necessary to mount and populate /dev manually. This is accomplished by bind + mounting the host system's /dev + directory. A bind mount is a special type of mount that allows you to + create a mirror of a directory or mount point to some other location. Use + the following command to achieve this: + +mount -v --bind /dev $LFS/dev + + + + + Mounting Virtual Kernel File Systems + + Now mount the remaining virtual kernel filesystems: + +mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620 +mount -vt proc proc $LFS/proc +mount -vt sysfs sysfs $LFS/sys +mount -vt tmpfs tmpfs $LFS/run + + + The meaning of the mount options for devpts: + + + gid=5 + + This ensures that all devpts-created device nodes are owned by + group ID 5. This is the ID we will use later on for the tty group. We use the group ID instead + of a name, since the host system might use a different ID for its + tty group. + + + + + mode=0620 + + This ensures that all devpts-created device nodes have mode 0620 + (user readable and writable, group writable). Together with the + option above, this ensures that devpts will create device nodes that + meet the requirements of grantpt(), meaning the Glibc + pt_chown helper binary (which is not installed by + default) is not necessary. + + + + + + In some host systems, /dev/shm is a + symbolic link to /run/shm. + The /run tmpfs was mounted above so in this case only a + directory needs to be created. + +if [ -h $LFS/dev/shm ]; then + mkdir -pv $LFS/$(readlink $LFS/dev/shm) +fi + + + + diff --git a/chapter05/libstdc++-pass2.xml b/chapter05/libstdc++-pass2.xml new file mode 100644 index 000000000..999a4fa4e --- /dev/null +++ b/chapter05/libstdc++-pass2.xml @@ -0,0 +1,114 @@ + + + %general-entities; +]> + + + + + + gcc-libstdc++ + &gcc-version; +
&gcc-url;
+
+ + Libstdc++ from GCC-&gcc-version;, Pass 2 + + + GCC + tools, libstdc++ pass 2 + + + + + + <para>Again, when building <xref linkend="ch-tools-gcc-pass2"/>, we had to + defer the installation of the C++ standard library, because no suitable + compiler was available to compile it: we could not use the compiler + installed, because this compiler is a native + compiler, and should not be used outside of chroot without being at + risk of polluting the build with some host components.</para> + + <segmentedlist> + <segtitle>&buildtime;</segtitle> + <segtitle>&diskspace;</segtitle> + + <!-- TODO --> + <seglistitem> + <seg>&libstdcpp-ch5-sbu;</seg> + <seg>&libstdcpp-ch5-du;</seg> + </seglistitem> + </segmentedlist> + + </sect2> + + <sect2 role="installation"> + <title>Installation of Target Libstdc++ + + + Libstdc++ is part of the GCC sources. + You should first unpack the GCC tarball and change to the + gcc-&gcc-version; directory. + + + Create a link which exists when building Libstdc++ in the gcc + tree: + +ln -s gthr-posix.h libgcc/gthr-default.h + + Create a separate build directory for Libstdc++ and enter it: + +mkdir -v build +cd build + + Prepare Libstdc++ for compilation: + +../libstdc++-v3/configure \ + CXXFLAGS="-g -O2 -D_GNU_SOURCE" \ + --prefix=/usr \ + --disable-multilib \ + --disable-nls \ + --disable-libstdcxx-pch + + + The meaning of the configure options: + + + CXXFLAGS="-g -O2 -D_GNU_SOURCE" + + Those flags are passed by the top level Makefile when doing + a full build of GCC. + + + + + --disable-libstdcxx-pch + + This switch prevents the installation of precompiled + include files, which are not needed at this stage. + + + + + + Compile libstdc++ by running: + +make + + Install the library: + +make install + + + + + + + <para>Details on this package are located in + <xref linkend="contents-gcc" role="."/></para> + + </sect2> + +</sect1> diff --git a/chapter05/libstdc++.xml b/chapter05/libstdc++.xml index 66128aa8a..3a1b0f2bf 100644 --- a/chapter05/libstdc++.xml +++ b/chapter05/libstdc++.xml @@ -5,8 +5,8 @@ %general-entities; ]> -<sect1 id="ch-tools-libstdcpp" role="wrap"> - <?dbhtml filename="gcc-libstdc++.html"?> +<sect1 id="ch-tools-libstdcpp-pass1" role="wrap"> + <?dbhtml filename="gcc-libstdc++-pass1.html"?> <sect1info condition="script"> <productname>gcc-libstdc++</productname> @@ -14,11 +14,11 @@ <address>&gcc-url;</address> </sect1info> - <title>Libstdc++ from GCC-&gcc-version; + Libstdc++ from GCC-&gcc-version;, Pass 1 - + GCC - tools, libstdc++ + tools, libstdc++ pass 1 @@ -28,7 +28,8 @@ to compile C++ code (part of GCC is written in C++), but we had to defer its installation when we built - because it depends on glibc, which was not yet available in /tools. + because it depends on glibc, which was not yet available in the target + directory. @@ -61,10 +62,10 @@ cd build ../libstdc++-v3/configure \ --host=$LFS_TGT \ - --prefix=/tools \ + --build=$(../config.guess) \ + --prefix=/usr \ --disable-multilib \ - --disable-nls \ + --disable-nls \ --disable-libstdcxx-pch \ --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/&gcc-version; @@ -78,15 +79,7 @@ cd build instead of the one in /usr/bin.
- + --disable-libstdcxx-pch @@ -114,7 +107,7 @@ cd build Install the library: -make install +make DESTDIR=$LFS install diff --git a/chapter05/linux-headers.xml b/chapter05/linux-headers.xml index 7a92b466f..6c1af3173 100644 --- a/chapter05/linux-headers.xml +++ b/chapter05/linux-headers.xml @@ -24,9 +24,8 @@ - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" - href="../chapter06/linux-headers.xml" - xpointer="xpointer(/sect1/sect2[1]/para[1])"/> + <para>The Linux API Headers (in linux-&linux-version;.tar.xz) expose the + kernel's API for use by Glibc.</para> <segmentedlist> <segtitle>&buildtime;</segtitle> @@ -60,15 +59,148 @@ location.</para> <screen><userinput remap="make">make headers -</userinput><userinput remap="install">cp -rv usr/include/* /tools/include</userinput></screen> +find usr/include -name '.*' -delete +rm usr/include/Makefile +</userinput><userinput remap="install">cp -rv usr/include $LFS/usr</userinput></screen> </sect2> - <sect2 role="content"> - <title/> + <sect2 id="contents-linux-headers" role="content"> + <title>Contents of Linux API Headers + + + Installed headers + Installed directories + + + /usr/include/asm/*.h, /usr/include/asm-generic/*.h, + /usr/include/drm/*.h, /usr/include/linux/*.h, /usr/include/misc/*.h, + /usr/include/mtd/*.h, /usr/include/rdma/*.h, /usr/include/scsi/*.h, + /usr/include/sound/*.h, /usr/include/video/*.h, + and /usr/include/xen/*.h + /usr/include/asm, /usr/include/asm-generic, /usr/include/drm, + /usr/include/linux, /usr/include/misc, /usr/include/mtd, + /usr/include/rdma, /usr/include/scsi, /usr/include/sound, + /usr/include/video, and /usr/include/xen + + - Details on this package are located in - + + Short Descriptions + + + + + /usr/include/asm/*.h + + The Linux API ASM Headers + + /usr/include/asm/*.h + + + + + + /usr/include/asm-generic/*.h + + The Linux API ASM Generic Headers + + /usr/include/asm-generic/*.h + + + + + + /usr/include/drm/*.h + + The Linux API DRM Headers + + /usr/include/drm/*.h + + + + + + /usr/include/linux/*.h + + The Linux API Linux Headers + + /usr/include/linux/*.h + + + + + + /usr/include/misc/*.h + + The Linux API Miscellaneous Headers + + /usr/include/misc/*.h + + + + + + /usr/include/mtd/*.h + + The Linux API MTD Headers + + /usr/include/mtd/*.h + + + + + + /usr/include/rdma/*.h + + The Linux API RDMA Headers + + /usr/include/rdma/*.h + + + + + + /usr/include/scsi/*.h + + The Linux API SCSI Headers + + /usr/include/scsi/*.h + + + + + + /usr/include/sound/*.h + + The Linux API Sound Headers + + /usr/include/sound/*.h + + + + + + /usr/include/video/*.h + + The Linux API Video Headers + + /usr/include/video/*.h + + + + + + /usr/include/xen/*.h + + The Linux API Xen Headers + + /usr/include/xen/*.h + + + + + diff --git a/chapter05/m4.xml b/chapter05/m4.xml index 0dcc6b774..3f51c11d1 100644 --- a/chapter05/m4.xml +++ b/chapter05/m4.xml @@ -50,27 +50,22 @@ echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h Prepare M4 for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(build-aux/config.guess) Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the M4 test suite anyway, issue the following command: - -make check - Install the package: -make install +make DESTDIR=$LFS install - <para>Details on this package are located in <xref linkend="contents-m4" role="."/></para> diff --git a/chapter05/make.xml b/chapter05/make.xml index 205ae5f15..5f895c49d 100644 --- a/chapter05/make.xml +++ b/chapter05/make.xml @@ -41,41 +41,20 @@ <sect2 role="installation"> <title>Installation of Make - Prepare Make for compilation: -./configure --prefix=/tools --without-guile - - - The meaning of the configure option: - - - --without-guile - - This ensures that Make-&make-version; won't link against Guile libraries, which - may be present on the host system, but won't be available within the - chroot environment in the next chapter. - - - +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(build-aux/config.guess) Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Make test suite anyway, issue the following command: - -make check - Install the package: -make install +make DESTDIR=$LFS install diff --git a/chapter05/ncurses.xml b/chapter05/ncurses.xml index c00135f12..5c868fffd 100644 --- a/chapter05/ncurses.xml +++ b/chapter05/ncurses.xml @@ -49,15 +49,20 @@ Prepare Ncurses for compilation: -./configure --prefix=/tools \ - --with-shared \ - --without-debug \ - --without-ada \ - --enable-widec \ - --enable-overwrite +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(./config.guess) \ + --mandir=/usr/share/man \ + --with-shared \ + --without-debug \ + --without-ada \ + --without-normal \ + --disable-db-install \ + --enable-widec \ + --enable-pc-files - The meaning of the configure options: + The meaning of the new configure options: --without-ada @@ -68,17 +73,6 @@ - - --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. - - - --enable-widec @@ -93,22 +87,53 @@ + + --enable-pc-files + + This switch generates and installs .pc files for pkg-config. + + + + + + --without-normal + + This switch disables building and installing most static libraries. + + + + + + --disable-db-install + + This switch disables building the terminfo database: it is not + needed at this stage, and if tic is too old, + it cannot compile recent databases. + + + Compile the package: make - This package has a test suite, but it can only be run after the - package has been installed. The tests reside in the - test/ directory. See the - README file in that directory for further details. - - Install the package: + +make DESTDIR=$LFS install + ln -s libncursesw.so $LFS/usr/lib/libncurses.so + + Move the shared libraries to the + /lib directory, where they are + expected to reside: + +mv -v $LFS/usr/lib/libncursesw.so.6* $LFS/lib + + Because the libraries have been moved, one symlink points to + a non-existent file. Recreate it: + +ln -sfv ../../lib/$(readlink $LFS/usr/lib/libncursesw.so) $LFS/usr/lib/libncursesw.so -make install -ln -s libncursesw.so /tools/lib/libncurses.so diff --git a/chapter05/patch.xml b/chapter05/patch.xml index 15049bbe5..08bad5c56 100644 --- a/chapter05/patch.xml +++ b/chapter05/patch.xml @@ -45,21 +45,17 @@ Prepare Patch for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(build-aux/config.guess) Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Patch test suite anyway, issue the following command: - -make check - Install the package: -make install +make DESTDIR=$LFS install diff --git a/chapter05/perl.xml b/chapter05/perl.xml index 2bb15453b..663d3dbc2 100644 --- a/chapter05/perl.xml +++ b/chapter05/perl.xml @@ -45,11 +45,10 @@ Prepare Perl for compilation: -sh Configure -des -Dprefix=/tools -Dlibs=-lm -Uloclibpth -Ulocincpth +sh Configure -des -Dprefix=/usr - The meaning of the Configure options: - + The meaning of the new Configure options: -des @@ -59,36 +58,13 @@ - - - -Uloclibpth and - -Ulocincpth - - - These entries undefine variables that cause the configuration - to search for locally installed components that may exist on the - host system. - - - - - - Build the package: make - Although Perl comes with a test suite, it would be better to wait - until it is installed in the next chapter. - - Only a few of the utilities and libraries need to be installed at this - time: - -cp -v perl cpan/podlators/scripts/pod2man /tools/bin -mkdir -pv /tools/lib/perl5/&perl-version; -cp -Rv lib/* /tools/lib/perl5/&perl-version; +make install diff --git a/chapter05/python.xml b/chapter05/python.xml index fcca9c92c..8e7afaf03 100644 --- a/chapter05/python.xml +++ b/chapter05/python.xml @@ -5,8 +5,8 @@ %general-entities; ]> - - + + Python @@ -16,9 +16,9 @@ Python-&python-version; - + Python - tools + temporary @@ -50,18 +50,9 @@ uppercase first letter). - This package first builds the Python interpreter, then some - standard Python modules. The main script for building modules is - written in Python, and uses hard-coded paths to the host /usr/include and /usr/lib directories. To prevent them - from being used, issue: - -sed -i '/def add_multiarch_paths/a \ return' setup.py - Prepare Python for compilation: -./configure --prefix=/tools --without-ensurepip +./configure --prefix=/usr --without-ensurepip The meaning of the configure option: @@ -80,10 +71,6 @@ make - Compilation is now complete. The test suite requires TK and - and X Windows and cannot be run at this time. - - Install the package: make install diff --git a/chapter05/sed.xml b/chapter05/sed.xml index 9a945e772..5daaf6b7e 100644 --- a/chapter05/sed.xml +++ b/chapter05/sed.xml @@ -45,21 +45,17 @@ Prepare Sed for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --bindir=/bin Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Sed test suite anyway, issue the following command: - -make check - Install the package: -make install +make DESTDIR=$LFS install diff --git a/chapter05/stripping.xml b/chapter05/stripping.xml index dc55959bf..7c054b6b2 100644 --- a/chapter05/stripping.xml +++ b/chapter05/stripping.xml @@ -15,12 +15,19 @@ The executables and libraries built so far contain about 70 MB of unneeded debugging symbols. Remove those symbols with: -strip --strip-debug /tools/lib/* -/usr/bin/strip --strip-unneeded /tools/{,s}bin/* +$LFS_TGT-strip --strip-debug $LFS/usr/lib/* +$LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/* These commands will skip a number of files, reporting that it does not recognize their file format. Most of these are scripts instead of binaries. - Also use the system strip command to include the strip binary in /tools. + Note that we use the strip program built in + Binutils pass 1, since it is the one that knows how to strip + our cross-compiled programs. + Take care not to use --strip-unneeded on the libraries. The static @@ -29,14 +36,14 @@ To save more, remove the documentation: -rm -rf /tools/{,share}/{info,man,doc} +rm -rf $LFS/usr/{,share}/{info,man,doc} The libtool .la files are only useful when linking with static libraries. They are unneeded, and potentially harmful, when using dynamic shared libraries, specially when using also non-autotools build systems. Remove those files now: -find /tools/{lib,libexec} -name \*.la -delete +find $LFS/usr/{lib,libexec} -name \*.la -delete At this point, you should have at least 3 GB of free space in $LFS that can be used to build and install Glibc and Gcc in diff --git a/chapter05/tar.xml b/chapter05/tar.xml index 002dc228f..26f676121 100644 --- a/chapter05/tar.xml +++ b/chapter05/tar.xml @@ -45,21 +45,18 @@ Prepare Tar for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(build-aux/config.guess) \ + --bindir=/bin Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Tar test suite anyway, issue the following command: - -make check - Install the package: -make install +make DESTDIR=$LFS install diff --git a/chapter05/tcl.xml b/chapter05/tcl.xml index f2265fd8d..bd17a91a8 100644 --- a/chapter05/tcl.xml +++ b/chapter05/tcl.xml @@ -3,6 +3,8 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ %general-entities; + + ]> @@ -46,8 +48,7 @@ installed to support running the test suites for GCC and Binutils and other packages. Installing three packages for testing purposes may seem excessive, but it is very reassuring, if not essential, to know that the - most important tools are working properly. Even if the test suites are not - run in this chapter (they are not mandatory), these packages are required + most important tools are working properly. These packages are required to run the test suites in . Note that the Tcl package used here is a minimal version needed @@ -56,27 +57,54 @@ Prepare Tcl for compilation: -cd unix -./configure --prefix=/tools +SRCDIR=$(pwd) +cd unix +./configure --prefix=/usr \ + --mandir=/usr/share/man \ + $([ "$(uname -m)" = x86_64 ] && echo --enable-64bit) + + + The meaning of the configure options: + + + $([ "$(uname -m)" = x86_64 ] && echo --enable-64bit) + + The construct $(<shell command>) + is replaced by the output of the chell command. Here this output is + empty if running on a 32 bit machine, and is + --enable-64bit if running on a 64 bit machine. + + + + + Build the package: -make +make + +sed -e "s|$SRCDIR/unix|/usr/lib|" \ + -e "s|$SRCDIR|/usr/include|" \ + -i tclConfig.sh + +sed -e "s|$SRCDIR/unix/pkgs/tdbc&tdbc-ver;|/usr/lib/tdbc&tdbc-ver;|" \ + -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;/generic|/usr/include|" \ + -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;/library|/usr/lib/tcl8.6|" \ + -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;|/usr/include|" \ + -i pkgs/tdbc&tdbc-ver;/tdbcConfig.sh - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Tcl test suite anyway, issue the following command: +sed -e "s|$SRCDIR/unix/pkgs/itcl&itcl-ver;|/usr/lib/itcl&itcl-ver;|" \ + -e "s|$SRCDIR/pkgs/itcl&itcl-ver;/generic|/usr/include|" \ + -e "s|$SRCDIR/pkgs/itcl&itcl-ver;|/usr/include|" \ + -i pkgs/itcl&itcl-ver;/itclConfig.sh -TZ=UTC make test +unset SRCDIR - The Tcl test suite may experience failures under certain host - conditions that are not fully understood. Therefore, test suite failures - here are not surprising, and are not considered critical. The - TZ=UTC parameter sets the time zone to Coordinated - Universal Time (UTC), but only - for the duration of the test suite run. This ensures that the clock tests - are exercised correctly. Details on the TZ environment - variable are provided in . + The various sed after the make command + remove references to the build directory from various configuration files, + and replaces them with the install directory. This is not mandatory + for the remaining of LFS, but may be needed in case a package built later + uses Tcl. Install the package: @@ -85,7 +113,7 @@ Make the installed library writable so debugging symbols can be removed later: -chmod -v u+w /tools/lib/libtcl&tcl-major-version;.so +chmod -v u+w /usr/lib/libtcl&tcl-major-version;.so Install Tcl's headers. The next package, Expect, requires them to build. @@ -94,7 +122,7 @@ Now make a necessary symbolic link: -ln -sv tclsh&tcl-major-version; /tools/bin/tclsh +ln -sfv tclsh&tcl-major-version; /usr/bin/tclsh diff --git a/chapter05/texinfo.xml b/chapter05/texinfo.xml index 3e5ecfaef..2cb7764cb 100644 --- a/chapter05/texinfo.xml +++ b/chapter05/texinfo.xml @@ -5,8 +5,8 @@ %general-entities; ]> - - + + texinfo @@ -16,9 +16,9 @@ Texinfo-&texinfo-version; - + Texinfo - tools + temporary @@ -45,7 +45,7 @@ Prepare Texinfo for compilation: -./configure --prefix=/tools +./configure --prefix=/usr As part of the configure process, a test is made that indicates an @@ -57,12 +57,6 @@ make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Texinfo test suite anyway, issue the following command: - -make check - Install the package: make install diff --git a/chapter05/toolchaintechnotes.xml b/chapter05/toolchaintechnotes.xml index e0ab899eb..63c9210e5 100644 --- a/chapter05/toolchaintechnotes.xml +++ b/chapter05/toolchaintechnotes.xml @@ -24,143 +24,312 @@ process has been designed to minimize the risks for new readers and to provide the most educational value at the same time. - - 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 32-bit Intel processor the - output will be i686-pc-linux-gnu. On a 64-bit - system it will be x86_64-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 (ld-linux-x86-64.so.2 for 64-bit systems). 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 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. - - - The temporary libraries are cross-compiled. Because a - cross-compiler by its nature cannot rely on anything from its host - system, this method removes potential contamination of the target - system by lessening the chance of headers or libraries from the host - being incorporated into the new tools. Cross-compilation also allows for - the possibility of building both 32-bit and 64-bit libraries on 64-bit - capable hardware. - - - Careful manipulation of the GCC source tells the compiler which target - dynamic linker will be used. - - - - Binutils is installed first because the configure - runs of both GCC and Glibc perform various feature tests on the assembler - and linker to determine which software features to enable or disable. This - is more important than one might first realize. An incorrectly configured - GCC or Glibc can result in a subtly broken toolchain, where the impact of - such breakage might not show up until near the end of the build of an - entire distribution. A test suite failure will usually highlight this error - before too much additional work is performed. - - Binutils installs its assembler and linker in two locations, - /tools/bin and /tools/$LFS_TGT/bin. The tools in one - location are hard linked to the other. An important facet of the linker is - its library search order. Detailed information can be obtained from - ld by passing it the --verbose - flag. For example, an ld --verbose | grep SEARCH - will illustrate the current search paths and their order. It shows which - files are linked by ld by compiling a dummy program and - passing the --verbose switch to the linker. For example, - gcc dummy.c -Wl,--verbose 2>&1 | grep succeeded - will show all the files successfully opened during the linking. - - The next package installed is GCC. An example of what can be - seen during its run of configure is: - -checking what assembler to use... /tools/i686-lfs-linux-gnu/bin/as -checking what linker to use... /tools/i686-lfs-linux-gnu/bin/ld - - This is important for the reasons mentioned above. It also demonstrates - that GCC's configure script does not search the PATH directories to find which - tools to use. However, during the actual operation of gcc - itself, the same search paths are not necessarily used. To find out which - standard linker gcc will use, run: - gcc -print-prog-name=ld. - - Detailed information can be obtained from gcc by - passing it the -v command line option while compiling - a dummy program. For example, gcc -v dummy.c will show - detailed information about the preprocessor, compilation, and assembly stages, - including gcc's included search paths and their order. - - Next installed are sanitized Linux API headers. These allow the standard - C library (Glibc) to interface with features that the Linux kernel will - provide. - - The next package installed is Glibc. The most important considerations - for building Glibc are the compiler, binary tools, and kernel headers. The - compiler is generally not an issue since Glibc will always use the compiler - relating to the --host parameter passed to its - configure script; e.g. in our case, the compiler will be - i686-lfs-linux-gnu-gcc. The binary tools and kernel - headers can be a bit more complicated. Therefore, take no risks and use the - available configure switches to enforce the correct selections. After the run - of configure, check the contents of the - config.make file in the glibc-build directory for all important details. - Note the use of CC="i686-lfs-gnu-gcc" to control which - binary tools are used and the use of the -nostdinc and - -isystem flags to control the compiler's include - search path. These items highlight an important aspect of the Glibc - package—it is very self-sufficient in terms of its build machinery and - generally does not rely on toolchain defaults. - - During the second pass of Binutils, we are able to utilize the - --with-lib-path configure switch to control - ld's library search path. - - For the second pass of GCC, its sources also need to be modified to - tell GCC to use the new dynamic linker. Failure to do so will result in the - GCC programs themselves having the name of the dynamic linker from the host - system's /lib directory embedded into - them, which would defeat the goal of getting away from the host. From this - point onwards, the core toolchain is self-contained and self-hosted. The - remainder of the packages all build - against the new Glibc in /tools. - - Upon entering the chroot environment in , the first major package to be - installed is Glibc, due to its self-sufficient nature mentioned above. - Once this Glibc is installed into /usr, we will perform a quick changeover of the - toolchain defaults, and then proceed in building the rest of the target - LFS system. + The build process is based on the process of + cross-compilation. Cross-compilation is normally used + for building a compiler and its toolchain for a machine different from + the one that is used for the build. This is not strictly needed for LFS, + since the machine where the new system will run is the same as the one + used for the build. But cross-compilation has the great advantage that + anything that is cross-compiled cannot depend on the host environment. + + + + About Cross-Compilation + + Cross-compilation involves some concepts that deserve a section on + their own. Although this section may be omitted in a first reading, it + is strongly suggested to come back to it later in order to get a full + grasp of the build process. + + Let us first define some terms used in this context: + + + build + is the machine where we build programs. Note that this machine + is referred to as the host in other + sections. + + + host + is the machine/system where the built programs will run. Note + that this use of host is not the same as in other + sections. + + + target + is only used for compilers. It is the machine the compiler + produces code for. It may be different from both build and + host. + + + + + As an example, let us imagine the following scenario: we may have a + compiler on a slow machine only, let's call the machine A, and the compiler + ccA. We may have also a fast machine (B), but with no compiler, and we may + want to produce code for a another slow machine (C). Then, to build a + compiler for machine C, we would have three stages: + + + + + + + + + + StageBuildHost + TargetAction + + + + 1AAB + build cross-compiler cc1 using ccA on machine A + + + 2ABB + build cross-compiler cc2 using cc1 on machine A + + + 3BCC + build compiler ccC using cc2 on machine B + + + + + + Then, all the other programs needed by machine C can be compiled + using cc2 on the fast machine B. Note that unless B can run programs + produced for C, there is no way to test the built programs until machine + C itself is running. For example, for testing ccC, we may want to add a + fourth stage: + + + + + + + + + + StageBuildHost + TargetAction + + + + 4CCC + rebuild and test ccC using itself on machine C + + + + + + In the example above, only cc1 and cc2 are cross-compilers, that is, + they produce code for a machine different from the one they are run on. + The other compilers ccA and ccC produce code for the machine they are run + on. Such compilers are called native compilers. + + + + + Implementation of Cross-Compilation for LFS + + + Almost all the build systems use names of the form + cpu-vendor-kernel-os referred to as the machine triplet. An astute + reader may wonder why a triplet refers to a four component + name. The reason is history: initially, three component names were enough + to designate unambiguously a machine, but with new machines and systems + appearing, that proved insufficient. The word triplet + remained. A simple way to determine your machine 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 32-bit Intel processor the + output will be i686-pc-linux-gnu. On a 64-bit + system it will be x86_64-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 (ld-linux-x86-64.so.2 for 64-bit systems). 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. + + + In order to fake a cross compilation, the name of the host triplet + is slightly adjusted by changing the "vendor" field in the + LFS_TGT variable. We also use the + --with-sysroot when building the cross linker and + cross compiler, to tell them where to find the needed host files. This + ensures none of the other programs built in can link to libraries on the build + machine. Only two stages are mandatory, and one more for tests: + + + + + + + + + + StageBuildHost + TargetAction + + + + 1pcpclfs + build cross-compiler cc1 using cc-pc on pc + + + 2pclfslfs + build compiler cc-lfs using cc1 on pc + + + 3lfslfslfs + rebuild and test cc-lfs using itself on lfs + + + + + + In the above table, on pc means the commands are run + on a machine using the already installed distribution. On + lfs means the commands are run in a chrooted environment. + + Now, there is more about cross-compiling: the C language is not + just a compiler, but also defines a standard library. In this book, the + GNU C library, named glibc, is used. This library must + be compiled for the lfs machine, that is, using the cross compiler cc1. + But the compiler itself uses an internal library implementing complex + instructions not available in the assembler instruction set. This + internal library is named libgcc, and must be linked to the glibc + library to be fully functional! Furthermore, the standard library for + C++ (libstdc++) also needs being linked to glibc. The solution + to this chicken and egg problem is to first build a degraded cc1+libgcc, + lacking some fuctionalities such as threads and exception handling, then + build glibc using this degraded compiler (glibc itself is not + degraded), then build libstdc++. But this last library will lack the + same functionalities as libgcc. + + This is not the end of the story: the conclusion of the preceding + paragraph is that cc1 is unable to build a fully functional libstdc++, but + this is the only compiler available for building the C/C++ libraries + during stage 2! Of course, the compiler built during stage 2, cc-lfs, + would be able to build those libraries, but (i) the build system of + gcc does not know that it is usable on pc, and (ii) using it on pc + would be at risk of linking to the pc libraries, since cc-lfs is a native + compiler. So we have to build libstdc++ later, in chroot. + + + + + + Other procedural details + + The cross-compiler will be installed in a separate $LFS/tools directory, since it will not + be part of the final system. + + Binutils is installed first because the configure + runs of both GCC and Glibc perform various feature tests on the assembler + and linker to determine which software features to enable or disable. This + is more important than one might first realize. An incorrectly configured + GCC or Glibc can result in a subtly broken toolchain, where the impact of + such breakage might not show up until near the end of the build of an + entire distribution. A test suite failure will usually highlight this error + before too much additional work is performed. + + Binutils installs its assembler and linker in two locations, + $LFS/tools/bin and $LFS/tools/$LFS_TGT/bin. The tools in one + location are hard linked to the other. An important facet of the linker is + its library search order. Detailed information can be obtained from + ld by passing it the --verbose + flag. For example, $LFS_TGT-ld --verbose | grep SEARCH + will illustrate the current search paths and their order. It shows which + files are linked by ld by compiling a dummy program and + passing the --verbose switch to the linker. For + example, + $LFS_TGT-gcc dummy.c -Wl,--verbose 2>&1 | grep succeeded + will show all the files successfully opened during the linking. + + The next package installed is GCC. An example of what can be + seen during its run of configure is: + +checking what assembler to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/as +checking what linker to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/ld + + This is important for the reasons mentioned above. It also + demonstrates that GCC's configure script does not search the PATH + directories to find which tools to use. However, during the actual + operation of gcc itself, the same search paths are not + necessarily used. To find out which standard linker gcc + will use, run: $LFS_TGT-gcc -print-prog-name=ld. + + Detailed information can be obtained from gcc by + passing it the -v command line option while compiling + a dummy program. For example, gcc -v dummy.c will show + detailed information about the preprocessor, compilation, and assembly + stages, including gcc's included search paths and their + order. + + Next installed are sanitized Linux API headers. These allow the + standard C library (Glibc) to interface with features that the Linux + kernel will provide. + + The next package installed is Glibc. The most important + considerations for building Glibc are the compiler, binary tools, and + kernel headers. The compiler is generally not an issue since Glibc will + always use the compiler relating to the --host + parameter passed to its configure script; e.g. in our case, the compiler + will be $LFS_TGT-gcc. The binary tools and kernel + headers can be a bit more complicated. Therefore, take no risks and use + the available configure switches to enforce the correct selections. After + the run of configure, check the contents of the + config.make file in the build directory for all important details. + Note the use of CC="$LFS_TGT-gcc" (with + $LFS_TGT expanded) to control which binary tools are used + and the use of the -nostdinc and + -isystem flags to control the compiler's include + search path. These items highlight an important aspect of the Glibc + package—it is very self-sufficient in terms of its build machinery + and generally does not rely on toolchain defaults. + + As said above, the standard C++ library is compiled next, followed + by all the programs that need themselves to be built. The install step + uses the DESTDIR variable to have the programs land into + the LFS filesystem. + + Then the native lfs compiler is built. First Binutils Pass 2, with + the same DESTDIR install as the other programs, then the + second pass of GCC, omitting libstdc++ and other non-important libraries. + Due to some weird logic in GCC's configure script, + CC_FOR_TARGET ends up as cc when host + is the same as target, but is different from build. This is why + CC_FOR_TARGET=$LFS_TGT-gcc is put explicitely into + the configure options. + + Upon entering the chroot environment in , the first task is to install + libstdc++. Then temporary installations of programs needed for the proper + operation of the toolchain are performed. Programs needed for testing + other programs are also built. From this point onwards, the + core toolchain is self-contained and self-hosted. In the remainder of + the , final versions of all the + packages needed for a fully functional system are built, tested and + installed. + + diff --git a/chapter05/util-linux.xml b/chapter05/util-linux.xml index b164fa2db..6aebad7a1 100644 --- a/chapter05/util-linux.xml +++ b/chapter05/util-linux.xml @@ -41,66 +41,55 @@ Installation of Util-linux - Prepare Util-linux for compilation: + First create a directory + to enable storage for the hwclock program: -./configure --prefix=/tools \ - --without-python \ - --disable-makeinstall-chown \ - --without-systemdsystemunitdir \ - --without-ncurses \ - PKG_CONFIG="" +mkdir -pv /var/lib/hwclock - - The meaning of the configure option: + Prepare Util-linux for compilation: - - --without-python - - This switch disables using Python - if it is installed on the host system. It avoids trying to build - unneeded bindings. - - +./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ + --docdir=/usr/share/doc/util-linux-&util-linux-version; \ + --disable-chfn-chsh \ + --disable-login \ + --disable-nologin \ + --disable-su \ + --disable-setpriv \ + --disable-runuser \ + --disable-pylibmount \ + --disable-static \ + --without-python + + The meaning of the configure options: + - --disable-makeinstall-chown + ADJTIME_PATH=/var/lib/hwclock/adjtime - This switch disables using the chown command - during installation. This is not needed when installing into the - /tools directory and avoids the necessity of installing as - root. + This sets the location of the file recording information about + the hardware clock, in accordance to the FHS. This is not stricly + needed fot his temporary tool, but it prevent creating a file + at another location, which would not be overwritten or removed + when building the final util-linux. - --without-ncurses + --disable-* - This switch disables using the ncurses library for - the build process. This is not needed when installing into the - /tools directory and avoids problems on some host distros. + Those switches prevent warnings about building components + that require packages not in LFS or not installed yet. - --without-systemdsystemunitdir + --without-python - On systems that use systemd, the package tries to install - a systemd specific file to a non-existent directory in /tools. - This switch disables the unnecessary action. + This switch disables using Python. + It avoids trying to build unneeded bindings. - - PKG_CONFIG="" - - Setting this environment variable prevents adding unneeded - features that may be available on the host. Note that the location - shown for setting this environment variable is different from other - LFS sections where variables are set preceding the command. This - location is shown to demonstrate an alternative way of setting an - environment variable when using configure. - - Compile the package: diff --git a/chapter05/xz.xml b/chapter05/xz.xml index ea1ea4966..83e4a96d6 100644 --- a/chapter05/xz.xml +++ b/chapter05/xz.xml @@ -45,29 +45,32 @@ Prepare Xz for compilation: -./configure --prefix=/tools +./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(build-aux/config.guess) \ + --disable-static \ + --docdir=/usr/share/doc/xz-&xz-version; Compile the package: make - Compilation is now complete. As discussed earlier, running the test - suite is not mandatory for the temporary tools here in this chapter. To run - the Xz test suite anyway, issue the following command: + Install the package: -make check +make DESTDIR=$LFS install - Install the package: + Make sure that all essential files are in the correct directory: -make install +mv -v $LFS/usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} $LFS/bin +mv -v $LFS/usr/lib/liblzma.so.* $LFS/lib +ln -svf ../../lib/$(readlink $LFS/usr/lib/liblzma.so) $LFS/usr/lib/liblzma.so - - <para>Details on this package are located in - <xref linkend="contents-xz" role="."/></para> + <para>Details on this package are located in<!-- TODO + <xref linkend="contents-xz" role="."/> --></para> </sect2> diff --git a/chapter06/acl.xml b/chapter06/acl.xml index cb5be400e..f9f2eddbe 100644 --- a/chapter06/acl.xml +++ b/chapter06/acl.xml @@ -50,7 +50,8 @@ --libexecdir=/usr/lib \ --docdir=/usr/share/doc/acl-&acl-version;</userinput></screen> -<screen revision="systemd"><userinput remap="configure">./configure --prefix=/usr \ +<screen revision="systemd"><userinput remap="configure"> +./configure --prefix=/usr \ --disable-static \ --libexecdir=/usr/lib \ --docdir=/usr/share/doc/acl-&acl-version;</userinput></screen> diff --git a/chapter06/attr.xml b/chapter06/attr.xml index de93a2b43..10c6eec53 100644 --- a/chapter06/attr.xml +++ b/chapter06/attr.xml @@ -43,13 +43,15 @@ <para>Prepare Attr for compilation:</para> -<screen revision="sysv"><userinput remap="configure">./configure --prefix=/usr \ +<screen revision="sysv"><userinput remap="configure"> +./configure --prefix=/usr \ --bindir=/bin \ --disable-static \ --sysconfdir=/etc \ --docdir=/usr/share/doc/attr-&attr-version;</userinput></screen> -<screen revision="systemd"><userinput remap="configure">./configure --prefix=/usr \ +<screen revision="systemd"><userinput remap="configure"> +./configure --prefix=/usr \ --disable-static \ --sysconfdir=/etc \ --docdir=/usr/share/doc/attr-&attr-version;</userinput></screen> diff --git a/chapter06/bc.xml b/chapter06/bc.xml index f78bd270e..d848ad365 100644 --- a/chapter06/bc.xml +++ b/chapter06/bc.xml @@ -40,62 +40,18 @@ <sect2 role="installation"> <title>Installation of Bc - + Prepare Bc for compilation: - + PREFIX=/usr CC=gcc CFLAGS="-std=c99" ./configure.sh -G -O3 The meaning of the configure options: - + CC=gcc CFLAGS="-std=c99" - These parameters specify the compiler and C standard to use. + These parameters specify the compiler and the C standard to use. @@ -118,14 +74,6 @@ ln -sfv libncursesw.so.6 /usr/lib/libncurses.so Compile the package: make - To test bc, run: diff --git a/chapter06/bzip2.xml b/chapter06/bzip2.xml index 761bd7abb..c42096ea3 100644 --- a/chapter06/bzip2.xml +++ b/chapter06/bzip2.xml @@ -90,10 +90,7 @@ make clean cp -v bzip2-shared /bin/bzip2 cp -av libbz2.so* /lib -ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so -rm -v /usr/bin/{bunzip2,bzcat,bzip2} -ln -sv bzip2 /bin/bunzip2 -ln -sv bzip2 /bin/bzcat +rm -v /usr/bin/{bunzip2,bzcat,bzip2} diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index 346df82cd..9a5ca1fc5 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -12,15 +12,11 @@ Installing Basic System Software - - - - - + + - diff --git a/chapter06/check.xml b/chapter06/check.xml index e7936f6b2..bd4306b28 100644 --- a/chapter06/check.xml +++ b/chapter06/check.xml @@ -56,11 +56,9 @@ Note that the Check test suite may take a relatively long (up to 4 SBU) time. - Install the package and fix a script: + Install the package: - make docdir=/usr/share/doc/check-&check-version; install && -sed -i '1 s/tools/usr/' /usr/bin/checkmk - + make docdir=/usr/share/doc/check-&check-version; install diff --git a/chapter06/chroot.xml b/chapter06/chroot.xml deleted file mode 100644 index c4a66bf00..000000000 --- a/chapter06/chroot.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - %general-entities; -]> - - - - - Entering the Chroot Environment - - It is time to enter the chroot environment to begin building and - installing the final LFS system. As user root, run the following command to enter the - realm that is, at the moment, populated with only the temporary tools: - -chroot "$LFS" /tools/bin/env -i \ - HOME=/root \ - TERM="$TERM" \ - PS1='(lfs chroot) \u:\w\$ ' \ - PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ - /tools/bin/bash --login +h - - The -i option given to the env - command will clear all variables of the chroot environment. After that, only - the HOME, TERM, PS1, and - PATH variables are set again. The - TERM=$TERM construct will set the TERM - variable inside chroot to the same value as outside chroot. This variable is - needed for programs like vim and less - to operate properly. If other variables are needed, such as - CFLAGS or CXXFLAGS, this is a good place to set - them again. - - From this point on, there is no need to use the - LFS variable anymore, because all work will be restricted - to the LFS file system. This is because the Bash shell is told that - $LFS is now the root - (/) directory. - - Notice that /tools/bin comes last - in the PATH. This means that a temporary tool will no longer be - used once its final version is installed. This occurs when the shell does not - remember the locations of executed binaries—for this - reason, hashing is switched off by passing the +h option - to bash. - - Note that the bash prompt will say - I have no name! This is normal because the - /etc/passwd file has not been created yet. - - - It is important that all the commands throughout the remainder of this - chapter and the following chapters are run from within the chroot - environment. If you leave this environment for any reason (rebooting for - example), ensure that the virtual kernel filesystems are mounted as - explained in and and enter chroot again before continuing - with the installation. - - - diff --git a/chapter06/coreutils.xml b/chapter06/coreutils.xml index 42ea98b0d..f383623a2 100644 --- a/chapter06/coreutils.xml +++ b/chapter06/coreutils.xml @@ -123,8 +123,7 @@ FORCE_UNSAFE_CONFIGURE=1 ./configure \ chown -Rv nobody . - Now run the tests. Make sure the PATH in the su - environment includes /tools/bin. + Now run the tests: su nobody -s /bin/bash \ -c "PATH=$PATH make RUN_EXPENSIVE_TESTS=yes check" diff --git a/chapter06/createfiles.xml b/chapter06/createfiles.xml deleted file mode 100644 index ac2805597..000000000 --- a/chapter06/createfiles.xml +++ /dev/null @@ -1,365 +0,0 @@ - - - %general-entities; -]> - - - - - Creating Essential Files and Symlinks - - - /etc/passwd - - - - /etc/group - - - - /var/run/utmp - - - - /var/log/btmp - - - - /var/log/lastlog - - - - /var/log/wtmp - - - Some programs use hard-wired paths to programs which do not exist yet. - In order to satisfy these programs, create a number of symbolic links which - will be replaced by real files throughout the course of this chapter after the - software has been installed: - -ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin -ln -sv /tools/bin/{env,install,perl,printf} /usr/bin -ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib -ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib -ln -sv /tools/lib/libfl.so* /usr/lib - -ln -sv bash /bin/sh - -for lib in blkid mount uuid fdisk -do - ln -sv /tools/lib/lib$lib.so* /usr/lib - sed 's|/tools|/usr|' /tools/lib/pkgconfig/${lib}.pc \ - > /usr/lib/pkgconfig/${lib}.pc -done -for incdir in blkid libmount uuid libfdisk -do - ln -svf /tools/include/$incdir /usr/include -done - - - The purpose of each link: - - - /bin/bash - - Many bash scripts specify - /bin/bash. - - - - - /bin/cat - - This pathname is hard-coded into Glibc's configure script. - - - - - /bin/dd - - The path to dd will be hard-coded into the - /usr/bin/libtool utility. - - - - - /bin/echo - - This is to satisfy one of the tests in Glibc's test suite, which - expects /bin/echo. - - - - - /usr/bin/env - - This pathname is hard-coded into some packages build procedures. - - - - - - /usr/bin/install - - The path to install will be hard-coded into - the /usr/lib/bash/Makefile.inc file. - - - - - /bin/ln - - The path to ln will be hard-coded into the - /usr/lib/perl5/&perl-version;/<target-triplet>/Config_heavy.pl - file. - - - - - /bin/pwd - - Some configure scripts, particularly Glibc's, - have this pathname hard-coded. - - - - - /bin/rm - - The path to rm will be hard-coded into the - /usr/lib/perl5/&perl-version;/<target-triplet>/Config_heavy.pl - file. - - - - - /bin/stty - - This pathname is hard-coded into Expect, therefore it is needed - for Binutils and GCC test suites to pass. - - - - - /usr/bin/perl - - Many Perl scripts hard-code this path to the - perl program. - - - - - /usr/lib/libgcc_s.so{,.1} - - Glibc needs this for the pthreads library to work. - - - - - /usr/lib/libstdc++{,.6} - - This is needed by several tests in Glibc's test suite, as well as - for C++ support in GMP. - - - - - /bin/sh - - Many shell scripts hard-code /bin/sh. - - - - - - /usr/lib/libfl.so* - - - This link allows binutils to find the flex library, and to - build enhanced versions of ar and ranlib. - - - - - - - /usr/lib/lib{blkid,fdisk,mount,uuid}.so*, - /usr/include/{blkid,libfdisk,libmount,uuid}, - /usr/lib/pkgconfig/{blkid,fdisk,mount,uuid}.pc - - - - These links and files allow - eudev - systemd to find the - util-linux libraries installed in chapter 5, without creating - wrong references to /tools. The uuid library is also needed for - building a python module. - - - - - - Historically, Linux maintains a list of the mounted file systems in the - file /etc/mtab. Modern kernels maintain this list - internally and exposes it to the user via the /proc filesystem. To satisfy utilities that - expect the presence of /etc/mtab, create the following - symbolic link: - -ln -sv /proc/self/mounts /etc/mtab - - In order for user root to be - able to login and for the name root to be recognized, there - must be relevant entries in the /etc/passwd and - /etc/group files. - - Create the /etc/passwd file by running the following - command: - -cat > /etc/passwd << "EOF" -root:x:0:0:root:/root:/bin/bash -bin:x:1:1:bin:/dev/null:/bin/false -daemon:x:6:6:Daemon User:/dev/null:/bin/false -messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false -nobody:x:99:99:Unprivileged User:/dev/null:/bin/false -EOF - -cat > /etc/passwd << "EOF" -root:x:0:0:root:/root:/bin/bash -bin:x:1:1:bin:/dev/null:/bin/false -daemon:x:6:6:Daemon User:/dev/null:/bin/false -messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false -systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false -systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false -systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false -systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false -systemd-network:x:76:76:systemd Network Management:/:/bin/false -systemd-resolve:x:77:77:systemd Resolver:/:/bin/false -systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false -systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false -nobody:x:99:99:Unprivileged User:/dev/null:/bin/false -EOF - - The actual password for root - (the x used here is just a placeholder) will be set later. - - Create the /etc/group file by running the following - command: - -cat > /etc/group << "EOF" -root:x:0: -bin:x:1:daemon -sys:x:2: -kmem:x:3: -tape:x:4: -tty:x:5: -daemon:x:6: -floppy:x:7: -disk:x:8: -lp:x:9: -dialout:x:10: -audio:x:11: -video:x:12: -utmp:x:13: -usb:x:14: -cdrom:x:15: -adm:x:16: -messagebus:x:18: -input:x:24: -mail:x:34: -kvm:x:61: -wheel:x:97: -nogroup:x:99: -users:x:999: -EOF - -cat > /etc/group << "EOF" -root:x:0: -bin:x:1:daemon -sys:x:2: -kmem:x:3: -tape:x:4: -tty:x:5: -daemon:x:6: -floppy:x:7: -disk:x:8: -lp:x:9: -dialout:x:10: -audio:x:11: -video:x:12: -utmp:x:13: -usb:x:14: -cdrom:x:15: -adm:x:16: -messagebus:x:18: -systemd-journal:x:23: -input:x:24: -mail:x:34: -kvm:x:61: -systemd-bus-proxy:x:72: -systemd-journal-gateway:x:73: -systemd-journal-remote:x:74: -systemd-journal-upload:x:75: -systemd-network:x:76: -systemd-resolve:x:77: -systemd-timesync:x:78: -systemd-coredump:x:79: -wheel:x:97: -nogroup:x:99: -users:x:999: -EOF - - The created groups are not part of any standard—they are groups - decided on in part by the requirements of the Udev configuration in this - chapter, and in part by common convention employed by a number of existing - Linux distributions. In addition, some test suites rely on specific users - or groups. The Linux Standard Base (LSB, available at ) recommends only that, besides the group - root with a Group ID (GID) of 0, - a group bin with a GID of 1 be - present. All other group names and GIDs can be chosen freely by the system - administrator since well-written programs do not depend on GID numbers, but - rather use the group's name. - - To remove the I have no name! prompt, start a new - shell. Since a full Glibc was installed in and the - /etc/passwd and /etc/group - files have been created, user name and group name resolution will now - work: - -exec /tools/bin/bash --login +h - - Note the use of the +h directive. This tells - bash not to use its internal path hashing. Without this - directive, bash would remember the paths to binaries it has - executed. To ensure the use of the newly compiled binaries as soon as they are - installed, the +h directive will be used for the duration - of this chapter. - - The login, agetty, and - init programs (and others) use a number of log - files to record information such as who was logged into the system and - when. However, these programs will not write to the log files if they - do not already exist. Initialize the log files and give them - proper permissions: - -touch /var/log/{btmp,lastlog,faillog,wtmp} -chgrp -v utmp /var/log/lastlog -chmod -v 664 /var/log/lastlog -chmod -v 600 /var/log/btmp - - The /var/log/wtmp file records all logins and - logouts. The /var/log/lastlog file records when each - user last logged in. The /var/log/faillog file records - failed login attempts. The /var/log/btmp file records - the bad login attempts. - - The /run/utmp file records the users that - are currently logged in. This file is created dynamically in the boot - scripts. - - diff --git a/chapter06/creatingdirs.xml b/chapter06/creatingdirs.xml deleted file mode 100644 index 129e94f18..000000000 --- a/chapter06/creatingdirs.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - %general-entities; -]> - - - - - Creating Directories - - It is time to create some structure in the LFS file system. Create a - standard directory tree by issuing the following commands: - -mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt} -mkdir -pv /{media/{floppy,cdrom},sbin,srv,var} -install -dv -m 0750 /root -install -dv -m 1777 /tmp /var/tmp -mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src} -mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man} -mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo} -mkdir -v /usr/libexec -mkdir -pv /usr/{,local/}share/man/man{1..8} -mkdir -v /usr/lib/pkgconfig - -case $(uname -m) in - x86_64) mkdir -v /lib64 ;; -esac - -mkdir -v /var/{log,mail,spool} -ln -sv /run /var/run -ln -sv /run/lock /var/lock -mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local} - - Directories are, by default, created with permission mode 755, but - this is not desirable for all directories. In the commands above, two - changes are made—one to the home directory of user root, and another to the directories for - temporary files. - - The first mode change ensures that not just anybody can enter - the /root directory—the - same as a normal user would do with his or her home directory. The - second mode change makes sure that any user can write to the - /tmp and /var/tmp directories, but cannot remove - another user's files from them. The latter is prohibited by the so-called - sticky bit, the highest bit (1) in the 1777 bit mask. - - - FHS Compliance Note - - The directory tree is based on the Filesystem Hierarchy Standard - (FHS) (available at ). The FHS also specifies - the optional existence of some directories such as /usr/local/games and /usr/share/games. We create only the - directories that are needed. However, feel free to create these - directories. - - - - diff --git a/chapter06/e2fsprogs.xml b/chapter06/e2fsprogs.xml index 08612ab3f..daa9bb91f 100644 --- a/chapter06/e2fsprogs.xml +++ b/chapter06/e2fsprogs.xml @@ -52,11 +52,6 @@ cd build Prepare E2fsprogs for compilation: - ../configure --prefix=/usr \ --bindir=/bin \ --with-root-prefix="" \ @@ -68,15 +63,7 @@ PKG_CONFIG_PATH=/tools/lib/pkgconfig \ The meaning of the environment variable and configure options: - + --with-root-prefix="" and --bindir=/bin @@ -117,17 +104,10 @@ PKG_CONFIG_PATH=/tools/lib/pkgconfig \ Compile the package: make - To run the tests, issue: make check - - One of the E2fsprogs tests will attempt to allocate 256 MB of memory. If you do not have significantly more RAM than this, be sure to enable diff --git a/chapter06/flex.xml b/chapter06/flex.xml index 2e12dabac..7bd8954ac 100644 --- a/chapter06/flex.xml +++ b/chapter06/flex.xml @@ -50,7 +50,7 @@ This is not present, so we use an environment variable to skip this process. Now, prepare Flex for compilation: -HELP2MAN=/tools/bin/true \ +HELP2MAN=/bin/true \ ./configure --prefix=/usr --docdir=/usr/share/doc/flex-&flex-version; Compile the package: diff --git a/chapter06/gcc.xml b/chapter06/gcc.xml index a9c8fa16c..952e3cca7 100644 --- a/chapter06/gcc.xml +++ b/chapter06/gcc.xml @@ -58,8 +58,8 @@ cd build Prepare GCC for compilation: -SED=sed \ -../configure --prefix=/usr \ +../configure --prefix=/usr \ + LD=ld \ --enable-languages=c,c++ \ --disable-multilib \ --disable-bootstrap \ @@ -71,25 +71,8 @@ cd build for instructions on how to build all of GCC's supported languages. - The meaning of the new configure parameters: + The meaning of the new configure parameter: - - SED=sed - - Setting this environment variable prevents a hard-coded - path to /tools/bin/sed. - - - --with-system-zlib @@ -170,12 +153,12 @@ rm -rf /usr/lib/gcc/$(gcc -dumpmachine)/&gcc-version;/include-fixed/bits/ ln -sv ../usr/bin/cpp /lib - + Add a compatibility symlink to enable building programs with Link Time Optimization (LTO): diff --git a/chapter06/glibc.xml b/chapter06/glibc.xml index d1e8086b2..a422c8d3c 100644 --- a/chapter06/glibc.xml +++ b/chapter06/glibc.xml @@ -43,13 +43,6 @@ Installation of Glibc - The Glibc build system is self-contained and will install - perfectly, even though the compiler specs file and linker are still - pointing to /tools. The specs - and linker cannot be adjusted before the Glibc install because the - Glibc autoconf tests would give false results and defeat the goal - of achieving a clean build. - Some of the Glibc programs use the non-FHS compliant /var/db directory to store their runtime data. Apply the following patch to make such programs @@ -66,7 +59,7 @@ sed -i '/asm.socket.h/a# include <linux/sockios.h>' \ sysdeps/unix/sysv/linux/bits/socket.h ---> +=== already done === Create a symlink for LSB compliance. Additionally, for x86_64, create a compatibility symlink required for the dynamic loader to function correctly: @@ -78,7 +71,7 @@ ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3 ;; esac - + The meaning of the options and new configure parameters: - CC="gcc -ffile-prefix-map=/tools=/usr" + CC="gcc -ffile-prefix-map=$LFS_DIR=$DIR" - Make GCC record any references to files in /tools in result - of the compilation as if the files resided in /usr. This avoids - introduction of invalid paths in debugging symbols. + Make GCC record any references to files in /usr/lib/gcc/x86_64-lfs-linux-gnu + in result of the compilation as if the files resided in /usr/lib/gcc/x86_64-pc-linux-gnu. + This avoids introduction of invalid paths in debugging + symbols. @@ -128,13 +123,12 @@ cd build smashing attacks. - + --with-headers=/usr/include This option tells the build system where to find the - kernel API headers. By default, those headers are sought in - /tools/include. + kernel API headers. diff --git a/chapter06/introduction.xml b/chapter06/introduction.xml index 876112796..c8ccb3908 100644 --- a/chapter06/introduction.xml +++ b/chapter06/introduction.xml @@ -36,15 +36,6 @@ optimizations. The subsequent system will still run very fast and be stable at the same time. - The order that packages are installed in this chapter needs to be - strictly followed to ensure that no program accidentally acquires a path - referring to /tools hard-wired into - it. For the same reason, do not compile separate packages in parallel. - Compiling in parallel may save time (especially on dual-CPU machines), but it - could result in a program containing a hard-wired path to /tools, which will cause the program to stop - working when that directory is removed. - Before the installation instructions, each installation page provides information about the package, including a concise description of what it contains, approximately how long it will take to build, and how much disk diff --git a/chapter06/kbd.xml b/chapter06/kbd.xml index 2bf0853f7..2f9cfd3f1 100644 --- a/chapter06/kbd.xml +++ b/chapter06/kbd.xml @@ -60,20 +60,11 @@ sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in Prepare Kbd for compilation: -PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure --prefix=/usr --disable-vlock +./configure --prefix=/usr --disable-vlock The meaning of the configure options: - + --disable-vlock @@ -104,16 +95,6 @@ sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in such languages have to download working keymaps separately. - If desired, install the documentation: mkdir -v /usr/share/doc/kbd-&kbd-version; diff --git a/chapter06/kernfs.xml b/chapter06/kernfs.xml deleted file mode 100644 index 860cdfc00..000000000 --- a/chapter06/kernfs.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - %general-entities; -]> - - - - - Preparing Virtual Kernel File Systems - - - /dev/* - - - Various file systems exported by the kernel are used to communicate to - and from the kernel itself. These file systems are virtual in that no disk - space is used for them. The content of the file systems resides in - memory. - - Begin by creating directories onto which the file systems will be - mounted: - -mkdir -pv $LFS/{dev,proc,sys,run} - - - Creating Initial Device Nodes - - When the kernel boots the system, it requires the presence of a few - device nodes, in particular the console and null devices. The device nodes must be created - on the hard disk so that they are available before udevd - has been started, and additionally when Linux is started with - init=/bin/bash. Create the devices by running the - following commands: - -mknod -m 600 $LFS/dev/console c 5 1 -mknod -m 666 $LFS/dev/null c 1 3 - - - - - Mounting and Populating /dev - - The recommended method of populating the /dev directory with devices is to mount a - virtual filesystem (such as tmpfs) on the /dev directory, and allow the devices to be - created dynamically on that virtual filesystem as they are detected or - accessed. Device creation is generally done during the boot process - by Udev. Since this new system does not yet have Udev and has not yet - been booted, it is necessary to mount and populate /dev manually. This is accomplished by bind - mounting the host system's /dev - directory. A bind mount is a special type of mount that allows you to - create a mirror of a directory or mount point to some other location. Use - the following command to achieve this: - -mount -v --bind /dev $LFS/dev - - - - - Mounting Virtual Kernel File Systems - - Now mount the remaining virtual kernel filesystems: - -mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620 -mount -vt proc proc $LFS/proc -mount -vt sysfs sysfs $LFS/sys -mount -vt tmpfs tmpfs $LFS/run - - - The meaning of the mount options for devpts: - - - gid=5 - - This ensures that all devpts-created device nodes are owned by - group ID 5. This is the ID we will use later on for the tty group. We use the group ID instead - of a name, since the host system might use a different ID for its - tty group. - - - - - mode=0620 - - This ensures that all devpts-created device nodes have mode 0620 - (user readable and writable, group writable). Together with the - option above, this ensures that devpts will create device nodes that - meet the requirements of grantpt(), meaning the Glibc - pt_chown helper binary (which is not installed by - default) is not necessary. - - - - - - In some host systems, /dev/shm is a - symbolic link to /run/shm. - The /run tmpfs was mounted above so in this case only a - directory needs to be created. - -if [ -h $LFS/dev/shm ]; then - mkdir -pv $LFS/$(readlink $LFS/dev/shm) -fi - - - - diff --git a/chapter06/libpipeline.xml b/chapter06/libpipeline.xml index 6496e792d..eb5a19438 100644 --- a/chapter06/libpipeline.xml +++ b/chapter06/libpipeline.xml @@ -45,22 +45,6 @@ ./configure --prefix=/usr - Compile the package: make diff --git a/chapter06/linux-headers.xml b/chapter06/linux-headers.xml deleted file mode 100644 index f1d4cb14e..000000000 --- a/chapter06/linux-headers.xml +++ /dev/null @@ -1,209 +0,0 @@ - - - %general-entities; -]> - - - - - - linux-headers - &linux-version; -
&linux-url;
-
- - Linux-&linux-version; API Headers - - - Linux - API headers - - - - - - <para>The Linux API Headers (in linux-&linux-version;.tar.xz) expose the - kernel's API for use by Glibc.</para> - - <segmentedlist> - <segtitle>&buildtime;</segtitle> - <segtitle>&diskspace;</segtitle> - - <seglistitem> - <seg>&linux-headers-ch6-sbu;</seg> - <seg>&linux-headers-ch6-du;</seg> - </seglistitem> - </segmentedlist> - - </sect2> - - <sect2 role="installation"> - <title>Installation of Linux API Headers - - The Linux kernel needs to expose an Application Programming Interface - (API) for the system's C library (Glibc in LFS) to use. This is done - by way of sanitizing various C header files that are shipped in the Linux - kernel source tarball. - - Make sure there are no stale files and dependencies lying around - from previous activity: - -make mrproper - - Now extract the user-visible kernel headers from the source. - The recommended make target headers_install cannot be - used, because it requires rsync, which is - not available in /tools. The - headers are first placed in ./usr, - then some files used by the kernel developers are removed, then - the files are copied to their final location. - -make headers -find usr/include -name '.*' -delete -rm usr/include/Makefile -cp -rv usr/include/* /usr/include - - - - - Contents of Linux API Headers - - - Installed headers - Installed directories - - - /usr/include/asm/*.h, /usr/include/asm-generic/*.h, - /usr/include/drm/*.h, /usr/include/linux/*.h, /usr/include/misc/*.h, - /usr/include/mtd/*.h, /usr/include/rdma/*.h, /usr/include/scsi/*.h, - /usr/include/sound/*.h, /usr/include/video/*.h, - and /usr/include/xen/*.h - /usr/include/asm, /usr/include/asm-generic, /usr/include/drm, - /usr/include/linux, /usr/include/misc, /usr/include/mtd, - /usr/include/rdma, /usr/include/scsi, /usr/include/sound, - /usr/include/video, and /usr/include/xen - - - - - Short Descriptions - - - - - /usr/include/asm/*.h - - The Linux API ASM Headers - - /usr/include/asm/*.h - - - - - - /usr/include/asm-generic/*.h - - The Linux API ASM Generic Headers - - /usr/include/asm-generic/*.h - - - - - - /usr/include/drm/*.h - - The Linux API DRM Headers - - /usr/include/drm/*.h - - - - - - /usr/include/linux/*.h - - The Linux API Linux Headers - - /usr/include/linux/*.h - - - - - - /usr/include/misc/*.h - - The Linux API Miscellaneous Headers - - /usr/include/misc/*.h - - - - - - /usr/include/mtd/*.h - - The Linux API MTD Headers - - /usr/include/mtd/*.h - - - - - - /usr/include/rdma/*.h - - The Linux API RDMA Headers - - /usr/include/rdma/*.h - - - - - - /usr/include/scsi/*.h - - The Linux API SCSI Headers - - /usr/include/scsi/*.h - - - - - - /usr/include/sound/*.h - - The Linux API Sound Headers - - /usr/include/sound/*.h - - - - - - /usr/include/video/*.h - - The Linux API Video Headers - - /usr/include/video/*.h - - - - - - /usr/include/xen/*.h - - The Linux API Xen Headers - - /usr/include/xen/*.h - - - - - - - - -
diff --git a/chapter06/readline.xml b/chapter06/readline.xml index bcefab042..87571ea9d 100644 --- a/chapter06/readline.xml +++ b/chapter06/readline.xml @@ -73,13 +73,13 @@ sed -i '/{OLDSUFF}/c:' support/shlib-install
Compile the package: -make SHLIB_LIBS="-L/tools/lib -lncursesw" +make SHLIB_LIBS="-lncursesw" The meaning of the make option: - SHLIB_LIBS="-L/tools/lib -lncursesw" + SHLIB_LIBS="-lncursesw" This option forces Readline to link against the libncursesw library. @@ -92,7 +92,7 @@ sed -i '/{OLDSUFF}/c:' support/shlib-install Install the package: -make SHLIB_LIBS="-L/tools/lib -lncursesw" install +make SHLIB_LIBS="-lncursesw" install Now move the dynamic libraries to a more appropriate location and fix up some permissions and symbolic links: diff --git a/chapter06/revisedchroot.xml b/chapter06/revisedchroot.xml index eb40fb7ce..882fbd3d5 100644 --- a/chapter06/revisedchroot.xml +++ b/chapter06/revisedchroot.xml @@ -26,18 +26,9 @@ chroot "$LFS" /usr/bin/env -i \ PATH=/bin:/usr/bin:/sbin:/usr/sbin \ /bin/bash --login - The reason for this is that the programs in /tools are no longer needed. For this reason - you can delete the /tools - directory if so desired. - - - Removing /tools will also - remove the temporary copies of Tcl, Expect, and DejaGNU which were used - for running the toolchain tests. If you need these programs later on, - they will need to be recompiled and re-installed. The BLFS book has - instructions for this (see ). - + Here the +h option is not used anymore, since + all the previous programs have been replaced: hashing is therefore + possible. If the virtual kernel file systems have been unmounted, either manually or through a reboot, ensure that the virtual kernel file systems are mounted diff --git a/chapter06/sed.xml b/chapter06/sed.xml index aa6ac177c..bebd49d14 100644 --- a/chapter06/sed.xml +++ b/chapter06/sed.xml @@ -42,24 +42,12 @@ First fix an issue in the LFS environment and remove a failing test: -sed -i 's/usr/tools/' build-aux/help2man -sed -i 's/testsuite.panic-tests.sh//' Makefile.in +sed -i 's/testsuite.panic-tests.sh//' Makefile.in Prepare Sed for compilation: ./configure --prefix=/usr --bindir=/bin - Compile the package and generate the HTML documentation: make diff --git a/chapter06/shadow.xml b/chapter06/shadow.xml index 7fd621bdb..425112cbd 100644 --- a/chapter06/shadow.xml +++ b/chapter06/shadow.xml @@ -84,7 +84,8 @@ find man -name Makefile.in -exec sed -i 's/passwd\.5 / /' {} \;Prepare Shadow for compilation: touch /usr/bin/passwd -./configure --sysconfdir=/etc --with-group-name-max-length=32 +./configure --sysconfdir=/etc \ + --with-group-name-max-length=32 The meaning of the configure option: diff --git a/chapter06/strippingagain.xml b/chapter06/strippingagain.xml index eef553173..fb2a1b55f 100644 --- a/chapter06/strippingagain.xml +++ b/chapter06/strippingagain.xml @@ -56,38 +56,22 @@ done unset LIB save_lib save_usrlib - Before performing the stripping, take special care to ensure that + - Now the binaries and libraries can be safely stripped: +--> + Now the binaries and libraries can be stripped: +find /usr/lib -type f -name \*.a \ + -exec strip --strip-debug {} ';' -/tools/bin/find /usr/lib -type f -name \*.a \ - -exec /tools/bin/strip --strip-debug {} ';' - -/tools/bin/find /lib /usr/lib -type f \( -name \*.so* -a ! -name \*dbg \) \ - -exec /tools/bin/strip --strip-unneeded {} ';' +find /lib /usr/lib -type f -name \*.so* ! -name \*dbg \ + -exec strip --strip-unneeded {} ';' -/tools/bin/find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \ - -exec /tools/bin/strip --strip-all {} ';' +find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \ + -exec strip --strip-all {} ';' A large number of files will be reported as having their file format not recognized. These warnings can be safely ignored. These diff --git a/chapter06/systemd.xml b/chapter06/systemd.xml index 1010c43ea..2870c3846 100644 --- a/chapter06/systemd.xml +++ b/chapter06/systemd.xml @@ -48,7 +48,7 @@ Create a symlink to work around missing xsltproc: -ln -sf /tools/bin/true /usr/bin/xsltproc +ln -sf /bin/true /usr/bin/xsltproc Set up the man pages: @@ -101,9 +101,7 @@ meson --prefix=/usr \ -D*-path=* These switches provide location of binaries needed by - systemd at runtime that have not yet been installed, or who's - pkgconfig files are currently only in - /tools/lib/pkgconfig. + systemd at runtime that have not yet been installed. diff --git a/chapter06/util-linux.xml b/chapter06/util-linux.xml index 6a6a5bcc5..bc328e8bb 100644 --- a/chapter06/util-linux.xml +++ b/chapter06/util-linux.xml @@ -54,18 +54,6 @@ Installation of Util-linux - - - Remove the earlier created symlinks and files: - -rm -vf /usr/include/{blkid,libfdisk,libmount,uuid} -rm -vf /usr/lib/lib{blkid,fdisk,mount,uuid}.so* -rm -vf /usr/lib/pkgconfig/{blkid,fdisk,mount,uuid}.pc Prepare Util-linux for compilation: diff --git a/chapter08/kernel.xml b/chapter08/kernel.xml index 0173f7445..0033028cf 100644 --- a/chapter08/kernel.xml +++ b/chapter08/kernel.xml @@ -299,7 +299,7 @@ cp -r Documentation/* /usr/share/doc/linux-&linux-version; class="directory">/usr/include) should always be the ones against which Glibc was compiled, that is, the sanitised headers installed in . Therefore, they should + linkend="ch-tools-linux-headers"/>. Therefore, they should never be replaced by either the raw kernel headers or any other kernel sanitized headers. -- cgit v1.2.3-54-g00ecf