Changeset efcb393
- Timestamp:
- 05/03/2020 09:02:51 PM (3 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, arm, cross-chap5, ml-11.0, multilib, s6-init, trunk, xry111/arm64, xry111/clfs-ng, xry111/git-transition, xry111/glibc-2.34, xry111/glibc-2.37, xry111/kcfg-revise, xry111/lfs-next, xry111/pip3, xry111/queue-11.3, xry111/rust-wip-20221008, xry111/tester-nohack, xry111/usr-move
- Children:
- a715dec
- Parents:
- 9d719e2
- Files:
-
- 2 added
- 1 deleted
- 68 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
chapter01/how.xml
r9d719e2 refcb393 47 47 work your way through <xref linkend="chapter-temporary-tools"/> and beyond.</para> 48 48 49 <para><xref linkend="chapter-temporary-tools"/> explains the 50 installation of a number of packages that will form the basic 51 development suite (or toolchain) which is used to build the actual 52 system in <xref linkend="chapter-building-system"/>. Some of these 53 packages are needed to resolve circular dependencies—for example, 54 to compile a compiler, you need a compiler.</para> 49 <para><xref linkend="chapter-temporary-tools"/> explains the installation of 50 a number of packages that are needed to resolve circular 51 dependencies—for example, to compile a compiler, you need a compiler. 52 or to unpack the tar package, you need tar.</para> 55 53 56 54 <para><xref linkend="chapter-temporary-tools"/> also shows you how to … … 67 65 68 66 <para>This effort to isolate the new system from the host distribution may 69 seem excessive. A full technical explanation as to why this is done is provided in70 <xref linkend="ch-tools-toolchaintechnotes"/>.</para>67 seem excessive. A full technical explanation as to why this is done is 68 provided in <xref linkend="ch-tools-toolchaintechnotes"/>.</para> 71 69 72 <para>In <xref linkend="chapter-building-system"/>, the full LFS system is 73 built. The <command>chroot</command> (change root) program is used to enter 74 a virtual environment and start a new shell whose root directory will be 75 set to the LFS partition. This is very similar to rebooting and instructing 76 the kernel to mount the LFS partition as the root partition. The system 77 does not actually reboot, but instead uses <command>chroot</command> because 78 creating a bootable system requires additional work which is not necessary 79 just yet. The major advantage is that <quote>chrooting</quote> allows you 80 to continue using the host system while LFS is being built. While waiting 81 for package compilations to complete, you can continue using your computer as 82 normal.</para> 70 <para><xref linkend="chapter-building-system"/> begins with installing the 71 remaining packages needed to build and test the final toolchain. Then, the 72 full LFS system is built. But first, the <command>chroot</command> (change 73 root) program is used to enter a virtual environment and start a new shell 74 whose root directory will be set to the LFS partition. This is very similar 75 to rebooting and instructing the kernel to mount the LFS partition as the 76 root partition. The system does not actually reboot, but instead uses 77 <command>chroot</command> because creating a bootable system requires 78 additional work which is not necessary just yet. The major advantage is 79 that <quote>chrooting</quote> allows you to continue using the host system 80 while LFS is being built. While waiting for package compilations to 81 complete, you can continue using your computer as normal.</para> 83 82 84 83 <para>To finish the installation, the basic system configuration is set up in -
chapter02/stages.xml
r9d719e2 refcb393 26 26 <itemizedlist> 27 27 <listitem> 28 29 30 28 <para>Procedures done as the root user after Section 2.4 need to 29 have the LFS environment variable set <emphasis>FOR THE ROOT 30 USER</emphasis>.</para> 31 31 </listitem> 32 32 </itemizedlist> … … 38 38 <itemizedlist> 39 39 <listitem> 40 40 <para>The /mnt/lfs partition must be mounted.</para> 41 41 </listitem> 42 42 43 43 <listitem> 44 <para><emphasis>ALL</emphasis> instructions in Chapter 5 45 must be done by user <emphasis>lfs</emphasis>. 46 A <command>su - lfs</command> needs to be done before any 47 task in Chapter 5.</para> 44 <para>This chapter includes three parts. The first one, from 45 <quote>Binutils Pass1</quote> to <quote>Stripping</quote> 46 must be done by user <emphasis>lfs</emphasis>. A 47 <command>su - lfs</command> needs to be done before any task in this 48 part. The second part, from <quote>Changing Ownership</quote> to 49 <quote>Entering the Chroot Environment</quote> must be done as the 50 root user, with LFS set for the root user. The third part, from 51 <quote>Creating Directories</quote> to the end of the chapter, is done 52 in the chroot environment. The same procedures as for chapter 6 53 apply.</para> 48 54 </listitem> 49 55 -
chapter04/abouttestsuites.xml
r9d719e2 refcb393 26 26 27 27 <note> 28 <para>Experience has shown that there is little to be gained from running 29 the test suites in <xref linkend="chapter-temporary-tools"/>. There can be 30 no escaping the fact that the host system always exerts some influence on 31 the tests in that chapter, often causing inexplicable failures. Because 32 the tools built in <xref linkend="chapter-temporary-tools"/> are temporary 33 and eventually discarded, we do not recommend running the test suites in 34 <xref linkend="chapter-temporary-tools"/> for the average reader. The 35 instructions for running those test suites are provided for the benefit of 36 testers and developers, but they are strictly optional.</para> 28 <para>Running the test suites in <xref linkend="chapter-temporary-tools"/> 29 is impossible, since the programs are compiled with a cross-compiler, 30 so are not supposed to be able to run on the build host.</para> 37 31 </note> 38 32 -
chapter04/addinguser.xml
r9d719e2 refcb393 78 78 79 79 <para>Grant <systemitem class="username">lfs</systemitem> full access to 80 <filename class="directory">$LFS/tools</filename> by making80 all directories under <filename class="directory">$LFS</filename> by making 81 81 <systemitem class="username">lfs</systemitem> the directory owner:</para> 82 82 83 <screen><userinput>chown -v lfs $LFS/ tools</userinput></screen>83 <screen><userinput>chown -v lfs $LFS/{usr,lib,var,etc,bin,sbin,lib64,tools}</userinput></screen> 84 84 85 85 <para>If a separate working directory was created as suggested, give -
chapter04/chapter04.xml
r9d719e2 refcb393 14 14 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="introduction.xml"/> 15 15 <!--<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="aboutlfs.xml"/>--> 16 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creating toolsdir.xml"/>16 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creatingminlayout.xml"/> 17 17 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="addinguser.xml"/> 18 18 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="settingenviron.xml"/> -
chapter04/introduction.xml
r9d719e2 refcb393 12 12 13 13 <para>In this chapter, we will perform a few additional tasks to prepare 14 for building the temporary system. We will create a directoryin14 for building the temporary system. We will create a set of directories in 15 15 <filename class="directory">$LFS</filename> for the installation of the 16 16 temporary tools, add an unprivileged user to reduce risk, -
chapter04/settingenviron.xml
r9d719e2 refcb393 44 44 LC_ALL=POSIX 45 45 LFS_TGT=$(uname -m)-lfs-linux-gnu 46 PATH= /tools/bin:/bin:/usr/bin46 PATH=$LFS/tools/bin:/bin:/usr/bin 47 47 export LFS LC_ALL LFS_TGT PATH</literal> 48 48 EOF</userinput></screen> … … 62 62 the shell will always search the <envar>PATH</envar> when a program is to 63 63 be run. As such, the shell will find the newly compiled tools in 64 <filename class="directory"> $LFS/tools</filename> as soon as they are64 <filename class="directory">~/tools</filename> as soon as they are 65 65 available without remembering a previous version of the same program in a 66 66 different location.</para> … … 109 109 110 110 <varlistentry> 111 <term><parameter>PATH= /tools/bin:/bin:/usr/bin</parameter></term>111 <term><parameter>PATH=$LFS/tools/bin:/bin:/usr/bin</parameter></term> 112 112 <listitem> 113 <para>By putting <filename class="directory"> /tools/bin</filename> ahead of the113 <para>By putting <filename class="directory">$LFS/tools/bin</filename> ahead of the 114 114 standard <envar>PATH</envar>, all the programs installed in <xref 115 115 linkend="chapter-temporary-tools"/> are picked up by the shell immediately after -
chapter05/bash.xml
r9d719e2 refcb393 43 43 <sect2 role="installation"> 44 44 <title>Installation of Bash</title> 45 <!--46 <para>First, apply the following patch to fix various bugs that have been47 addressed upstream:</para>48 45 49 <screen><userinput remap="pre">patch -Np1 -i ../&bash-fixes-patch;</userinput></screen>50 -->51 46 <para>Prepare Bash for compilation:</para> 52 47 53 <screen><userinput remap="configure">./configure --prefix=/tools --without-bash-malloc</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --build=$(support/config.guess) \ 50 --host=$LFS_TGT \ 51 --without-bash-malloc</userinput></screen> 54 52 55 53 <variablelist> … … 73 71 <screen><userinput remap="make">make</userinput></screen> 74 72 75 <para>Compilation is now complete. As discussed earlier, running the test76 suite is not mandatory for the temporary tools here in this chapter. To run77 the Bash test suite anyway, issue the following command:</para>78 79 80 <screen><userinput remap="test">make tests</userinput></screen>81 82 73 <para>Install the package:</para> 83 74 84 <screen><userinput remap="install">make install</userinput></screen> 75 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 76 77 <para>Move the excutable to where it is expected to be:</para> 78 79 <screen><userinput remap="install">mv $LFS/usr/bin/bash $LFS/bin/bash</userinput></screen> 85 80 86 81 <para>Make a link for the programs that use <command>sh</command> for 87 82 a shell:</para> 88 83 89 <screen><userinput remap="install">ln -sv bash /tools/bin/sh</userinput></screen>84 <screen><userinput remap="install">ln -sv bash $LFS/bin/sh</userinput></screen> 90 85 91 86 </sect2> -
chapter05/binutils-pass1.xml
r9d719e2 refcb393 67 67 && make install; }</userinput>.</para> 68 68 </note> 69 69 <!-- 70 70 <note><para>The approximate build SBU values and required disk space 71 71 in Chapter 5 does not include test suite data.</para></note> 72 72 --> 73 73 <para>Now prepare Binutils for compilation:</para> 74 74 75 <screen><userinput remap="configure">../configure --prefix= /tools\75 <screen><userinput remap="configure">../configure --prefix=$LFS/tools \ 76 76 --with-sysroot=$LFS \ 77 --with-lib-path=/tools/lib \78 77 --target=$LFS_TGT \ 79 78 --disable-nls \ … … 84 83 85 84 <varlistentry> 86 <term><parameter>--prefix= /tools</parameter></term>85 <term><parameter>--prefix=$LFS/tools</parameter></term> 87 86 <listitem> 88 87 <para>This tells the configure script to prepare to install the 89 Binutils programs in the <filename class="directory">/tools</filename>90 directory.</para>88 Binutils programs in the <filename 89 class="directory">$LFS/tools</filename> directory.</para> 91 90 </listitem> 92 91 </varlistentry> … … 99 98 </listitem> 100 99 </varlistentry> 101 100 <!-- 102 101 <varlistentry> 103 <term><parameter>- -with-lib-path=/tools/lib</parameter></term>102 <term><parameter>- -with-lib-path=/tools/lib</parameter></term> 104 103 <listitem> 105 104 <para>This specifies which library path the linker should be … … 107 106 </listitem> 108 107 </varlistentry> 109 108 --> 110 109 <varlistentry> 111 110 <term><envar>--target=$LFS_TGT</envar></term> … … 141 140 <screen><userinput remap="make">make</userinput></screen> 142 141 143 <para>Compilation is now complete. Ordinarily we would now run the144 test suite, but at this early stage the test suite framework (Tcl,145 Expect, and DejaGNU) is not yet in place. The benefits of running the146 tests at this point are minimal since the programs from this147 first pass will soon be replaced by those from the second.</para>148 149 <para>If building on x86_64, create a symlink to ensure the sanity of150 the toolchain:</para>151 152 <screen><userinput remap="install">case $(uname -m) in153 x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;;154 esac</userinput></screen>155 156 142 <para>Install the package:</para> 157 143 -
chapter05/binutils-pass2.xml
r9d719e2 refcb393 51 51 <para>Prepare Binutils for compilation:</para> 52 52 53 <screen><userinput remap="configure">CC=$LFS_TGT-gcc \ 54 AR=$LFS_TGT-ar \ 55 RANLIB=$LFS_TGT-ranlib \ 56 ../configure \ 57 --prefix=/tools \ 53 <screen><userinput remap="configure">../configure \ 54 --prefix=/usr \ 55 --build=$(../config.guess) \ 56 --host=$LFS_TGT \ 58 57 --disable-nls \ 59 --disable-werror \ 60 --with-lib-path=/tools/lib \ 61 --with-sysroot</userinput></screen> 58 --enable-shared \ 59 --disable-werror</userinput></screen> 62 60 63 61 <variablelist> … … 65 63 66 64 <varlistentry> 67 <term><parameter> CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib</parameter></term>65 <term><parameter>--host=$LFS_TGT</parameter></term> 68 66 <listitem> 69 <para>Because this is really a native build of Binutils, setting these 70 variables ensures that the build system uses the cross-compiler and 71 associated tools instead of the ones on the host system.</para> 72 </listitem> 73 </varlistentry> 74 75 <varlistentry> 76 <term><parameter>--with-lib-path=/tools/lib</parameter></term> 77 <listitem> 78 <para>This tells the configure script to specify the library 79 search path during the compilation of Binutils, resulting in 80 <filename class="directory">/tools/lib</filename> being passed 81 to the linker. This prevents the linker from searching through 82 library directories on the host.</para> 83 </listitem> 84 </varlistentry> 85 86 <varlistentry> 87 <term><parameter>--with-sysroot</parameter></term> 88 <listitem> 89 <para>This defines a default (non-existent) sysroot directory 90 <filename class="directory">/tools/$LFS_TGT/sys-root</filename>. 91 It is useful when looking for shared objects which are required by 92 other shared objects explicitly included on the linker's command 93 line. Those objects are searched into the directories listed in 94 <filename><sysroot>/etc/ld.so.conf</filename>, and failing 95 that, into the linker search path, which is right. If this switch 96 is not given, <filename>/etc/ld.so.conf</filename> on the host 97 is used, that is, programs may be linked to libraries on 98 the host, which we want to avoid.</para> 67 <para>This tells the configure script that we want to build 68 this pass of binutils for the $LFS_TGT machine, using our just 69 built cross-compiler. This prevents the linker from searching 70 through library directories on the host.</para> 99 71 </listitem> 100 72 </varlistentry> … … 108 80 <para>Install the package:</para> 109 81 110 <screen><userinput remap="install">make install</userinput></screen> 111 112 <para>Now prepare the linker for the <quote>Re-adjusting</quote> phase in 113 the next chapter:</para> 114 115 <screen><userinput remap="adjust">make -C ld clean 116 make -C ld LIB_PATH=/usr/lib:/lib 117 cp -v ld/ld-new /tools/bin</userinput></screen> 118 119 <variablelist> 120 <title>The meaning of the make parameters:</title> 121 122 <varlistentry> 123 <term><parameter>-C ld clean</parameter></term> 124 <listitem> 125 <para>This tells the make program to remove all compiled 126 files in the <filename class="directory">ld</filename> 127 subdirectory.</para> 128 </listitem> 129 </varlistentry> 130 131 <varlistentry> 132 <term><parameter>-C ld LIB_PATH=/usr/lib:/lib</parameter></term> 133 <listitem> 134 <para>This option rebuilds everything in the <filename 135 class="directory">ld</filename> subdirectory. Specifying the 136 <envar>LIB_PATH</envar> Makefile variable on the command line 137 allows us to override the default value of the temporary tools 138 and point it to the proper final path. The value of this variable 139 specifies the linker's default library search path. This 140 preparation is used in the next chapter.</para> 141 </listitem> 142 </varlistentry> 143 144 </variablelist> 82 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 145 83 146 84 </sect2> -
chapter05/bison.xml
r9d719e2 refcb393 46 46 <para>Prepare Bison for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --build=$(build-aux/config.guess) \ 50 --host=$LFS_TGT \ 51 --docdir=/usr/share/doc/bison-&bison-version;</userinput></screen> 52 53 <variablelist> 54 <title>The meaning of the new configure option:</title> 55 56 <varlistentry> 57 <term><parameter>--docdir=/usr/share/doc/bison-&bison-version;</parameter></term> 58 <listitem> 59 <para>This tells the build system to install bison documentation 60 into a versioned directory.</para> 61 </listitem> 62 </varlistentry> 63 64 </variablelist> 49 65 50 66 <para>Compile the package:</para> … … 52 68 <screen><userinput remap="make">make</userinput></screen> 53 69 54 <para>To test the results, issue:</para>55 56 <screen><userinput remap="test">make check</userinput></screen>57 58 70 <para>Install the package:</para> 59 71 60 <screen><userinput remap="install">make install</userinput></screen>72 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 61 73 62 74 </sect2> -
chapter05/bzip2.xml
r9d719e2 refcb393 44 44 <title>Installation of Bzip2</title> 45 45 46 <para>Apply a patch that will install the documentation for this 47 package:</para> 48 49 <screen><userinput remap="pre">patch -Np1 -i ../&bzip2-docs-patch;</userinput></screen> 50 51 <para>The following command ensures installation of symbolic links are 52 relative:</para> 53 54 <screen><userinput remap="pre">sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile</userinput></screen> 55 56 <para>Ensure the man pages are installed into the correct location:</para> 57 58 <screen><userinput remap="pre">sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile</userinput></screen> 59 46 60 <para>The Bzip2 package does not contain a <command>configure</command> 47 61 script. There are two <filename>Makefile</filename>, one for the shared … … 49 63 do the compilation in two stages. First the shared library:</para> 50 64 51 <screen><userinput remap="make">make -f Makefile-libbz2_so65 <screen><userinput remap="make">make CC=$LFS_TGT-gcc -f Makefile-libbz2_so 52 66 make clean</userinput></screen> 53 67 … … 70 84 <para>Compile and test the package with:</para> 71 85 72 <screen><userinput remap="make">make </userinput></screen>86 <screen><userinput remap="make">make CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib</userinput></screen> 73 87 74 88 <para>Install the package:</para> 75 89 76 <screen><userinput remap="install">make PREFIX=/tools install 77 cp -v bzip2-shared /tools/bin/bzip2 78 cp -av libbz2.so* /tools/lib 79 ln -sv libbz2.so.1.0 /tools/lib/libbz2.so</userinput></screen> 90 <screen><userinput remap="install">make PREFIX=$LFS/usr install</userinput></screen> 91 92 <para>Install the shared <command>bzip2</command> binary into the 93 <filename class="directory">/bin</filename> directory, make some necessary 94 symbolic links, and clean up:</para> 95 96 <screen><userinput remap="install">cp -v bzip2-shared $LFS/bin/bzip2 97 cp -av libbz2.so* $LFS/lib 98 ln -sv ../../lib/libbz2.so.1.0 $LFS/usr/lib/libbz2.so 99 rm -v $LFS/usr/bin/{bunzip2,bzcat,bzip2} 100 ln -sv bzip2 $LFS/bin/bunzip2 101 ln -sv bzip2 $LFS/bin/bzcat</userinput></screen> 80 102 81 103 </sect2> … … 83 105 <sect2 role="content"> 84 106 <title/> 85 86 107 <para>Details on this package are located in 87 108 <xref linkend="contents-bzip2" role="."/></para> -
chapter05/changingowner.xml
r9d719e2 refcb393 19 19 </note> 20 20 21 <para>Currently, the <filename class="directory">$LFS/tools</filename> directory 21 <para>Currently, the whole directory hierarchy in <filename 22 class="directory">$LFS</filename> 22 23 is owned by the user <systemitem class="username">lfs</systemitem>, a user 23 that exists only on the host system. If the <filename24 class="directory">$LFS /tools</filename> directory is kept as is, the files are24 that exists only on the host system. If the directories under <filename 25 class="directory">$LFS</filename> are kept as they are, the files are 25 26 owned by a user ID without a corresponding account. This is dangerous because 26 a user account created later could get this same user ID and would own the27 <filename class="directory">$LFS/tools</filename> directory and all the files28 the rein, thus exposing these files to possible malicious manipulation.</para>27 a user account created later could get this same user ID and would own all 28 the files under <filename class="directory">$LFS</filename>, thus exposing 29 these files to possible malicious manipulation.</para> 29 30 30 31 <para>To avoid this issue, you could add the <systemitem … … 32 33 creating the <filename>/etc/passwd</filename> file, taking care to assign it 33 34 the same user and group IDs as on the host system. Better yet, change the 34 ownership of the <filename class="directory">$LFS/ tools</filename> directoryto35 ownership of the <filename class="directory">$LFS/*</filename> directories to 35 36 user <systemitem class="username">root</systemitem> by running the following 36 37 command:</para> 37 38 38 <screen><userinput>chown -R root:root $LFS/tools</userinput></screen> 39 40 <para>Although the <filename class="directory">$LFS/tools</filename> directory 41 can be deleted once the LFS system has been finished, it can be retained to build 42 additional LFS systems <emphasis>of the same book version</emphasis>. How best 43 to backup <filename class="directory">$LFS/tools</filename> is a matter of 44 personal preference.</para> 45 46 <caution> 47 <para>If you intend to keep the temporary tools for use in building future LFS 48 systems, <emphasis>now</emphasis> is the time to back them up. Subsequent 49 commands in chapter 6 will alter the tools currently in place, rendering them 50 useless for future builds.</para> 51 </caution> 39 <screen><userinput>chown -R root:root $LFS/{usr,lib,var,etc,bin,sbin,lib64,tools}</userinput></screen> 52 40 53 41 </sect1> -
chapter05/chapter05.xml
r9d719e2 refcb393 20 20 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/> 21 21 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="libstdc++.xml"/> 22 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils-pass2.xml"/>23 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/>24 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/>25 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="expect.xml"/>26 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dejagnu.xml"/>27 22 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="m4.xml"/> 28 23 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ncurses.xml"/> … … 36 31 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="findutils.xml"/> 37 32 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gawk.xml"/> 38 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gettext.xml"/>39 33 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="grep.xml"/> 40 34 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gzip.xml"/> 41 35 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="make.xml"/> 42 36 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="patch.xml"/> 37 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sed.xml"/> 38 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tar.xml"/> 39 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="xz.xml"/> 40 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils-pass2.xml"/> 41 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/> 42 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="stripping.xml"/> 43 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="changingowner.xml"/> 44 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="kernfs.xml"/> 45 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="chroot.xml"/> 46 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creatingdirs.xml"/> 47 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="createfiles.xml"/> 48 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="libstdc++-pass2.xml"/> 49 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gettext.xml"/> 43 50 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="perl.xml"/> 44 51 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="python.xml"/> 45 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sed.xml"/>46 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tar.xml"/>47 52 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="texinfo.xml"/> 48 53 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="util-linux.xml"/> 49 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href=" xz.xml"/>50 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href=" stripping.xml"/>51 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href=" changingowner.xml"/>54 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/> 55 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="expect.xml"/> 56 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dejagnu.xml"/> 52 57 53 58 </chapter> -
chapter05/chroot.xml
r9d719e2 refcb393 6 6 ]> 7 7 8 <sect1 id="ch- system-chroot">8 <sect1 id="ch-tools-chroot"> 9 9 <?dbhtml filename="chroot.html"?> 10 10 11 11 <title>Entering the Chroot Environment</title> 12 12 13 <para>It is time to enter the chroot environment to begin building and 14 installing the final LFS system. As user <systemitem 13 <para>Now that all the packages which depend on themselves for being built 14 are on the system, it is time to enter the chroot environment to finish 15 installing the remaining temporary tools. This environment will be in use 16 also for installing the final system. As user <systemitem 15 17 class="username">root</systemitem>, run the following command to enter the 16 18 realm that is, at the moment, populated with only the temporary tools:</para> 17 19 18 <screen role="nodump"><userinput>chroot "$LFS" / tools/bin/env -i \20 <screen role="nodump"><userinput>chroot "$LFS" /usr/bin/env -i \ 19 21 HOME=/root \ 20 22 TERM="$TERM" \ 21 23 PS1='(lfs chroot) \u:\w\$ ' \ 22 PATH=/bin:/usr/bin:/sbin:/usr/sbin :/tools/bin\23 / tools/bin/bash --login +h</userinput></screen>24 PATH=/bin:/usr/bin:/sbin:/usr/sbin \ 25 /bin/bash --login +h</userinput></screen> 24 26 25 27 <para>The <parameter>-i</parameter> option given to the <command>env</command> … … 40 42 (<filename class="directory">/</filename>) directory.</para> 41 43 42 <para>Notice that <filename class="directory">/tools/bin</filename> comes last43 in the <envar>PATH</envar>. This means that a temporary tool will no longer be44 <para>Notice that <filename class="directory">/tools/bin</filename> is not 45 anymore in the <envar>PATH</envar>. This means that a temporary tool will no longer be 44 46 used once its final version is installed. This occurs when the shell does not 45 47 <quote>remember</quote> the locations of executed binaries—for this -
chapter05/coreutils.xml
r9d719e2 refcb393 46 46 <para>Prepare Coreutils for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools --enable-install-program=hostname</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT \ 50 --build=$(build-aux/config.guess) \ 51 --enable-install-program=hostname \ 52 --enable-no-install-program=kill,uptime</userinput></screen> 49 53 50 54 <variablelist> … … 65 69 <screen><userinput remap="make">make</userinput></screen> 66 70 67 <para>Compilation is now complete. As discussed earlier, running the test68 suite is not mandatory for the temporary tools here in this chapter. To run69 the Coreutils test suite anyway, issue the following command:</para>70 71 <screen><userinput remap="test">make RUN_EXPENSIVE_TESTS=yes check</userinput></screen>72 73 <para>The <parameter>RUN_EXPENSIVE_TESTS=yes</parameter> parameter tells the74 test suite to run several additional tests that are considered75 relatively expensive (in terms of CPU power and memory usage) on some76 platforms, but generally are not a problem on Linux.</para>77 78 71 <para>Install the package:</para> 79 72 80 <screen><userinput remap="install">make install</userinput></screen>73 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 81 74 <!-- 82 75 <para>The above command refuses to install <filename>su</filename> … … 87 80 <screen><userinput remap="install">cp -v src/su /tools/bin</userinput></screen> 88 81 --> 82 <para>Move programs to their final expected locations. Although this is 83 not necessary in this temporary environment, we must do so because some 84 programs harcode executable locations:</para> 85 86 <screen><userinput remap="install">mv -v $LFS/usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} $LFS/bin 87 mv -v $LFS/usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} $LFS/bin 88 mv -v $LFS/usr/bin/{rmdir,stty,sync,true,uname} $LFS/bin 89 mv -v $LFS/usr/bin/chroot $LFS/usr/sbin 90 mkdir -pv $LFS/usr/share/man/man8 91 mv -v $LFS/usr/share/man/man1/chroot.1 $LFS/usr/share/man/man8/chroot.8 92 sed -i s/\"1\"/\"8\"/1 $LFS/usr/share/man/man8/chroot.8 93 mv -v $LFS/usr/bin/{head,nice,sleep,touch} $LFS/bin</userinput></screen> 94 89 95 </sect2> 90 96 -
chapter05/createfiles.xml
r9d719e2 refcb393 6 6 ]> 7 7 8 <sect1 id="ch- system-createfiles">8 <sect1 id="ch-tools-createfiles"> 9 9 <?dbhtml filename="createfiles.html"?> 10 10 11 11 <title>Creating Essential Files and Symlinks</title> 12 12 13 <indexterm zone="ch- system-createfiles">13 <indexterm zone="ch-tools-createfiles"> 14 14 <primary sortas="e-/etc/passwd">/etc/passwd</primary> 15 15 </indexterm> 16 16 17 <indexterm zone="ch- system-createfiles">17 <indexterm zone="ch-tools-createfiles"> 18 18 <primary sortas="e-/etc/group">/etc/group</primary> 19 19 </indexterm> 20 20 21 <indexterm zone="ch- system-createfiles">21 <indexterm zone="ch-tools-createfiles"> 22 22 <primary sortas="e-/var/run/utmp">/var/run/utmp</primary> 23 23 </indexterm> 24 24 25 <indexterm zone="ch- system-createfiles">25 <indexterm zone="ch-tools-createfiles"> 26 26 <primary sortas="e-/var/log/btmp">/var/log/btmp</primary> 27 27 </indexterm> 28 28 29 <indexterm zone="ch- system-createfiles">29 <indexterm zone="ch-tools-createfiles"> 30 30 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary> 31 31 </indexterm> 32 32 33 <indexterm zone="ch- system-createfiles">33 <indexterm zone="ch-tools-createfiles"> 34 34 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary> 35 35 </indexterm> 36 37 <para>Some programs use hard-wired paths to programs which do not exist yet.38 In order to satisfy these programs, create a number of symbolic links which39 will be replaced by real files throughout the course of this chapter after the40 software has been installed:</para>41 42 <screen><userinput>ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin43 ln -sv /tools/bin/{env,install,perl,printf} /usr/bin44 ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib45 ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib46 ln -sv /tools/lib/libfl.so* /usr/lib47 48 ln -sv bash /bin/sh49 50 for lib in blkid mount uuid fdisk51 do52 ln -sv /tools/lib/lib$lib.so* /usr/lib53 sed 's|/tools|/usr|' /tools/lib/pkgconfig/${lib}.pc \54 > /usr/lib/pkgconfig/${lib}.pc55 done56 for incdir in blkid libmount uuid libfdisk57 do58 ln -svf /tools/include/$incdir /usr/include59 done</userinput></screen>60 61 <variablelist>62 <title>The purpose of each link:</title>63 64 <varlistentry>65 <term><parameter><filename>/bin/bash</filename></parameter></term>66 <listitem>67 <para>Many <command>bash</command> scripts specify68 <filename>/bin/bash</filename>.</para>69 </listitem>70 </varlistentry>71 72 <varlistentry>73 <term><parameter><filename>/bin/cat</filename></parameter></term>74 <listitem>75 <para>This pathname is hard-coded into Glibc's configure script.</para>76 </listitem>77 </varlistentry>78 79 <varlistentry>80 <term><parameter><filename>/bin/dd</filename></parameter></term>81 <listitem>82 <para>The path to <filename>dd</filename> will be hard-coded into the83 <filename>/usr/bin/libtool</filename> utility.</para>84 </listitem>85 </varlistentry>86 87 <varlistentry>88 <term><parameter><filename>/bin/echo</filename></parameter></term>89 <listitem>90 <para>This is to satisfy one of the tests in Glibc's test suite, which91 expects <filename>/bin/echo</filename>.</para>92 </listitem>93 </varlistentry>94 95 <varlistentry>96 <term><parameter><filename>/usr/bin/env</filename></parameter></term>97 <listitem>98 <para>This pathname is hard-coded into some packages build procedures.99 <!-- systemd This may not be needed if we move sysd to the end--></para>100 </listitem>101 </varlistentry>102 103 <varlistentry>104 <term><parameter><filename>/usr/bin/install</filename></parameter></term>105 <listitem>106 <para>The path to <filename>install</filename> will be hard-coded into107 the <filename>/usr/lib/bash/Makefile.inc</filename> file.</para>108 </listitem>109 </varlistentry>110 111 <varlistentry>112 <term><parameter><filename>/bin/ln</filename></parameter></term>113 <listitem>114 <para>The path to <filename>ln</filename> will be hard-coded into the115 <filename>/usr/lib/perl5/&perl-version;/<target-triplet>/Config_heavy.pl</filename>116 file.</para>117 </listitem>118 </varlistentry>119 120 <varlistentry>121 <term><parameter><filename>/bin/pwd</filename></parameter></term>122 <listitem>123 <para>Some <command>configure</command> scripts, particularly Glibc's,124 have this pathname hard-coded.</para>125 </listitem>126 </varlistentry>127 128 <varlistentry>129 <term><parameter><filename>/bin/rm</filename></parameter></term>130 <listitem>131 <para>The path to <filename>rm</filename> will be hard-coded into the132 <filename>/usr/lib/perl5/&perl-version;/<target-triplet>/Config_heavy.pl</filename>133 file.</para>134 </listitem>135 </varlistentry>136 137 <varlistentry>138 <term><parameter><filename>/bin/stty</filename></parameter></term>139 <listitem>140 <para>This pathname is hard-coded into Expect, therefore it is needed141 for Binutils and GCC test suites to pass.</para>142 </listitem>143 </varlistentry>144 145 <varlistentry>146 <term><parameter><filename>/usr/bin/perl</filename></parameter></term>147 <listitem>148 <para>Many Perl scripts hard-code this path to the149 <command>perl</command> program.</para>150 </listitem>151 </varlistentry>152 153 <varlistentry>154 <term><parameter><filename>/usr/lib/libgcc_s.so{,.1}</filename></parameter></term>155 <listitem>156 <para>Glibc needs this for the pthreads library to work.</para>157 </listitem>158 </varlistentry>159 160 <varlistentry>161 <term><parameter><filename>/usr/lib/libstdc++{,.6}</filename></parameter></term>162 <listitem>163 <para>This is needed by several tests in Glibc's test suite, as well as164 for C++ support in GMP.</para>165 </listitem>166 </varlistentry>167 168 <varlistentry>169 <term><parameter><filename>/bin/sh</filename></parameter></term>170 <listitem>171 <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>172 </listitem>173 </varlistentry>174 175 <varlistentry>176 <term>177 <parameter><filename>/usr/lib/libfl.so*</filename></parameter>178 </term>179 <listitem>180 <para>This link allows binutils to find the flex library, and to181 build enhanced versions of ar and ranlib.</para>182 </listitem>183 </varlistentry>184 185 <varlistentry>186 <term>187 <parameter>188 <filename>/usr/lib/lib{blkid,fdisk,mount,uuid}.so*</filename>,189 <filename>/usr/include/{blkid,libfdisk,libmount,uuid}</filename>,190 <filename>/usr/lib/pkgconfig/{blkid,fdisk,mount,uuid}.pc</filename>191 </parameter>192 </term>193 <listitem>194 <para>These links and files allow195 <phrase revision="sysv">eudev</phrase>196 <phrase revision="systemd">systemd</phrase> to find the197 util-linux libraries installed in chapter 5, without creating198 wrong references to /tools. The uuid library is also needed for199 building a python module.</para>200 </listitem>201 </varlistentry>202 203 </variablelist>204 36 205 37 <para>Historically, Linux maintains a list of the mounted file systems in the … … 314 146 315 147 <para>The created groups are not part of any standard—they are groups 316 decided on in part by the requirements of the Udev configuration in th is148 decided on in part by the requirements of the Udev configuration in the next 317 149 chapter, and in part by common convention employed by a number of existing 318 150 Linux distributions. In addition, some test suites rely on specific users … … 326 158 327 159 <para>To remove the <quote>I have no name!</quote> prompt, start a new 328 shell. Since a full Glibc was installed in <xref 329 linkend="chapter-temporary-tools"/> and the 160 shell. Since the 330 161 <filename>/etc/passwd</filename> and <filename>/etc/group</filename> 331 162 files have been created, user name and group name resolution will now 332 163 work:</para> 333 164 334 <screen role="nodump"><userinput>exec / tools/bin/bash --login +h</userinput></screen>165 <screen role="nodump"><userinput>exec /bin/bash --login +h</userinput></screen> 335 166 336 167 <para>Note the use of the <parameter>+h</parameter> directive. This tells -
chapter05/creatingdirs.xml
r9d719e2 refcb393 6 6 ]> 7 7 8 <sect1 id="ch- system-creatingdirs">8 <sect1 id="ch-tools-creatingdirs"> 9 9 <?dbhtml filename="creatingdirs.html"?> 10 10 11 11 <title>Creating Directories</title> 12 12 13 <para>It is time to create some structure in the LFS file system. Create a14 standard directory tree by issuing the following commands:</para>13 <para>It is time to create the full structure in the LFS file system. Create 14 a standard directory tree by issuing the following commands:</para> 15 15 16 16 <screen><userinput>mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt} 17 mkdir -pv /{media/{floppy,cdrom},s bin,srv,var}17 mkdir -pv /{media/{floppy,cdrom},srv,var} 18 18 install -dv -m 0750 /root 19 19 install -dv -m 1777 /tmp /var/tmp 20 20 mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src} 21 21 mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man} 22 mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo} 23 mkdir -v /usr/libexec 22 mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo} 24 23 mkdir -pv /usr/{,local/}share/man/man{1..8} 25 mkdir -v /usr/lib/pkgconfig26 27 case $(uname -m) in28 x86_64) mkdir -v /lib64 ;;29 esac30 24 31 25 mkdir -v /var/{log,mail,spool} -
chapter05/dejagnu.xml
r9d719e2 refcb393 45 45 <para>Prepare DejaGNU for compilation:</para> 46 46 47 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 47 <screen><userinput remap="configure">./configure --prefix=/usr 48 makeinfo --html --no-split -o doc/dejagnu.html doc/dejagnu.texi 49 makeinfo --plaintext -o doc/dejagnu.txt doc/dejagnu.texi</userinput></screen> 48 50 49 51 <para>Build and install the package:</para> 50 52 51 <screen><userinput remap="install">make install</userinput></screen> 53 <screen><userinput remap="install">make install 54 install -v -dm755 /usr/share/doc/dejagnu-&dejagnu-version; 55 install -v -m644 doc/dejagnu.{html,txt} \ 56 /usr/share/doc/dejagnu-&dejagnu-version;</userinput></screen> 52 57 53 58 <para>To test the results, issue:</para> -
chapter05/diffutils.xml
r9d719e2 refcb393 46 46 <para>Prepare Diffutils for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/ tools</userinput></screen>48 <screen><userinput remap="configure">./configure --prefix=/usr --host=$LFS_TGT</userinput></screen> 49 49 50 50 <para>Compile the package:</para> … … 52 52 <screen><userinput remap="make">make</userinput></screen> 53 53 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the Diffutils test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 54 <para>Install the package:</para> 61 55 62 <screen><userinput remap="install">make install</userinput></screen>56 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 63 57 64 58 </sect2> -
chapter05/expect.xml
r9d719e2 refcb393 49 49 <title>Installation of Expect</title> 50 50 51 <para>First, force Expect's configure script to use <filename>/bin/stty</filename> 52 instead of a <filename>/usr/local/bin/stty</filename> it may find on the host system. 53 This will ensure that our test suite tools remain sane for the final builds of our 54 toolchain:</para> 51 <para>Prepare Expect for compilation:</para> 55 52 56 <screen><userinput remap="pre">cp -v configure{,.orig} 57 sed 's:/usr/local/bin:/bin:' configure.orig > configure</userinput></screen> 58 59 <para>Now prepare Expect for compilation:</para> 60 61 <screen><userinput remap="configure">./configure --prefix=/tools \ 62 --with-tcl=/tools/lib \ 63 --with-tclinclude=/tools/include</userinput></screen> 53 <screen><userinput remap="configure"> 54 ./configure --prefix=/usr \ 55 --with-tcl=/usr/lib \ 56 --enable-shared \ 57 --mandir=/usr/share/man \ 58 --with-tclinclude=/usr/include</userinput></screen> 64 59 65 60 <variablelist> … … 67 62 68 63 <varlistentry> 69 <term><parameter>--with-tcl=/ tools/lib</parameter></term>64 <term><parameter>--with-tcl=/usr/lib</parameter></term> 70 65 <listitem> 71 <para>This ensures that the configure script finds the Tcl72 installation in the temporary tools location instead of possibly73 locating an existing one on the host system.</para>66 <para>This parameter is needed to tell the 67 <command>configure</command> where the 68 <command>tclConfig.sh</command> is located.</para> 74 69 </listitem> 75 70 </varlistentry> 76 71 77 72 <varlistentry> 78 <term><parameter>--with-tclinclude=/ tools/include</parameter></term>73 <term><parameter>--with-tclinclude=/usr/include</parameter></term> 79 74 <listitem> 80 75 <para>This explicitly tells Expect where to find Tcl's internal … … 91 86 <screen><userinput remap="make">make</userinput></screen> 92 87 93 <para>Compilation is now complete. As discussed earlier, running the test94 suite is not mandatory for the temporary tools here in this chapter. To run95 the Expect test suite anyway, issue the following command:</para>96 97 <screen><userinput remap="test">make test</userinput></screen>98 99 <para>Note that the Expect test suite is known to experience failures under100 certain host conditions that are not within our control. Therefore,101 test suite failures here are not surprising and are not considered102 critical.</para>103 104 88 <para>Install the package:</para> 105 89 106 <screen><userinput remap="install">make SCRIPTS="" install</userinput></screen> 107 108 <variablelist> 109 <title>The meaning of the make parameter:</title> 110 111 <varlistentry> 112 <term><parameter>SCRIPTS=""</parameter></term> 113 <listitem> 114 <para>This prevents installation of the supplementary Expect 115 scripts, which are not needed.</para> 116 </listitem> 117 </varlistentry> 118 119 </variablelist> 90 <screen><userinput remap="install">make install 91 ln -svf expect&expect-version;/libexpect&expect-version;.so /usr/lib</userinput></screen> 120 92 121 93 </sect2> -
chapter05/file.xml
r9d719e2 refcb393 46 46 <para>Prepare File for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT</userinput></screen> 49 50 51 <!-- devs: if using - -build here, the build system wants to compile 52 the signature file with "file" on the build system, but stops if it is not 53 the same version. One possibility would be to build "file" on the build 54 system first, but it is simpler to have the system think it is not 55 cross-compiling, and use the just built "file". --> 50 56 <para>Compile the package:</para> 51 57 52 58 <screen><userinput remap="make">make</userinput></screen> 53 59 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the File test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 60 <para>Install the package:</para> 61 61 62 <screen><userinput remap="install">make install</userinput></screen>62 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 63 63 64 64 </sect2> … … 66 66 <sect2 role="content"> 67 67 <title/> 68 69 <para>Details on this package are located in 70 <xref linkend="contents-file" role="."/></para> 68 <para>Details on this package are located in<!-- TODO 69 <xref linkend="contents-file" role="."/> --></para> 71 70 72 71 </sect2> -
chapter05/findutils.xml
r9d719e2 refcb393 43 43 <sect2 role="installation"> 44 44 <title>Installation of Findutils</title> 45 <!--46 <para>First, make some fixes required by glibc-2.28:</para>47 45 48 <screen><userinput remap="pre">sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' gl/lib/*.c49 sed -i '/unistd/a #include <sys/sysmacros.h>' gl/lib/mountlist.c50 echo "#define _IO_IN_BACKUP 0x100" >> gl/lib/stdio-impl.h</userinput></screen>51 -->52 46 <para>Prepare Findutils for compilation:</para> 53 47 54 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT \ 50 --build=$(build-aux/config.guess)</userinput></screen> 55 51 56 52 <para>Compile the package:</para> … … 58 54 <screen><userinput remap="make">make</userinput></screen> 59 55 60 <para>Compilation is now complete. As discussed earlier, running the test61 suite is not mandatory for the temporary tools here in this chapter. To run62 the Findutils test suite anyway, issue the following command:</para>63 64 <screen><userinput remap="test">make check</userinput></screen>65 66 56 <para>Install the package:</para> 67 57 68 <screen><userinput remap="install">make install</userinput></screen> 58 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 59 60 <para>Move the excutable to its final expected location:</para> 61 62 <screen><userinput remap="install">mv -v $LFS/usr/bin/find $LFS/bin 63 sed -i 's|find:=${BINDIR}|find:=/bin|' $LFS/usr/bin/updatedb</userinput></screen> 69 64 70 65 </sect2> -
chapter05/flex.xml
r9d719e2 refcb393 46 46 <para>Prepare Flex for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT \ 50 --build=$(build-aux/config.guess) \ 51 --disable-bootstrap \ 52 --docdir=/usr/share/doc/flex-&flex-version;</userinput></screen> 53 54 <variablelist> 55 <title>The meaning of the new configure option:</title> 56 57 <varlistentry> 58 <term><parameter>--disable-bootstrap</parameter></term> 59 <listitem> 60 <para>Normally, building flex is done in two stages. A first 61 programs, which is used to generate the source of a second one, 62 which is then compiled. When using cross-compilation, the first 63 program is generated on the build systemd. However, due to a bug 64 in configure, the presence of some funciton is tested only on the 65 host system. If this function is not found on the build system, the 66 build fails. This can be prevented by disabling the two stage 67 build.</para> 68 </listitem> 69 </varlistentry> 70 </variablelist> 49 71 50 72 <para>Compile the package:</para> … … 52 74 <screen><userinput remap="make">make</userinput></screen> 53 75 54 <para>To test the results, issue:</para>55 56 <screen><userinput remap="test">make check</userinput></screen>57 58 76 <para>Install the package:</para> 59 77 60 <screen><userinput remap="install">make install</userinput></screen>78 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 61 79 62 80 </sect2> -
chapter05/gawk.xml
r9d719e2 refcb393 44 44 <title>Installation of Gawk</title> 45 45 46 <para>First, ensure some unneeded files are not installed:</para> 47 48 <screen><userinput remap="pre">sed -i 's/extras//' Makefile.in</userinput></screen> 49 46 50 <para>Prepare Gawk for compilation:</para> 47 51 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 52 <screen><userinput remap="configure">./configure --prefix=/usr \ 53 --host=$LFS_TGT \ 54 --build=$(./config.guess)</userinput></screen> 49 55 50 56 <para>Compile the package:</para> … … 52 58 <screen><userinput remap="make">make</userinput></screen> 53 59 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the Gawk test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 60 <para>Install the package:</para> 61 61 62 <screen><userinput remap="install">make install</userinput></screen>62 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 63 63 64 64 </sect2> -
chapter05/gcc-pass1.xml
r9d719e2 refcb393 44 44 <title>Installation of Cross GCC</title> 45 45 46 <para>GCC nowrequires the GMP, MPFR and MPC packages. As these packages may46 <para>GCC requires the GMP, MPFR and MPC packages. As these packages may 47 47 not be included in your host distribution, they will be built with 48 48 GCC. Unpack each package into the GCC source directory and rename the … … 63 63 mv -v mpc-&mpc-version; mpc</userinput></screen> 64 64 65 <para>The following command will change the location of GCC's default 66 dynamic linker to use the one installed in <filename 67 class="directory">/tools</filename>. It also removes <filename 68 class="directory">/usr/include</filename> from GCC's include search path. 69 Issue:</para> 70 71 <screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h 72 do 73 cp -uv $file{,.orig} 74 sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ 75 -e 's@/usr@/tools@g' $file.orig > $file 76 echo ' 77 #undef STANDARD_STARTFILE_PREFIX_1 78 #undef STANDARD_STARTFILE_PREFIX_2 79 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" 80 #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file 81 touch $file.orig 82 done</userinput></screen> 83 84 <para>In case the above seems hard to follow, let's break it down a bit. 85 First we copy the files <filename>gcc/config/linux.h</filename>, 86 <filename>gcc/config/i386/linux.h</filename>, and 87 <filename>gcc/config/i386/linux64.h</filename> to a file of 88 the same name but with an added suffix of <quote>.orig</quote>. Then the 89 first sed expression prepends <quote>/tools</quote> to every instance of 90 <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or 91 <quote>/lib32/ld</quote>, while the second one replaces hard-coded 92 instances of <quote>/usr</quote>. Next, we add our define statements which 93 alter the default startfile prefix to the end of the file. Note that the 94 trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required. 95 Finally, we use <command>touch</command> to update the timestamp on the 96 copied files. When used in conjunction with <command>cp -u</command>, this 97 prevents unexpected changes to the original files in case the commands are 98 inadvertently run twice.</para> 99 100 <para>Finally, on x86_64 hosts, set the default directory name for 65 <para>On x86_64 hosts, set the default directory name for 101 66 64-bit libraries to <quote>lib</quote>:</para> 102 67 … … 108 73 esac</userinput></screen> 109 74 110 <!--111 <para>GCC doesn't detect stack protection correctly, which causes problems112 for the build of Glibc-&glibc-version;, so fix that by issuing the following113 command:</para>114 115 <screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen>116 -->117 118 <!--119 <para>Also fix a problem identified upstream:</para>120 121 <screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&\& \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>122 -->123 75 <para>The GCC documentation recommends building GCC 124 76 in a dedicated build directory:</para> … … 131 83 <screen><userinput remap="configure">../configure \ 132 84 --target=$LFS_TGT \ 133 --prefix= /tools\85 --prefix=$LFS/tools \ 134 86 --with-glibc-version=2.11 \ 135 87 --with-sysroot=$LFS \ 136 88 --with-newlib \ 137 89 --without-headers \ 138 --with-local-prefix=/tools \ 139 --with-native-system-header-dir=/tools/include \ 90 --enable-initfini-array \ 140 91 --disable-nls \ 141 92 --disable-shared \ … … 182 133 183 134 <varlistentry> 184 <term><parameter>--with-local-prefix=/tools</parameter></term>185 <listitem>186 <para>The local prefix is the location in the system that GCC will search187 for locally installed include files. The default is <filename>/usr/local</filename>.188 Setting this to <filename>/tools</filename> helps keep the host location of189 <filename>/usr/local</filename> out of this GCC's search path.</para>190 </listitem>191 </varlistentry>192 193 <varlistentry>194 <term><parameter>--with-native-system-header-dir=/tools/include</parameter></term>195 <listitem>196 <para>By default, GCC searches <filename>/usr/include</filename> for197 system headers. In conjunction with the sysroot switch, this would198 normally translate to <filename>$LFS/usr/include</filename>. However199 the headers that will be installed in the next two sections will go200 to <filename>$LFS/tools/include</filename>. This switch ensures that201 gcc will find them correctly. In the second pass of GCC, this same202 switch will ensure that no headers from the host system are203 found.</para>204 </listitem>205 </varlistentry>206 207 <varlistentry>208 135 <term><parameter>--disable-shared</parameter></term> 209 136 <listitem> 210 137 <para>This switch forces GCC to link its internal libraries 211 statically. We do this to avoid possible issues with the host 212 138 statically. We need this because the shared libraries require glibc, 139 which is not yet installed on the target system.</para> 213 140 </listitem> 214 141 </varlistentry> … … 250 177 <screen><userinput remap="make">make</userinput></screen> 251 178 252 <para>Compilation is now complete. At this point, the test suite would253 normally be run, but, as mentioned before, the test suite framework is254 not in place yet. The benefits of running the tests at this point255 are minimal since the programs from this first pass will soon be256 replaced.</para>257 258 179 <para>Install the package:</para> 259 180 260 <screen><userinput remap="install">make install</userinput></screen> 261 <!-- 262 <para>Using <parameter>- -disable-shared</parameter> means that the 263 <filename>libgcc_eh.a</filename> file isn't created and installed. The 264 Glibc package depends on this library as it uses 265 <parameter>-lgcc_eh</parameter> within its build system. This dependency 266 can be satisfied by creating a symlink to <filename>libgcc.a</filename>, 267 since that file will end up containing the objects normally contained in 268 <filename>libgcc_eh.a</filename>:</para> 269 270 <screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`</userinput></screen> 271 --> 181 <screen><userinput remap="install">make install</userinput></screen> 182 183 <para>This build of GCC has installed a couple of internal system 184 headers. Normally one of them, <filename>limits.h</filename>, would in turn 185 include the corresponding system <filename>limits.h</filename> header, in 186 this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the 187 time of this build of gcc <filename>$LFS/usr/include/limits.h</filename> 188 does not exist, so the internal header that has just been installed is a 189 partial, self-contained file and does not include the extended features of 190 the system header. This is adequate for building glibc, but the full 191 internal header will be needed later. Create a full version of the internal 192 header using a command that is identical to what the GCC build system does 193 in normal circumstances:</para> 194 195 <screen><userinput remap="install">cd .. 196 cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ 197 `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen> 272 198 </sect2> 273 199 -
chapter05/gcc-pass2.xml
r9d719e2 refcb393 55 55 mv -v mpc-&mpc-version; mpc</userinput></screen> 56 56 57 <para>Once again, change the location of GCC's default dynamic linker to58 use the one installed in <filename59 class="directory">/tools</filename>.</para>60 61 <screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h62 do63 cp -uv $file{,.orig}64 sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \65 -e 's@/usr@/tools@g' $file.orig > $file66 echo '67 #undef STANDARD_STARTFILE_PREFIX_168 #undef STANDARD_STARTFILE_PREFIX_269 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"70 #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file71 touch $file.orig72 done</userinput></screen>73 74 57 <para>If building on x86_64, change the default directory name for 64-bit 75 58 libraries to <quote>lib</quote>:</para> … … 82 65 esac</userinput></screen> 83 66 84 <para>Our first build of GCC has installed a couple of internal system85 headers. Normally one of them, <filename>limits.h</filename>, will in turn86 include the corresponding system <filename>limits.h</filename> header, in87 this case, <filename>/tools/include/limits.h</filename>. However, at the88 time of the first build of gcc <filename>/tools/include/limits.h</filename>89 did not exist, so the internal header that GCC installed is a partial,90 self-contained file and does not include the extended features of the91 system header. This was adequate for building the temporary libc, but this92 build of GCC now requires the full internal header. Create a full version93 of the internal header using a command that is identical to what the GCC94 build system does in normal circumstances:</para>95 96 <screen><userinput remap="pre">cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \97 `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h</userinput></screen>98 <!--99 <para>For x86 machines, the limited number of registers is a bottleneck100 for the system. Free one up by not using a frame pointer that is not101 needed:</para>102 103 <screen><userinput remap="pre">case `uname -m` in104 i?86) sed -i 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in ;;105 esac</userinput></screen>106 -->107 67 <para>Create a separate build directory again:</para> 108 68 109 69 <screen><userinput remap="pre">mkdir -v build 110 70 cd build</userinput></screen> 71 72 <para>Create a symlink that allos libgcc to be built with posix threads 73 support:</para> 74 75 <screen><userinput remap="pre">mkdir -pv $LFS_TGT/libgcc 76 ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h</userinput></screen> 111 77 112 78 <para>Before starting to build GCC, remember to unset any environment … … 115 81 <para>Now prepare GCC for compilation:</para> 116 82 117 <screen><userinput remap="configure">CC=$LFS_TGT-gcc \ 118 CXX=$LFS_TGT-g++ \ 119 AR=$LFS_TGT-ar \ 120 RANLIB=$LFS_TGT-ranlib \ 121 ../configure \ 122 --prefix=/tools \ 123 --with-local-prefix=/tools \ 124 --with-native-system-header-dir=/tools/include \ 125 --enable-languages=c,c++ \ 126 --disable-libstdcxx-pch \ 83 <screen><userinput remap="configure">../configure \ 84 --build=$(../config.guess) \ 85 --host=$LFS_TGT \ 86 --prefix=/usr \ 87 CC_FOR_TARGET=$LFS_TGT-gcc \ 88 --with-build-sysroot=$LFS \ 89 --enable-initfini-array \ 90 --disable-nls \ 127 91 --disable-multilib \ 128 --disable-bootstrap \ 129 --disable-libgomp</userinput></screen> 92 --disable-decimal-float \ 93 --disable-libatomic \ 94 --disable-libgomp \ 95 --disable-libquadmath \ 96 --disable-libssp \ 97 --disable-libvtv \ 98 --disable-libstdcxx \ 99 --enable-languages=c,c++</userinput></screen> 130 100 131 101 <variablelist> 132 <title>The meaning of the new configure options:</title> 102 <title>The meaning of the new configure options:</title><!-- WIP --> 133 103 134 104 <varlistentry> 135 <term><parameter>- -enable-languages=c,c++</parameter></term>105 <term><parameter>-with-build-sysroot=$LFS</parameter></term> 136 106 <listitem> 137 <para>This option ensures that both the C and C++ compilers are 138 built.</para> 107 <para>Normally, using <parameter>--host=</parameter> ensures that 108 a cross-compiler is used for building gcc, and that compiler knows 109 that it has to look for headers and libraries in <filename 110 class="directory">$LFS</filename>. But the build system of GCC uses 111 other tools, which are not aware of this location. This switch is 112 needed to have them find the needed files in <filename 113 class="directory">$LFS</filename>, and not on the host.</para> 139 114 </listitem> 140 115 </varlistentry> 141 116 142 117 <varlistentry> 143 <term><parameter>-- disable-libstdcxx-pch</parameter></term>118 <term><parameter>--enable-initfini-array</parameter></term> 144 119 <listitem> 145 <para>Do not build the pre-compiled header (PCH) for 146 <filename class="libraryfile">libstdc++</filename>. It takes up a 147 lot of space, and we have no use for it.</para> 148 </listitem> 149 </varlistentry> 150 151 <varlistentry> 152 <term><parameter>--disable-bootstrap</parameter></term> 153 <listitem> 154 <para>For native builds of GCC, the default is to do a "bootstrap" 155 build. This does not just compile GCC, but compiles it several times. 156 It uses the programs compiled in a first round to compile itself a 157 second time, and then again a third time. The second and third 158 iterations are compared to make sure it can reproduce itself 159 flawlessly. This also implies that it was compiled correctly. 160 However, the LFS build method should provide a solid compiler 161 without the need to bootstrap each time.</para> 120 <para>This option is automatically enabled when building a native 121 compiler with a native compiler on x86. But here, we build with 122 a cross compiler, so we need to explicitely set this option.</para> 162 123 </listitem> 163 124 </varlistentry> … … 171 132 <para>Install the package:</para> 172 133 173 <screen><userinput remap="install">make install</userinput></screen>134 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 174 135 175 136 <para>As a finishing touch, create a symlink. Many programs and scripts … … 180 141 which C compiler to install:</para> 181 142 182 <screen><userinput remap="install">ln -sv gcc /tools/bin/cc</userinput></screen> 183 184 <caution> 185 <para>At this point, it is imperative to stop and ensure that the basic 186 functions (compiling and linking) of the new toolchain are working as 187 expected. To perform a sanity check, run the following commands:</para> 188 189 <screen><userinput>echo 'int main(){}' > dummy.c 190 cc dummy.c 191 readelf -l a.out | grep ': /tools'</userinput></screen> 192 193 <para>If everything is working correctly, there should be no errors, 194 and the output of the last command will be of the form:</para> 195 196 <screen><computeroutput>[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]</computeroutput></screen> 197 198 <para>Note that the dynamic linker will be /tools/lib/ld-linux.so.2 199 for 32-bit machines.</para> 200 201 <para>If the output is not shown as above or there was no output at all, 202 then something is wrong. Investigate and retrace the steps to find out 203 where the problem is and correct it. This issue must be resolved before 204 continuing on. First, perform the sanity check again, using 205 <command>gcc</command> instead of <command>cc</command>. If this works, 206 then the <filename class="symlink">/tools/bin/cc</filename> symlink is 207 missing. Install the symlink as per above. 208 Next, ensure that the <envar>PATH</envar> is correct. This 209 can be checked by running <command>echo $PATH</command> and verifying that 210 <filename class="directory">/tools/bin</filename> is at the head of the 211 list. If the <envar>PATH</envar> is wrong it could mean that you are not 212 logged in as user <systemitem class="username">lfs</systemitem> or that 213 something went wrong back in <xref linkend="ch-preps-settingenviron" 214 role="."/></para> 215 216 <para>Once all is well, clean up the test files:</para> 217 218 <screen><userinput>rm -v dummy.c a.out</userinput></screen> 219 220 </caution> 143 <screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen> 221 144 222 145 </sect2> -
chapter05/generalinstructions.xml
r9d719e2 refcb393 82 82 <para>Place all the sources and patches in a directory that will be 83 83 accessible from the chroot environment such as 84 <filename class="directory">/mnt/lfs/sources/</filename>.Do84 <filename class="directory">/mnt/lfs/sources/</filename>.<!-- Do 85 85 <emphasis>not</emphasis> put sources in 86 <filename class="directory">/mnt/lfs/tools/</filename>.</para>86 <filename class="directory">/mnt/lfs/tools/</filename>. --></para> 87 87 </listitem> 88 88 <listitem> -
chapter05/gettext.xml
r9d719e2 refcb393 53 53 <variablelist> 54 54 <title>The meaning of the configure option:</title> 55 <!-- 56 <varlistentry> 57 <term><parameter>EMACS="no"</parameter></term> 58 <listitem> 59 <para>This prevents the configure script from determining where to 60 install Emacs Lisp files as the test is known to hang on some hosts. 61 </para> 62 </listitem> 63 </varlistentry> 64 --> 55 65 56 <varlistentry> 66 57 <term><parameter>--disable-shared</parameter></term> … … 77 68 <screen><userinput remap="make">make</userinput></screen> 78 69 79 <para>80 Due to the limited environment, running the test suite at this stage81 is not recommended.</para>82 83 70 <para>Install the <command>msgfmt</command>, <command>msgmerge</command> and 84 71 <command>xgettext</command> programs:</para> 85 72 86 <screen><userinput remap="install">cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} / tools/bin</userinput></screen>73 <screen><userinput remap="install">cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin</userinput></screen> 87 74 88 75 </sect2> -
chapter05/glibc.xml
r9d719e2 refcb393 44 44 <title>Installation of Glibc</title> 45 45 46 <para>First, create two symbolic links, which are needed for proper 47 operation of the dynamic library loader:</para> 48 49 <screen><userinput remap="pre">ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64 50 ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3</userinput></screen> 51 52 <para>Some of the Glibc programs use the non-FHS compliant 53 <filename class="directory">/var/db</filename> directory to store their 54 runtime data. Apply the following patch to make such programs store their 55 runtime data in the FHS-compliant locations:</para> 56 57 <screen><userinput remap="pre">patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch</userinput></screen> 58 46 59 <para>The Glibc documentation recommends building Glibc 47 60 in a dedicated build directory:</para> … … 53 66 54 67 <screen><userinput remap="configure">../configure \ 55 --prefix=/ tools\68 --prefix=/usr \ 56 69 --host=$LFS_TGT \ 57 70 --build=$(../scripts/config.guess) \ 58 71 --enable-kernel=&min-kernel; \ 59 --with-headers=/tools/include</userinput></screen> 72 --with-headers=$LFS/usr/include \ 73 libc_cv_slibdir=/lib</userinput></screen> 60 74 <!-- 61 75 libc_cv_forced_unwind=yes \ … … 69 83 <listitem> 70 84 <para>The combined effect of these switches is that Glibc's build system 71 configures itself to cross-compile, using the cross-linker and85 configures itself to be cross-compiled, using the cross-linker and 72 86 cross-compiler in <filename class="directory">/tools</filename>.</para> 73 87 </listitem> … … 84 98 85 99 <varlistentry> 86 <term><parameter>--with-headers= /tools/include</parameter></term>100 <term><parameter>--with-headers=$LFS/usr/include</parameter></term> 87 101 <listitem> 88 102 <para>This tells Glibc to compile itself against the headers recently 89 installed to the toolsdirectory, so that it knows exactly what103 installed to the usr/include directory, so that it knows exactly what 90 104 features the kernel has and can optimize itself accordingly.</para> 91 105 </listitem> 92 106 </varlistentry> 107 108 <varlistentry> 109 <term><parameter>libc_cv_slibdir=/lib</parameter></term> 110 <listitem> 111 <para>This ensures that the library is installed in /lib instead 112 of the default /lib64 on 64 bit machines.</para> 113 </listitem> 114 </varlistentry> 93 115 <!-- 94 <varlistentry>95 <term><parameter>libc_cv_forced_unwind=yes</parameter></term>96 <listitem>97 <para>The linker installed during98 <xref linkend="ch-tools-binutils-pass1"/> was cross-compiled and as99 such cannot be used until Glibc has been installed. This means that100 the configure test for force-unwind support will fail, as it relies on101 a working linker. The libc_cv_forced_unwind=yes variable is passed in102 order to inform <command>configure</command> that force-unwind103 support is available without it having to run the test.</para>104 </listitem>105 </varlistentry>106 116 <varlistentry> 107 117 <term><parameter>libc_cv_c_cleanup=yes</parameter></term> … … 112 122 </listitem> 113 123 </varlistentry> 114 --> 115 <!--<varlistentry>124 125 <varlistentry> 116 126 <term><parameter>libc_cv_ctors_header=yes</parameter></term> 117 127 <listitem> … … 148 158 <para>Install the package:</para> 149 159 150 <screen><userinput remap="install">make install</userinput></screen> 151 152 <caution> 153 <para>At this point, it is imperative to stop and ensure that the basic 154 functions (compiling and linking) of the new toolchain are working as 155 expected. To perform a sanity check, run the following commands:</para> 160 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 161 162 <variablelist> 163 <title>The meaning of the <command>make install</command> option:</title> 164 165 <varlistentry> 166 <term><parameter>DESTDIR=$LFS</parameter></term> 167 <listitem> 168 <para>The <envar>DESTDIR</envar> make variable is used by almost all 169 packages to define the location where the package should be 170 installed. If it is not set, it defaults to the root (<filename 171 class="directory">/</filename>) directory. Here we specify that 172 the package be installed in <filename class="directory">$LFS 173 </filename>, which will become the root after <xref linkend= 174 "ch-tools-chroot"/>.</para> 175 </listitem> 176 </varlistentry> 177 178 </variablelist> 179 180 <caution> 181 <para>At this point, it is imperative to stop and ensure that the basic 182 functions (compiling and linking) of the new toolchain are working as 183 expected. To perform a sanity check, run the following commands:</para> 156 184 157 185 <screen><userinput>echo 'int main(){}' > dummy.c 158 186 $LFS_TGT-gcc dummy.c 159 readelf -l a.out | grep ' : /tools'</userinput></screen>160 161 <para>If everything is working correctly, there should be no errors,162 and the output of the last command will be of the form:</para>163 164 <screen><computeroutput>[Requesting program interpreter: / tools/lib64/ld-linux-x86-64.so.2]</computeroutput></screen>165 166 <para>Note that for 32-bit machines, the interpreter name will be167 <filename>/tools/lib/ld-linux.so.2</filename>.</para>168 169 <para>If the output is not shown as above or there was no output at all,170 then something is wrong. Investigate and retrace the steps to find out171 where the problem is and correct it. This issue must be resolved before172 continuing on.</para>173 174 <para>Once all is well, clean up the test files:</para>187 readelf -l a.out | grep '/ld-linux'</userinput></screen> 188 189 <para>If everything is working correctly, there should be no errors, 190 and the output of the last command will be of the form:</para> 191 192 <screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen> 193 194 <para>Note that for 32-bit machines, the interpreter name will be 195 <filename>/lib/ld-linux.so.2</filename>.</para> 196 197 <para>If the output is not shown as above or there was no output at all, 198 then something is wrong. Investigate and retrace the steps to find out 199 where the problem is and correct it. This issue must be resolved before 200 continuing on.</para> 201 202 <para>Once all is well, clean up the test files:</para> 175 203 176 204 <screen><userinput>rm -v dummy.c a.out</userinput></screen> 177 205 178 </caution> 179 180 <note><para>Building Binutils in the section after next will serve as an 181 additional check that the toolchain has been built properly. If Binutils 182 fails to build, it is an indication that something has gone wrong with the 183 previous Binutils, GCC, or Glibc installations.</para></note> 206 </caution> 207 208 <note><para>Building packages in the next sections will serve as an 209 additional check that the toolchain has been built properly. If some 210 package, especially binutils-pass2 or gcc-pass2, fails to build, it is 211 an indication that something has gone wrong with the 212 previous Binutils, GCC, or Glibc installations.</para></note> 213 214 <para>Now that our cross-toolchain is complete, finalize the installation 215 of the limits.h header. For doing so, run an utility provided by the GCC 216 developers:</para> 217 218 <screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen> 184 219 185 220 </sect2> -
chapter05/grep.xml
r9d719e2 refcb393 46 46 <para>Prepare Grep for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT \ 50 --bindir=/bin</userinput></screen> 49 51 50 52 <para>Compile the package:</para> … … 52 54 <screen><userinput remap="make">make</userinput></screen> 53 55 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the Grep test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 56 <para>Install the package:</para> 61 57 62 <screen><userinput remap="install">make install</userinput></screen>58 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 63 59 64 60 </sect2> -
chapter05/gzip.xml
r9d719e2 refcb393 46 46 <para>Prepare Gzip for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/ tools</userinput></screen>48 <screen><userinput remap="configure">./configure --prefix=/usr --host=$LFS_TGT</userinput></screen> 49 49 50 50 <para>Compile the package:</para> … … 52 52 <screen><userinput remap="make">make</userinput></screen> 53 53 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the Gzip test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 54 <para>Install the package:</para> 61 55 62 <screen><userinput remap="install">make install</userinput></screen> 56 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 57 58 <para>Move the excutable to its final expected location:</para> 59 60 <screen><userinput remap="install">mv -v $LFS/usr/bin/gzip $LFS/bin</userinput></screen> 63 61 64 62 </sect2> -
chapter05/introduction.xml
r9d719e2 refcb393 20 20 linker, libraries, and a few useful utilities). The second step uses this 21 21 toolchain to build the other essential tools.</para> 22 22 <!-- 23 23 <para>The files compiled in this chapter will be installed under the 24 <filename class="directory">$LFS /tools</filename> directory to keep them24 <filename class="directory">$LFS</filename> directory to keep them 25 25 separate from the files installed in the next chapter and the host 26 26 production directories. Since the packages compiled here are temporary, 27 27 we do not want them to pollute the soon-to-be LFS system.</para> 28 28 --> 29 29 </sect1> -
chapter05/kernfs.xml
r9d719e2 refcb393 6 6 ]> 7 7 8 <sect1 id="ch- system-kernfs">8 <sect1 id="ch-tools-kernfs"> 9 9 <?dbhtml filename="kernfs.html"?> 10 10 11 11 <title>Preparing Virtual Kernel File Systems</title> 12 12 13 <indexterm zone="ch- system-kernfs">13 <indexterm zone="ch-tools-kernfs"> 14 14 <primary sortas="e-/dev/">/dev/*</primary> 15 15 </indexterm> -
chapter05/libstdc++.xml
r9d719e2 refcb393 6 6 ]> 7 7 8 <sect1 id="ch-tools-libstdcpp " role="wrap">9 <?dbhtml filename="gcc-libstdc++ .html"?>8 <sect1 id="ch-tools-libstdcpp-pass1" role="wrap"> 9 <?dbhtml filename="gcc-libstdc++-pass1.html"?> 10 10 11 11 <sect1info condition="script"> … … 15 15 </sect1info> 16 16 17 <title>Libstdc++ from GCC-&gcc-version; </title>17 <title>Libstdc++ from GCC-&gcc-version;, Pass 1</title> 18 18 19 <indexterm zone="ch-tools-libstdcpp ">19 <indexterm zone="ch-tools-libstdcpp-pass1"> 20 20 <primary sortas="a-GCC">GCC</primary> 21 <secondary>tools, libstdc++ </secondary>21 <secondary>tools, libstdc++ pass 1</secondary> 22 22 </indexterm> 23 23 … … 29 29 (part of GCC is written in C++), but we had to defer its installation 30 30 when we built <xref linkend="ch-tools-gcc-pass1"/> 31 because it depends on glibc, which was not yet available in /tools. 31 because it depends on glibc, which was not yet available in the target 32 directory. 32 33 </para> 33 34 … … 62 63 <screen><userinput remap="configure">../libstdc++-v3/configure \ 63 64 --host=$LFS_TGT \ 64 --prefix=/tools \ 65 --build=$(../config.guess) \ 66 --prefix=/usr \ 65 67 --disable-multilib \ 66 --disable-nls \<!-- 67 - -disable-libstdcxx-threads \--> 68 --disable-nls \ 68 69 --disable-libstdcxx-pch \ 69 70 --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/&gcc-version;</userinput></screen> … … 79 80 </listitem> 80 81 </varlistentry> 81 <!-- 82 <varlistentry> 83 <term><parameter>- -disable-libstdcxx-threads</parameter></term> 84 <listitem> 85 <para>Since gcc-pass1 is built without thread support, the C++ 86 thread library cannot be built either.</para> 87 </listitem> 88 </varlistentry> 89 --> 82 90 83 <varlistentry> 91 84 <term><parameter>--disable-libstdcxx-pch</parameter></term> … … 115 108 <para>Install the library:</para> 116 109 117 <screen><userinput remap="install">make install</userinput></screen>110 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 118 111 119 112 </sect2> -
chapter05/linux-headers.xml
r9d719e2 refcb393 25 25 <title/> 26 26 27 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" 28 href="../chapter06/linux-headers.xml" 29 xpointer="xpointer(/sect1/sect2[1]/para[1])"/> 27 <para>The Linux API Headers (in linux-&linux-version;.tar.xz) expose the 28 kernel's API for use by Glibc.</para> 30 29 31 30 <segmentedlist> … … 61 60 62 61 <screen><userinput remap="make">make headers 63 </userinput><userinput remap="install">cp -rv usr/include/* /tools/include</userinput></screen> 62 find usr/include -name '.*' -delete 63 rm usr/include/Makefile 64 </userinput><userinput remap="install">cp -rv usr/include $LFS/usr</userinput></screen> 64 65 65 66 </sect2> 66 67 67 <sect2 role="content"> 68 <title/> 69 70 <para>Details on this package are located in 71 <xref linkend="contents-linux-headers" role="."/></para> 68 <sect2 id="contents-linux-headers" role="content"> 69 <title>Contents of Linux API Headers</title> 70 71 <segmentedlist> 72 <segtitle>Installed headers</segtitle> 73 <segtitle>Installed directories</segtitle> 74 75 <seglistitem> 76 <seg>/usr/include/asm/*.h, /usr/include/asm-generic/*.h, 77 /usr/include/drm/*.h, /usr/include/linux/*.h, /usr/include/misc/*.h, 78 /usr/include/mtd/*.h, /usr/include/rdma/*.h, /usr/include/scsi/*.h, 79 /usr/include/sound/*.h, /usr/include/video/*.h, 80 and /usr/include/xen/*.h</seg> 81 <seg>/usr/include/asm, /usr/include/asm-generic, /usr/include/drm, 82 /usr/include/linux, /usr/include/misc, /usr/include/mtd, 83 /usr/include/rdma, /usr/include/scsi, /usr/include/sound, 84 /usr/include/video, and /usr/include/xen</seg> 85 </seglistitem> 86 </segmentedlist> 87 88 <variablelist> 89 <bridgehead renderas="sect3">Short Descriptions</bridgehead> 90 <?dbfo list-presentation="list"?> 91 <?dbhtml list-presentation="table"?> 92 93 <varlistentry id="asm"> 94 <term><filename class="headerfile">/usr/include/asm/*.h</filename></term> 95 <listitem> 96 <para>The Linux API ASM Headers</para> 97 <indexterm zone="ch-tools-linux-headers asm"> 98 <primary sortas="e-/usr/include/asm/*.h">/usr/include/asm/*.h</primary> 99 </indexterm> 100 </listitem> 101 </varlistentry> 102 103 <varlistentry id="asm-generic"> 104 <term><filename class="headerfile">/usr/include/asm-generic/*.h</filename></term> 105 <listitem> 106 <para>The Linux API ASM Generic Headers</para> 107 <indexterm zone="ch-tools-linux-headers asm-generic"> 108 <primary sortas="e-/usr/include/asm-generic/*.h">/usr/include/asm-generic/*.h</primary> 109 </indexterm> 110 </listitem> 111 </varlistentry> 112 113 <varlistentry id="drm"> 114 <term><filename class="headerfile">/usr/include/drm/*.h</filename></term> 115 <listitem> 116 <para>The Linux API DRM Headers</para> 117 <indexterm zone="ch-tools-linux-headers drm"> 118 <primary sortas="e-/usr/include/drm/*.h">/usr/include/drm/*.h</primary> 119 </indexterm> 120 </listitem> 121 </varlistentry> 122 123 <varlistentry id="linux"> 124 <term><filename class="headerfile">/usr/include/linux/*.h</filename></term> 125 <listitem> 126 <para>The Linux API Linux Headers</para> 127 <indexterm zone="ch-tools-linux-headers linux"> 128 <primary sortas="e-/usr/include/linux/*.h">/usr/include/linux/*.h</primary> 129 </indexterm> 130 </listitem> 131 </varlistentry> 132 133 <varlistentry id="misc"> 134 <term><filename class="headerfile">/usr/include/misc/*.h</filename></term> 135 <listitem> 136 <para>The Linux API Miscellaneous Headers</para> 137 <indexterm zone="ch-tools-linux-headers misc"> 138 <primary sortas="e-/usr/include/misc/*.h">/usr/include/misc/*.h</primary> 139 </indexterm> 140 </listitem> 141 </varlistentry> 142 143 <varlistentry id="mtd"> 144 <term><filename class="headerfile">/usr/include/mtd/*.h</filename></term> 145 <listitem> 146 <para>The Linux API MTD Headers</para> 147 <indexterm zone="ch-tools-linux-headers mtd"> 148 <primary sortas="e-/usr/include/mtd/*.h">/usr/include/mtd/*.h</primary> 149 </indexterm> 150 </listitem> 151 </varlistentry> 152 153 <varlistentry id="rdma"> 154 <term><filename class="headerfile">/usr/include/rdma/*.h</filename></term> 155 <listitem> 156 <para>The Linux API RDMA Headers</para> 157 <indexterm zone="ch-tools-linux-headers rdma"> 158 <primary sortas="e-/usr/include/rdma/*.h">/usr/include/rdma/*.h</primary> 159 </indexterm> 160 </listitem> 161 </varlistentry> 162 163 <varlistentry id="scsi"> 164 <term><filename class="headerfile">/usr/include/scsi/*.h</filename></term> 165 <listitem> 166 <para>The Linux API SCSI Headers</para> 167 <indexterm zone="ch-tools-linux-headers scsi"> 168 <primary sortas="e-/usr/include/scsi/*.h">/usr/include/scsi/*.h</primary> 169 </indexterm> 170 </listitem> 171 </varlistentry> 172 173 <varlistentry id="sound"> 174 <term><filename class="headerfile">/usr/include/sound/*.h</filename></term> 175 <listitem> 176 <para>The Linux API Sound Headers</para> 177 <indexterm zone="ch-tools-linux-headers sound"> 178 <primary sortas="e-/usr/include/sound/*.h">/usr/include/sound/*.h</primary> 179 </indexterm> 180 </listitem> 181 </varlistentry> 182 183 <varlistentry id="video"> 184 <term><filename class="headerfile">/usr/include/video/*.h</filename></term> 185 <listitem> 186 <para>The Linux API Video Headers</para> 187 <indexterm zone="ch-tools-linux-headers video"> 188 <primary sortas="e-/usr/include/video/*.h">/usr/include/video/*.h</primary> 189 </indexterm> 190 </listitem> 191 </varlistentry> 192 193 <varlistentry id="xen"> 194 <term><filename class="headerfile">/usr/include/xen/*.h</filename></term> 195 <listitem> 196 <para>The Linux API Xen Headers</para> 197 <indexterm zone="ch-tools-linux-headers xen"> 198 <primary sortas="e-/usr/include/xen/*.h">/usr/include/xen/*.h</primary> 199 </indexterm> 200 </listitem> 201 </varlistentry> 202 203 </variablelist> 72 204 73 205 </sect2> -
chapter05/m4.xml
r9d719e2 refcb393 51 51 <para>Prepare M4 for compilation:</para> 52 52 53 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 53 <screen><userinput remap="configure">./configure --prefix=/usr \ 54 --host=$LFS_TGT \ 55 --build=$(build-aux/config.guess)</userinput></screen> 54 56 55 57 <para>Compile the package:</para> … … 57 59 <screen><userinput remap="make">make</userinput></screen> 58 60 59 <para>Compilation is now complete. As discussed earlier, running the test60 suite is not mandatory for the temporary tools here in this chapter. To run61 the M4 test suite anyway, issue the following command:</para>62 63 <screen><userinput remap="test">make check</userinput></screen>64 65 61 <para>Install the package:</para> 66 62 67 <screen><userinput remap="install">make install</userinput></screen>63 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 68 64 69 65 </sect2> … … 71 67 <sect2 role="content"> 72 68 <title/> 73 74 69 <para>Details on this package are located in 75 70 <xref linkend="contents-m4" role="."/></para> -
chapter05/make.xml
r9d719e2 refcb393 42 42 <sect2 role="installation"> 43 43 <title>Installation of Make</title> 44 <!--45 <para>First, work around an error caused by glibc-2.27 and later:</para>46 44 47 <screen><userinput remap="pre">sed -i '211,217 d; 219,229 d; 232 d' glob/glob.c</userinput></screen>48 -->49 45 <para>Prepare Make for compilation:</para> 50 46 51 <screen><userinput remap="configure">./configure --prefix=/tools --without-guile</userinput></screen> 52 53 <variablelist> 54 <title>The meaning of the configure option:</title> 55 56 <varlistentry> 57 <term><parameter>--without-guile</parameter></term> 58 <listitem> 59 <para>This ensures that Make-&make-version; won't link against Guile libraries, which 60 may be present on the host system, but won't be available within the 61 <command>chroot</command> environment in the next chapter.</para> 62 </listitem> 63 </varlistentry> 64 </variablelist> 47 <screen><userinput remap="configure">./configure --prefix=/usr \ 48 --host=$LFS_TGT \ 49 --build=$(build-aux/config.guess)</userinput></screen> 65 50 66 51 <para>Compile the package:</para> … … 68 53 <screen><userinput remap="make">make</userinput></screen> 69 54 70 <para>Compilation is now complete. As discussed earlier, running the test71 suite is not mandatory for the temporary tools here in this chapter. To run72 the Make test suite anyway, issue the following command:</para>73 74 <screen><userinput remap="test">make check</userinput></screen>75 76 55 <para>Install the package:</para> 77 56 78 <screen><userinput remap="install">make install</userinput></screen>57 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 79 58 80 59 </sect2> -
chapter05/ncurses.xml
r9d719e2 refcb393 50 50 <para>Prepare Ncurses for compilation:</para> 51 51 52 <screen><userinput remap="configure">./configure --prefix=/tools \ 53 --with-shared \ 54 --without-debug \ 55 --without-ada \ 56 --enable-widec \ 57 --enable-overwrite</userinput></screen> 52 <screen><userinput remap="configure">./configure --prefix=/usr \ 53 --host=$LFS_TGT \ 54 --build=$(./config.guess) \ 55 --mandir=/usr/share/man \ 56 --with-shared \ 57 --without-debug \ 58 --without-ada \ 59 --without-normal \ 60 --disable-db-install \ 61 --enable-widec \ 62 --enable-pc-files</userinput></screen> 58 63 59 64 <variablelist> 60 <title>The meaning of the configure options:</title>65 <title>The meaning of the new configure options:</title> 61 66 62 67 <varlistentry> … … 66 71 compiler which may be present on the host but will not be available 67 72 once we enter the <command>chroot</command> environment.</para> 68 </listitem>69 </varlistentry>70 71 <varlistentry>72 <term><parameter>--enable-overwrite</parameter></term>73 <listitem>74 <para>This tells Ncurses to install its header files into75 <filename class="directory">/tools/include</filename>, instead of76 <filename class="directory">/tools/include/ncurses</filename>, to77 ensure that other packages can find the Ncurses headers78 successfully.</para>79 73 </listitem> 80 74 </varlistentry> … … 94 88 </varlistentry> 95 89 90 <varlistentry> 91 <term><parameter>--enable-pc-files</parameter></term> 92 <listitem> 93 <para>This switch generates and installs .pc files for pkg-config. 94 </para> 95 </listitem> 96 </varlistentry> 97 98 <varlistentry> 99 <term><parameter>--without-normal</parameter></term> 100 <listitem> 101 <para>This switch disables building and installing most static libraries. 102 </para> 103 </listitem> 104 </varlistentry> 105 106 <varlistentry> 107 <term><parameter>--disable-db-install</parameter></term> 108 <listitem> 109 <para>This switch disables building the terminfo database: it is not 110 needed at this stage, and if <command>tic</command> is too old, 111 it cannot compile recent databases.</para> 112 </listitem> 113 </varlistentry> 114 96 115 </variablelist> 97 116 … … 100 119 <screen><userinput remap="make">make</userinput></screen> 101 120 102 <para>This package has a test suite, but it can only be run after the 103 package has been installed. The tests reside in the 104 <filename class="directory">test/</filename> directory. See the 105 <filename>README</filename> file in that directory for further details. 106 </para> 121 <para>Install the package:</para> 122 <!-- TODO: check and document --> 123 <screen><userinput remap="install">make DESTDIR=$LFS install 124 ln -s libncursesw.so $LFS/usr/lib/libncurses.so</userinput></screen> 107 125 108 <para>Install the package:</para> 126 <para>Move the shared libraries to the 127 <filename class="directory">/lib</filename> directory, where they are 128 expected to reside:</para> 109 129 110 <screen><userinput remap="install">make install 111 ln -s libncursesw.so /tools/lib/libncurses.so</userinput></screen> 130 <screen><userinput remap="install">mv -v $LFS/usr/lib/libncursesw.so.6* $LFS/lib</userinput></screen> 131 132 <para>Because the libraries have been moved, one symlink points to 133 a non-existent file. Recreate it:</para> 134 135 <screen><userinput remap="install">ln -sfv ../../lib/$(readlink $LFS/usr/lib/libncursesw.so) $LFS/usr/lib/libncursesw.so</userinput></screen> 136 112 137 113 138 </sect2> -
chapter05/patch.xml
r9d719e2 refcb393 46 46 <para>Prepare Patch for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT \ 50 --build=$(build-aux/config.guess)</userinput></screen> 49 51 50 52 <para>Compile the package:</para> … … 52 54 <screen><userinput remap="make">make</userinput></screen> 53 55 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the Patch test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 56 <para>Install the package:</para> 61 57 62 <screen><userinput remap="install">make install</userinput></screen>58 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 63 59 64 60 </sect2> -
chapter05/perl.xml
r9d719e2 refcb393 46 46 <para>Prepare Perl for compilation:</para> 47 47 48 <screen><userinput remap="configure">sh Configure -des -Dprefix=/ tools -Dlibs=-lm -Uloclibpth -Ulocincpth</userinput></screen>48 <screen><userinput remap="configure">sh Configure -des -Dprefix=/usr</userinput></screen> 49 49 50 50 <variablelist> 51 <title>The meaning of the Configure options:</title> 52 51 <title>The meaning of the new Configure options:</title> 53 52 <varlistentry> 54 53 <term><parameter>-des</parameter></term> … … 60 59 </varlistentry> 61 60 62 <varlistentry>63 <term>64 <parameter>-Uloclibpth</parameter> and65 <parameter>-Ulocincpth</parameter>66 </term>67 <listitem>68 <para>These entries undefine variables that cause the configuration69 to search for locally installed components that may exist on the70 host system.</para>71 </listitem>72 </varlistentry>73 74 61 </variablelist> 75 76 77 78 62 79 63 <para>Build the package:</para> … … 81 65 <screen><userinput remap="make">make</userinput></screen> 82 66 83 <para>Although Perl comes with a test suite, it would be better to wait 84 until it is installed in the next chapter.</para> 85 86 <para>Only a few of the utilities and libraries need to be installed at this 87 time:</para> 88 89 <screen><userinput remap="install">cp -v perl cpan/podlators/scripts/pod2man /tools/bin 90 mkdir -pv /tools/lib/perl5/&perl-version; 91 cp -Rv lib/* /tools/lib/perl5/&perl-version;</userinput></screen> 67 <screen><userinput remap="install">make install</userinput></screen> 92 68 93 69 </sect2> -
chapter05/python.xml
r9d719e2 refcb393 6 6 ]> 7 7 8 <sect1 id="ch- tools-Python" role="wrap">9 <?dbhtml filename="Python .html"?>8 <sect1 id="ch-system-Python-temp" role="wrap"> 9 <?dbhtml filename="Python-temp.html"?> 10 10 11 11 <sect1info condition="script"> … … 17 17 <title>Python-&python-version;</title> 18 18 19 <indexterm zone="ch- tools-Python">19 <indexterm zone="ch-system-Python-temp"> 20 20 <primary sortas="a-Python">Python</primary> 21 <secondary>t ools</secondary>21 <secondary>temporary</secondary> 22 22 </indexterm> 23 23 … … 51 51 </note> 52 52 53 <para>This package first builds the Python interpreter, then some54 standard Python modules. The main script for building modules is55 written in Python, and uses hard-coded paths to the host <filename56 class="directory">/usr/include</filename> and <filename57 class="directory">/usr/lib</filename> directories. To prevent them58 from being used, issue:</para>59 60 <screen><userinput remap="pre">sed -i '/def add_multiarch_paths/a \ return' setup.py</userinput></screen>61 62 53 <para>Prepare Python for compilation:</para> 63 54 64 <screen><userinput remap="configure">./configure --prefix=/ tools--without-ensurepip</userinput></screen>55 <screen><userinput remap="configure">./configure --prefix=/usr --without-ensurepip</userinput></screen> 65 56 66 57 <variablelist> … … 81 72 <screen><userinput remap="make">make</userinput></screen> 82 73 83 <para>Compilation is now complete. The test suite requires TK and84 and X Windows and cannot be run at this time.85 </para>86 87 74 <para>Install the package:</para> 88 75 -
chapter05/sed.xml
r9d719e2 refcb393 46 46 <para>Prepare Sed for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT \ 50 --bindir=/bin</userinput></screen> 49 51 50 52 <para>Compile the package:</para> … … 52 54 <screen><userinput remap="make">make</userinput></screen> 53 55 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the Sed test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 56 <para>Install the package:</para> 61 57 62 <screen><userinput remap="install">make install</userinput></screen>58 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 63 59 64 60 </sect2> -
chapter05/stripping.xml
r9d719e2 refcb393 16 16 debugging symbols. Remove those symbols with:</para> 17 17 18 <screen><userinput> strip --strip-debug /tools/lib/*19 /usr/bin/strip --strip-unneeded /tools/{,s}bin/*</userinput></screen>18 <screen><userinput>$LFS_TGT-strip --strip-debug $LFS/usr/lib/* 19 $LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/*</userinput></screen> 20 20 21 21 <para>These commands will skip a number of files, reporting that it does not 22 22 recognize their file format. Most of these are scripts instead of binaries. 23 Also use the system strip command to include the strip binary in /tools.</para> 23 Note that we use the <command>strip</command> program built in 24 <quote>Binutils pass 1</quote>, since it is the one that knows how to strip 25 our cross-compiled programs.</para> 26 <!-- Normally, the host "strip" could be used too, since it is actually the 27 same computer. But Some old versions of binutils may generate buggy crt1.o 28 and the like, because they do not know about recently introduced symbol 29 types. For more details, 30 see https://sourceware.org/bugzilla/show_bug.cgi?id=22875--> 24 31 25 32 <para>Take care <emphasis>not</emphasis> to use … … 30 37 <para>To save more, remove the documentation:</para> 31 38 32 <screen><userinput>rm -rf /tools/{,share}/{info,man,doc}</userinput></screen>39 <screen><userinput>rm -rf $LFS/usr/{,share}/{info,man,doc}</userinput></screen> 33 40 34 41 <para>The libtool .la files are only useful when linking with static … … 37 44 Remove those files now:</para> 38 45 39 <screen><userinput>find /tools/{lib,libexec} -name \*.la -delete</userinput></screen>46 <screen><userinput>find $LFS/usr/{lib,libexec} -name \*.la -delete</userinput></screen> 40 47 41 48 <para>At this point, you should have at least 3 GB of free space in -
chapter05/tar.xml
r9d719e2 refcb393 46 46 <para>Prepare Tar for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT \ 50 --build=$(build-aux/config.guess) \ 51 --bindir=/bin</userinput></screen> 49 52 50 53 <para>Compile the package:</para> … … 52 55 <screen><userinput remap="make">make</userinput></screen> 53 56 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the Tar test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 57 <para>Install the package:</para> 61 58 62 <screen><userinput remap="install">make install</userinput></screen>59 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 63 60 64 61 </sect2> -
chapter05/tcl.xml
r9d719e2 refcb393 4 4 <!ENTITY % general-entities SYSTEM "../general.ent"> 5 5 %general-entities; 6 <!ENTITY tdbc-ver "1.1.1"> 7 <!ENTITY itcl-ver "4.2.0"> 6 8 ]> 7 9 … … 47 49 packages. Installing three packages for testing purposes may seem 48 50 excessive, but it is very reassuring, if not essential, to know that the 49 most important tools are working properly. Even if the test suites are not 50 run in this chapter (they are not mandatory), these packages are required 51 most important tools are working properly. These packages are required 51 52 to run the test suites in <xref linkend="chapter-building-system"/>.</para> 52 53 … … 57 58 <para>Prepare Tcl for compilation:</para> 58 59 59 <screen><userinput remap="configure">cd unix 60 ./configure --prefix=/tools</userinput></screen> 60 <screen><userinput remap="configure">SRCDIR=$(pwd) 61 cd unix 62 ./configure --prefix=/usr \ 63 --mandir=/usr/share/man \ 64 $([ "$(uname -m)" = x86_64 ] && echo --enable-64bit)</userinput></screen> 65 66 <variablelist> 67 <title>The meaning of the configure options:</title> 68 69 <varlistentry> 70 <term><parameter>$([ "$(uname -m)" = x86_64 ] && echo --enable-64bit)</parameter></term> 71 <listitem> 72 <para>The construct <parameter>$(<shell command>)</parameter> 73 is replaced by the output of the chell command. Here this output is 74 empty if running on a 32 bit machine, and is 75 <parameter>--enable-64bit</parameter> if running on a 64 bit machine. 76 </para> 77 </listitem> 78 </varlistentry> 79 80 </variablelist> 61 81 62 82 <para>Build the package:</para> 63 83 64 <screen><userinput remap="make">make </userinput></screen>84 <screen><userinput remap="make">make 65 85 66 <para>Compilation is now complete. As discussed earlier, running the test 67 suite is not mandatory for the temporary tools here in this chapter. To run68 the Tcl test suite anyway, issue the following command:</para>86 sed -e "s|$SRCDIR/unix|/usr/lib|" \ 87 -e "s|$SRCDIR|/usr/include|" \ 88 -i tclConfig.sh 69 89 70 <screen><userinput remap="test">TZ=UTC make test</userinput></screen> 90 sed -e "s|$SRCDIR/unix/pkgs/tdbc&tdbc-ver;|/usr/lib/tdbc&tdbc-ver;|" \ 91 -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;/generic|/usr/include|" \ 92 -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;/library|/usr/lib/tcl8.6|" \ 93 -e "s|$SRCDIR/pkgs/tdbc&tdbc-ver;|/usr/include|" \ 94 -i pkgs/tdbc&tdbc-ver;/tdbcConfig.sh 71 95 72 <para>The Tcl test suite may experience failures under certain host 73 conditions that are not fully understood. Therefore, test suite failures 74 here are not surprising, and are not considered critical. The 75 <parameter>TZ=UTC</parameter> parameter sets the time zone to Coordinated 76 Universal Time (UTC), but only 77 for the duration of the test suite run. This ensures that the clock tests 78 are exercised correctly. Details on the <envar>TZ</envar> environment 79 variable are provided in <xref linkend="chapter-config"/>.</para> 96 sed -e "s|$SRCDIR/unix/pkgs/itcl&itcl-ver;|/usr/lib/itcl&itcl-ver;|" \ 97 -e "s|$SRCDIR/pkgs/itcl&itcl-ver;/generic|/usr/include|" \ 98 -e "s|$SRCDIR/pkgs/itcl&itcl-ver;|/usr/include|" \ 99 -i pkgs/itcl&itcl-ver;/itclConfig.sh 100 101 unset SRCDIR</userinput></screen> 102 103 <para>The various <quote>sed</quote> after the <quote>make</quote> command 104 remove references to the build directory from various configuration files, 105 and replaces them with the install directory. This is not mandatory 106 for the remaining of LFS, but may be needed in case a package built later 107 uses Tcl.</para> 80 108 81 109 <para>Install the package:</para> … … 86 114 be removed later:</para> 87 115 88 <screen><userinput remap="install">chmod -v u+w / tools/lib/libtcl&tcl-major-version;.so</userinput></screen>116 <screen><userinput remap="install">chmod -v u+w /usr/lib/libtcl&tcl-major-version;.so</userinput></screen> 89 117 90 118 <para>Install Tcl's headers. The next package, Expect, requires them … … 95 123 <para>Now make a necessary symbolic link:</para> 96 124 97 <screen><userinput remap="install">ln -s v tclsh&tcl-major-version; /tools/bin/tclsh</userinput></screen>125 <screen><userinput remap="install">ln -sfv tclsh&tcl-major-version; /usr/bin/tclsh</userinput></screen> 98 126 99 127 </sect2> -
chapter05/texinfo.xml
r9d719e2 refcb393 6 6 ]> 7 7 8 <sect1 id="ch- tools-texinfo" role="wrap">9 <?dbhtml filename="texinfo .html"?>8 <sect1 id="ch-system-texinfo-temp" role="wrap"> 9 <?dbhtml filename="texinfo-temp.html"?> 10 10 11 11 <sect1info condition="script"> … … 17 17 <title>Texinfo-&texinfo-version;</title> 18 18 19 <indexterm zone="ch- tools-texinfo">19 <indexterm zone="ch-system-texinfo-temp"> 20 20 <primary sortas="a-Texinfo">Texinfo</primary> 21 <secondary>t ools</secondary>21 <secondary>temporary</secondary> 22 22 </indexterm> 23 23 … … 46 46 <para>Prepare Texinfo for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/ tools</userinput></screen>48 <screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen> 49 49 50 50 <note> … … 57 57 58 58 <screen><userinput remap="make">make</userinput></screen> 59 60 <para>Compilation is now complete. As discussed earlier, running the test61 suite is not mandatory for the temporary tools here in this chapter. To run62 the Texinfo test suite anyway, issue the following command:</para>63 64 <screen><userinput remap="test">make check</userinput></screen>65 59 66 60 <para>Install the package:</para> -
chapter05/toolchaintechnotes.xml
r9d719e2 refcb393 25 25 the most educational value at the same time.</para> 26 26 27 <note> 28 <para>Before continuing, be aware of the name of the working platform, 29 often referred to as the target triplet. A simple way to determine the 30 name of the target triplet is to run the <command>config.guess</command> 31 script that comes with the source for many packages. Unpack the Binutils 32 sources and run the script: <userinput>./config.guess</userinput> and note 33 the output. For example, for a 32-bit Intel processor the 34 output will be <emphasis>i686-pc-linux-gnu</emphasis>. On a 64-bit 35 system it will be <emphasis>x86_64-pc-linux-gnu</emphasis>.</para> 36 37 <para>Also be aware of the name of the platform's dynamic linker, often 38 referred to as the dynamic loader (not to be confused with the standard 39 linker <command>ld</command> that is part of Binutils). The dynamic linker 40 provided by Glibc finds and loads the shared libraries needed by a program, 41 prepares the program to run, and then runs it. The name of the dynamic 42 linker for a 32-bit Intel machine will be <filename 43 class="libraryfile">ld-linux.so.2</filename> (<filename 44 class="libraryfile">ld-linux-x86-64.so.2</filename> for 64-bit systems). A 45 sure-fire way to determine the name of the dynamic linker is to inspect a 46 random binary from the host system by running: <userinput>readelf -l 47 <name of binary> | grep interpreter</userinput> and noting the 48 output. The authoritative reference covering all platforms is in the 49 <filename>shlib-versions</filename> file in the root of the Glibc source 50 tree.</para> 51 </note> 52 53 <para>Some key technical points of how the <xref 54 linkend="chapter-temporary-tools"/> build method works:</para> 55 56 <itemizedlist> 57 <listitem> 58 <para>Slightly adjusting the name of the working platform, by changing the 59 "vendor" field target triplet by way of the 60 <envar>LFS_TGT</envar> variable, ensures that the first build of Binutils 61 and GCC produces a compatible cross-linker and cross-compiler. Instead of 62 producing binaries for another architecture, the cross-linker and 63 cross-compiler will produce binaries compatible with the current 64 hardware.</para> 65 </listitem> 66 <listitem> 67 <para> The temporary libraries are cross-compiled. Because a 68 cross-compiler by its nature cannot rely on anything from its host 69 system, this method removes potential contamination of the target 70 system by lessening the chance of headers or libraries from the host 71 being incorporated into the new tools. Cross-compilation also allows for 72 the possibility of building both 32-bit and 64-bit libraries on 64-bit 73 capable hardware.</para> 74 </listitem> 75 <listitem> 76 <para>Careful manipulation of the GCC source tells the compiler which target 77 dynamic linker will be used.</para> 78 </listitem> 79 </itemizedlist> 80 81 <para>Binutils is installed first because the <command>configure</command> 82 runs of both GCC and Glibc perform various feature tests on the assembler 83 and linker to determine which software features to enable or disable. This 84 is more important than one might first realize. An incorrectly configured 85 GCC or Glibc can result in a subtly broken toolchain, where the impact of 86 such breakage might not show up until near the end of the build of an 87 entire distribution. A test suite failure will usually highlight this error 88 before too much additional work is performed.</para> 89 90 <para>Binutils installs its assembler and linker in two locations, 91 <filename class="directory">/tools/bin</filename> and <filename 92 class="directory">/tools/$LFS_TGT/bin</filename>. The tools in one 93 location are hard linked to the other. An important facet of the linker is 94 its library search order. Detailed information can be obtained from 95 <command>ld</command> by passing it the <parameter>--verbose</parameter> 96 flag. For example, an <userinput>ld --verbose | grep SEARCH</userinput> 97 will illustrate the current search paths and their order. It shows which 98 files are linked by <command>ld</command> by compiling a dummy program and 99 passing the <parameter>--verbose</parameter> switch to the linker. For example, 100 <userinput>gcc dummy.c -Wl,--verbose 2>&1 | grep succeeded</userinput> 101 will show all the files successfully opened during the linking.</para> 102 103 <para>The next package installed is GCC. An example of what can be 104 seen during its run of <command>configure</command> is:</para> 105 106 <screen><computeroutput>checking what assembler to use... /tools/i686-lfs-linux-gnu/bin/as 107 checking what linker to use... /tools/i686-lfs-linux-gnu/bin/ld</computeroutput></screen> 108 109 <para>This is important for the reasons mentioned above. It also demonstrates 110 that GCC's configure script does not search the PATH directories to find which 111 tools to use. However, during the actual operation of <command>gcc</command> 112 itself, the same search paths are not necessarily used. To find out which 113 standard linker <command>gcc</command> will use, run: 114 <userinput>gcc -print-prog-name=ld</userinput>.</para> 115 116 <para>Detailed information can be obtained from <command>gcc</command> by 117 passing it the <parameter>-v</parameter> command line option while compiling 118 a dummy program. For example, <userinput>gcc -v dummy.c</userinput> will show 119 detailed information about the preprocessor, compilation, and assembly stages, 120 including <command>gcc</command>'s included search paths and their order.</para> 121 122 <para>Next installed are sanitized Linux API headers. These allow the standard 123 C library (Glibc) to interface with features that the Linux kernel will 124 provide.</para> 125 126 <para>The next package installed is Glibc. The most important considerations 127 for building Glibc are the compiler, binary tools, and kernel headers. The 128 compiler is generally not an issue since Glibc will always use the compiler 129 relating to the <parameter>--host</parameter> parameter passed to its 130 configure script; e.g. in our case, the compiler will be 131 <command>i686-lfs-linux-gnu-gcc</command>. The binary tools and kernel 132 headers can be a bit more complicated. Therefore, take no risks and use the 133 available configure switches to enforce the correct selections. After the run 134 of <command>configure</command>, check the contents of the 135 <filename>config.make</filename> file in the <filename 136 class="directory">glibc-build</filename> directory for all important details. 137 Note the use of <parameter>CC="i686-lfs-gnu-gcc"</parameter> to control which 138 binary tools are used and the use of the <parameter>-nostdinc</parameter> and 139 <parameter>-isystem</parameter> flags to control the compiler's include 140 search path. These items highlight an important aspect of the Glibc 141 package—it is very self-sufficient in terms of its build machinery and 142 generally does not rely on toolchain defaults.</para> 143 144 <para>During the second pass of Binutils, we are able to utilize the 145 <parameter>--with-lib-path</parameter> configure switch to control 146 <command>ld</command>'s library search path.</para> 147 148 <para>For the second pass of GCC, its sources also need to be modified to 149 tell GCC to use the new dynamic linker. Failure to do so will result in the 150 GCC programs themselves having the name of the dynamic linker from the host 151 system's <filename class="directory">/lib</filename> directory embedded into 152 them, which would defeat the goal of getting away from the host. From this 153 point onwards, the core toolchain is self-contained and self-hosted. The 154 remainder of the <xref linkend="chapter-temporary-tools"/> packages all build 155 against the new Glibc in <filename 156 class="directory">/tools</filename>.</para> 157 158 <para>Upon entering the chroot environment in <xref 159 linkend="chapter-building-system"/>, the first major package to be 160 installed is Glibc, due to its self-sufficient nature mentioned above. 161 Once this Glibc is installed into <filename 162 class="directory">/usr</filename>, we will perform a quick changeover of the 163 toolchain defaults, and then proceed in building the rest of the target 164 LFS system.</para> 27 <para>The build process is based on the process of 28 <emphasis>cross-compilation</emphasis>. Cross-compilation is normally used 29 for building a compiler and its toolchain for a machine different from 30 the one that is used for the build. This is not strictly needed for LFS, 31 since the machine where the new system will run is the same as the one 32 used for the build. But cross-compilation has the great advantage that 33 anything that is cross-compiled cannot depend on the host environment.</para> 34 35 <sect2 id="cross-compile" xreflabel="About Cross-Compilation"> 36 37 <title>About Cross-Compilation</title> 38 39 <para>Cross-compilation involves some concepts that deserve a section on 40 their own. Although this section may be omitted in a first reading, it 41 is strongly suggested to come back to it later in order to get a full 42 grasp of the build process.</para> 43 44 <para>Let us first define some terms used in this context:</para> 45 46 <variablelist> 47 <varlistentry><term>build</term><listitem> 48 <para>is the machine where we build programs. Note that this machine 49 is referred to as the <quote>host</quote> in other 50 sections.</para></listitem> 51 </varlistentry> 52 53 <varlistentry><term>host</term><listitem> 54 <para>is the machine/system where the built programs will run. Note 55 that this use of <quote>host</quote> is not the same as in other 56 sections.</para></listitem> 57 </varlistentry> 58 59 <varlistentry><term>target</term><listitem> 60 <para>is only used for compilers. It is the machine the compiler 61 produces code for. It may be different from both build and 62 host.</para></listitem> 63 </varlistentry> 64 65 </variablelist> 66 67 <para>As an example, let us imagine the following scenario: we may have a 68 compiler on a slow machine only, let's call the machine A, and the compiler 69 ccA. We may have also a fast machine (B), but with no compiler, and we may 70 want to produce code for a another slow machine (C). Then, to build a 71 compiler for machine C, we would have three stages:</para> 72 73 <informaltable align="center"> 74 <tgroup cols="5"> 75 <colspec colnum="1" align="center"/> 76 <colspec colnum="2" align="center"/> 77 <colspec colnum="3" align="center"/> 78 <colspec colnum="4" align="center"/> 79 <colspec colnum="5" align="left"/> 80 <thead> 81 <row><entry>Stage</entry><entry>Build</entry><entry>Host</entry> 82 <entry>Target</entry><entry>Action</entry></row> 83 </thead> 84 <tbody> 85 <row> 86 <entry>1</entry><entry>A</entry><entry>A</entry><entry>B</entry> 87 <entry>build cross-compiler cc1 using ccA on machine A</entry> 88 </row> 89 <row> 90 <entry>2</entry><entry>A</entry><entry>B</entry><entry>B</entry> 91 <entry>build cross-compiler cc2 using cc1 on machine A</entry> 92 </row> 93 <row> 94 <entry>3</entry><entry>B</entry><entry>C</entry><entry>C</entry> 95 <entry>build compiler ccC using cc2 on machine B</entry> 96 </row> 97 </tbody> 98 </tgroup> 99 </informaltable> 100 101 <para>Then, all the other programs needed by machine C can be compiled 102 using cc2 on the fast machine B. Note that unless B can run programs 103 produced for C, there is no way to test the built programs until machine 104 C itself is running. For example, for testing ccC, we may want to add a 105 fourth stage:</para> 106 107 <informaltable align="center"> 108 <tgroup cols="5"> 109 <colspec colnum="1" align="center"/> 110 <colspec colnum="2" align="center"/> 111 <colspec colnum="3" align="center"/> 112 <colspec colnum="4" align="center"/> 113 <colspec colnum="5" align="left"/> 114 <thead> 115 <row><entry>Stage</entry><entry>Build</entry><entry>Host</entry> 116 <entry>Target</entry><entry>Action</entry></row> 117 </thead> 118 <tbody> 119 <row> 120 <entry>4</entry><entry>C</entry><entry>C</entry><entry>C</entry> 121 <entry>rebuild and test ccC using itself on machine C</entry> 122 </row> 123 </tbody> 124 </tgroup> 125 </informaltable> 126 127 <para>In the example above, only cc1 and cc2 are cross-compilers, that is, 128 they produce code for a machine different from the one they are run on. 129 The other compilers ccA and ccC produce code for the machine they are run 130 on. Such compilers are called <emphasis>native</emphasis> compilers.</para> 131 132 </sect2> 133 134 <sect2 id="lfs-cross"> 135 <title>Implementation of Cross-Compilation for LFS</title> 136 137 <note> 138 <para>Almost all the build systems use names of the form 139 cpu-vendor-kernel-os referred to as the machine triplet. An astute 140 reader may wonder why a <quote>triplet</quote> refers to a four component 141 name. The reason is history: initially, three component names were enough 142 to designate unambiguously a machine, but with new machines and systems 143 appearing, that proved insufficient. The word <quote>triplet</quote> 144 remained. A simple way to determine your machine triplet is to run 145 the <command>config.guess</command> 146 script that comes with the source for many packages. Unpack the Binutils 147 sources and run the script: <userinput>./config.guess</userinput> and note 148 the output. For example, for a 32-bit Intel processor the 149 output will be <emphasis>i686-pc-linux-gnu</emphasis>. On a 64-bit 150 system it will be <emphasis>x86_64-pc-linux-gnu</emphasis>.</para> 151 152 <para>Also be aware of the name of the platform's dynamic linker, often 153 referred to as the dynamic loader (not to be confused with the standard 154 linker <command>ld</command> that is part of Binutils). The dynamic linker 155 provided by Glibc finds and loads the shared libraries needed by a 156 program, prepares the program to run, and then runs it. The name of the 157 dynamic linker for a 32-bit Intel machine will be <filename 158 class="libraryfile">ld-linux.so.2</filename> (<filename 159 class="libraryfile">ld-linux-x86-64.so.2</filename> for 64-bit systems). A 160 sure-fire way to determine the name of the dynamic linker is to inspect a 161 random binary from the host system by running: <userinput>readelf -l 162 <name of binary> | grep interpreter</userinput> and noting the 163 output. The authoritative reference covering all platforms is in the 164 <filename>shlib-versions</filename> file in the root of the Glibc source 165 tree.</para> 166 </note> 167 168 <para>In order to fake a cross compilation, the name of the host triplet 169 is slightly adjusted by changing the "vendor" field in the 170 <envar>LFS_TGT</envar> variable. We also use the 171 <parameter>--with-sysroot</parameter> when building the cross linker and 172 cross compiler, to tell them where to find the needed host files. This 173 ensures none of the other programs built in <xref 174 linkend="chapter-temporary-tools"/> can link to libraries on the build 175 machine. Only two stages are mandatory, and one more for tests:</para> 176 177 <informaltable align="center"> 178 <tgroup cols="5"> 179 <colspec colnum="1" align="center"/> 180 <colspec colnum="2" align="center"/> 181 <colspec colnum="3" align="center"/> 182 <colspec colnum="4" align="center"/> 183 <colspec colnum="5" align="left"/> 184 <thead> 185 <row><entry>Stage</entry><entry>Build</entry><entry>Host</entry> 186 <entry>Target</entry><entry>Action</entry></row> 187 </thead> 188 <tbody> 189 <row> 190 <entry>1</entry><entry>pc</entry><entry>pc</entry><entry>lfs</entry> 191 <entry>build cross-compiler cc1 using cc-pc on pc</entry> 192 </row> 193 <row> 194 <entry>2</entry><entry>pc</entry><entry>lfs</entry><entry>lfs</entry> 195 <entry>build compiler cc-lfs using cc1 on pc</entry> 196 </row> 197 <row> 198 <entry>3</entry><entry>lfs</entry><entry>lfs</entry><entry>lfs</entry> 199 <entry>rebuild and test cc-lfs using itself on lfs</entry> 200 </row> 201 </tbody> 202 </tgroup> 203 </informaltable> 204 205 <para>In the above table, <quote>on pc</quote> means the commands are run 206 on a machine using the already installed distribution. <quote>On 207 lfs</quote> means the commands are run in a chrooted environment.</para> 208 209 <para>Now, there is more about cross-compiling: the C language is not 210 just a compiler, but also defines a standard library. In this book, the 211 GNU C library, named glibc, is used. This library must 212 be compiled for the lfs machine, that is, using the cross compiler cc1. 213 But the compiler itself uses an internal library implementing complex 214 instructions not available in the assembler instruction set. This 215 internal library is named libgcc, and must be linked to the glibc 216 library to be fully functional! Furthermore, the standard library for 217 C++ (libstdc++) also needs being linked to glibc. The solution 218 to this chicken and egg problem is to first build a degraded cc1+libgcc, 219 lacking some fuctionalities such as threads and exception handling, then 220 build glibc using this degraded compiler (glibc itself is not 221 degraded), then build libstdc++. But this last library will lack the 222 same functionalities as libgcc.</para> 223 224 <para>This is not the end of the story: the conclusion of the preceding 225 paragraph is that cc1 is unable to build a fully functional libstdc++, but 226 this is the only compiler available for building the C/C++ libraries 227 during stage 2! Of course, the compiler built during stage 2, cc-lfs, 228 would be able to build those libraries, but (i) the build system of 229 gcc does not know that it is usable on pc, and (ii) using it on pc 230 would be at risk of linking to the pc libraries, since cc-lfs is a native 231 compiler. So we have to build libstdc++ later, in chroot.</para> 232 233 </sect2> 234 235 <sect2 id="other-details"> 236 237 <title>Other procedural details</title> 238 239 <para>The cross-compiler will be installed in a separate <filename 240 class="directory">$LFS/tools</filename> directory, since it will not 241 be part of the final system.</para> 242 243 <para>Binutils is installed first because the <command>configure</command> 244 runs of both GCC and Glibc perform various feature tests on the assembler 245 and linker to determine which software features to enable or disable. This 246 is more important than one might first realize. An incorrectly configured 247 GCC or Glibc can result in a subtly broken toolchain, where the impact of 248 such breakage might not show up until near the end of the build of an 249 entire distribution. A test suite failure will usually highlight this error 250 before too much additional work is performed.</para> 251 252 <para>Binutils installs its assembler and linker in two locations, 253 <filename class="directory">$LFS/tools/bin</filename> and <filename 254 class="directory">$LFS/tools/$LFS_TGT/bin</filename>. The tools in one 255 location are hard linked to the other. An important facet of the linker is 256 its library search order. Detailed information can be obtained from 257 <command>ld</command> by passing it the <parameter>--verbose</parameter> 258 flag. For example, <command>$LFS_TGT-ld --verbose | grep SEARCH</command> 259 will illustrate the current search paths and their order. It shows which 260 files are linked by <command>ld</command> by compiling a dummy program and 261 passing the <parameter>--verbose</parameter> switch to the linker. For 262 example, 263 <command>$LFS_TGT-gcc dummy.c -Wl,--verbose 2>&1 | grep succeeded</command> 264 will show all the files successfully opened during the linking.</para> 265 266 <para>The next package installed is GCC. An example of what can be 267 seen during its run of <command>configure</command> is:</para> 268 269 <screen><computeroutput>checking what assembler to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/as 270 checking what linker to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/ld</computeroutput></screen> 271 272 <para>This is important for the reasons mentioned above. It also 273 demonstrates that GCC's configure script does not search the PATH 274 directories to find which tools to use. However, during the actual 275 operation of <command>gcc</command> itself, the same search paths are not 276 necessarily used. To find out which standard linker <command>gcc</command> 277 will use, run: <command>$LFS_TGT-gcc -print-prog-name=ld</command>.</para> 278 279 <para>Detailed information can be obtained from <command>gcc</command> by 280 passing it the <parameter>-v</parameter> command line option while compiling 281 a dummy program. For example, <command>gcc -v dummy.c</command> will show 282 detailed information about the preprocessor, compilation, and assembly 283 stages, including <command>gcc</command>'s included search paths and their 284 order.</para> 285 286 <para>Next installed are sanitized Linux API headers. These allow the 287 standard C library (Glibc) to interface with features that the Linux 288 kernel will provide.</para> 289 290 <para>The next package installed is Glibc. The most important 291 considerations for building Glibc are the compiler, binary tools, and 292 kernel headers. The compiler is generally not an issue since Glibc will 293 always use the compiler relating to the <parameter>--host</parameter> 294 parameter passed to its configure script; e.g. in our case, the compiler 295 will be <command>$LFS_TGT-gcc</command>. The binary tools and kernel 296 headers can be a bit more complicated. Therefore, take no risks and use 297 the available configure switches to enforce the correct selections. After 298 the run of <command>configure</command>, check the contents of the 299 <filename>config.make</filename> file in the <filename 300 class="directory">build</filename> directory for all important details. 301 Note the use of <parameter>CC="$LFS_TGT-gcc"</parameter> (with 302 <envar>$LFS_TGT</envar> expanded) to control which binary tools are used 303 and the use of the <parameter>-nostdinc</parameter> and 304 <parameter>-isystem</parameter> flags to control the compiler's include 305 search path. These items highlight an important aspect of the Glibc 306 package—it is very self-sufficient in terms of its build machinery 307 and generally does not rely on toolchain defaults.</para> 308 309 <para>As said above, the standard C++ library is compiled next, followed 310 by all the programs that need themselves to be built. The install step 311 uses the <envar>DESTDIR</envar> variable to have the programs land into 312 the LFS filesystem.</para> 313 314 <para>Then the native lfs compiler is built. First Binutils Pass 2, with 315 the same <envar>DESTDIR</envar> install as the other programs, then the 316 second pass of GCC, omitting libstdc++ and other non-important libraries. 317 Due to some weird logic in GCC's configure script, 318 <envar>CC_FOR_TARGET</envar> ends up as <command>cc</command> when host 319 is the same as target, but is different from build. This is why 320 <parameter>CC_FOR_TARGET=$LFS_TGT-gcc</parameter> is put explicitely into 321 the configure options.</para> 322 323 <para>Upon entering the chroot environment in <xref 324 linkend="chapter-building-system"/>, the first task is to install 325 libstdc++. Then temporary installations of programs needed for the proper 326 operation of the toolchain are performed. Programs needed for testing 327 other programs are also built. From this point onwards, the 328 core toolchain is self-contained and self-hosted. In the remainder of 329 the <xref linkend="chapter-building-system"/>, final versions of all the 330 packages needed for a fully functional system are built, tested and 331 installed.</para> 332 333 </sect2> 165 334 166 335 </sect1> -
chapter05/util-linux.xml
r9d719e2 refcb393 42 42 <title>Installation of Util-linux</title> 43 43 44 <para>First create a directory 45 to enable storage for the <command>hwclock</command> program:</para> 46 47 <screen><userinput remap="pre">mkdir -pv /var/lib/hwclock</userinput></screen> 48 44 49 <para>Prepare Util-linux for compilation:</para> 45 50 46 <screen><userinput remap="configure">./configure --prefix=/tools \ 47 --without-python \ 48 --disable-makeinstall-chown \ 49 --without-systemdsystemunitdir \ 50 --without-ncurses \ 51 PKG_CONFIG=""</userinput></screen> 51 <screen><userinput remap="configure">./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ 52 --docdir=/usr/share/doc/util-linux-&util-linux-version; \ 53 --disable-chfn-chsh \ 54 --disable-login \ 55 --disable-nologin \ 56 --disable-su \ 57 --disable-setpriv \ 58 --disable-runuser \ 59 --disable-pylibmount \ 60 --disable-static \ 61 --without-python</userinput></screen> 52 62 53 63 <variablelist> 54 <title>The meaning of the configure option:</title> 64 <title>The meaning of the configure options:</title> 65 <!-- TODO --> 66 <varlistentry> 67 <term><parameter>ADJTIME_PATH=/var/lib/hwclock/adjtime</parameter></term> 68 <listitem> 69 <para>This sets the location of the file recording information about 70 the hardware clock, in accordance to the FHS. This is not stricly 71 needed fot his temporary tool, but it prevent creating a file 72 at another location, which would not be overwritten or removed 73 when building the final util-linux.</para> 74 </listitem> 75 </varlistentry> 76 77 <varlistentry> 78 <term><parameter>--disable-*</parameter></term> 79 <listitem> 80 <para>Those switches prevent warnings about building components 81 that require packages not in LFS or not installed yet.</para> 82 </listitem> 83 </varlistentry> 55 84 56 85 <varlistentry> 57 86 <term><parameter>--without-python</parameter></term> 58 87 <listitem> 59 <para>This switch disables using <application>Python</application> 60 if it is installed on the host system. It avoids trying to build 61 unneeded bindings.</para> 88 <para>This switch disables using <application>Python</application>. 89 It avoids trying to build unneeded bindings.</para> 62 90 </listitem> 63 91 </varlistentry> 64 92 65 <varlistentry>66 <term><parameter>--disable-makeinstall-chown</parameter></term>67 <listitem>68 <para>This switch disables using the <command>chown</command> command69 during installation. This is not needed when installing into the70 /tools directory and avoids the necessity of installing as71 root.</para>72 </listitem>73 </varlistentry>74 75 <varlistentry>76 <term><parameter>--without-ncurses</parameter></term>77 <listitem>78 <para>This switch disables using the ncurses library for79 the build process. This is not needed when installing into the80 /tools directory and avoids problems on some host distros.</para>81 </listitem>82 </varlistentry>83 84 <varlistentry>85 <term><parameter>--without-systemdsystemunitdir</parameter></term>86 <listitem>87 <para>On systems that use systemd, the package tries to install88 a systemd specific file to a non-existent directory in /tools.89 This switch disables the unnecessary action.</para>90 </listitem>91 </varlistentry>92 93 <varlistentry>94 <term><envar>PKG_CONFIG=""</envar></term>95 <listitem>96 <para>Setting this environment variable prevents adding unneeded97 features that may be available on the host. Note that the location98 shown for setting this environment variable is different from other99 LFS sections where variables are set preceding the command. This100 location is shown to demonstrate an alternative way of setting an101 environment variable when using configure.</para>102 </listitem>103 </varlistentry>104 93 </variablelist> 105 94 -
chapter05/xz.xml
r9d719e2 refcb393 46 46 <para>Prepare Xz for compilation:</para> 47 47 48 <screen><userinput remap="configure">./configure --prefix=/tools</userinput></screen> 48 <screen><userinput remap="configure">./configure --prefix=/usr \ 49 --host=$LFS_TGT \ 50 --build=$(build-aux/config.guess) \ 51 --disable-static \ 52 --docdir=/usr/share/doc/xz-&xz-version;</userinput></screen> 49 53 50 54 <para>Compile the package:</para> … … 52 56 <screen><userinput remap="make">make</userinput></screen> 53 57 54 <para>Compilation is now complete. As discussed earlier, running the test55 suite is not mandatory for the temporary tools here in this chapter. To run56 the Xz test suite anyway, issue the following command:</para>57 58 <screen><userinput remap="test">make check</userinput></screen>59 60 58 <para>Install the package:</para> 61 59 62 <screen><userinput remap="install">make install</userinput></screen> 60 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 61 62 <para>Make sure that all essential files are in the correct directory:</para> 63 64 <screen><userinput remap="install">mv -v $LFS/usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} $LFS/bin 65 mv -v $LFS/usr/lib/liblzma.so.* $LFS/lib 66 ln -svf ../../lib/$(readlink $LFS/usr/lib/liblzma.so) $LFS/usr/lib/liblzma.so</userinput></screen> 63 67 64 68 </sect2> … … 66 70 <sect2 role="content"> 67 71 <title/> 68 69 <para>Details on this package are located in 70 <xref linkend="contents-xz" role="."/></para> 72 <para>Details on this package are located in<!-- TODO 73 <xref linkend="contents-xz" role="."/> --></para> 71 74 72 75 </sect2> -
chapter06/acl.xml
r9d719e2 refcb393 51 51 --docdir=/usr/share/doc/acl-&acl-version;</userinput></screen> 52 52 53 <screen revision="systemd"><userinput remap="configure">./configure --prefix=/usr \ 53 <screen revision="systemd"><userinput remap="configure"> 54 ./configure --prefix=/usr \ 54 55 --disable-static \ 55 56 --libexecdir=/usr/lib \ -
chapter06/attr.xml
r9d719e2 refcb393 44 44 <para>Prepare Attr for compilation:</para> 45 45 46 <screen revision="sysv"><userinput remap="configure">./configure --prefix=/usr \ 46 <screen revision="sysv"><userinput remap="configure"> 47 ./configure --prefix=/usr \ 47 48 --bindir=/bin \ 48 49 --disable-static \ … … 50 51 --docdir=/usr/share/doc/attr-&attr-version;</userinput></screen> 51 52 52 <screen revision="systemd"><userinput remap="configure">./configure --prefix=/usr \ 53 <screen revision="systemd"><userinput remap="configure"> 54 ./configure --prefix=/usr \ 53 55 --disable-static \ 54 56 --sysconfdir=/etc \ -
chapter06/bc.xml
r9d719e2 refcb393 41 41 <sect2 role="installation"> 42 42 <title>Installation of Bc</title> 43 <!--44 <para>First, change an internal script to use <command>sed</command> instead45 of <command>ed</command>:</para>46 43 47 <screen><userinput remap="pre">cat > bc/fix-libmath_h << "EOF" 48 #! /bin/bash 49 sed -e '1 s/^/{"/' \ 50 -e 's/$/",/' \ 51 -e '2,$ s/^/"/' \ 52 -e '$ d' \ 53 -i libmath.h 44 <para>Prepare Bc for compilation:</para> 54 45 55 sed -e '$ s/$/0}/' \56 -i libmath.h57 EOF</userinput></screen>58 59 <para>Create temporary symbolic links so the package can find60 the readline library and confirm that its required libncurses61 library is available. Even though the libraries are in /tools/lib62 at this point, the system will use /usr/lib at the end of63 this chapter.</para>64 65 <screen><userinput remap="pre">ln -sv /tools/lib/libncursesw.so.6 /usr/lib/libncursesw.so.666 ln -sfv libncursesw.so.6 /usr/lib/libncurses.so</userinput></screen>67 68 <para>Fix an issue in <command>configure</command> due to missing69 files in the early stages of LFS:</para>70 71 <screen><userinput remap="pre">sed -i -e '/flex/s/as_fn_error/: ;; # &/' configure</userinput></screen>72 -->73 <para>Prepare Bc for compilation:</para>74 <!--75 <screen><userinput remap="configure">./configure - -prefix=/usr \76 - -with-readline \77 - -mandir=/usr/share/man \78 - -infodir=/usr/share/info</userinput></screen>79 -->80 46 <screen><userinput remap="configure">PREFIX=/usr CC=gcc CFLAGS="-std=c99" ./configure.sh -G -O3</userinput></screen> 81 47 82 48 <variablelist> 83 49 <title>The meaning of the configure options:</title> 84 <!-- 85 <varlistentry> 86 <term><parameter>- -with-readline</parameter></term> 87 <listitem> 88 <para>This option tells Bc to use the <filename 89 class="libraryfile">readline</filename> library that is already 90 installed on the system rather than using its own readline 91 version.</para> 92 </listitem> 93 </varlistentry> 94 --> 50 95 51 <varlistentry> 96 52 <term><parameter>CC=gcc CFLAGS="-std=c99"</parameter></term> 97 53 <listitem> 98 <para>These parameters specify the compiler and C standard to use.</para>54 <para>These parameters specify the compiler and the C standard to use.</para> 99 55 </listitem> 100 56 </varlistentry> … … 119 75 120 76 <screen><userinput remap="make">make</userinput></screen> 121 <!--122 <para>To test bc, run the commands below. There is quite a bit of output,123 so you may want to redirect it to a file. There are a very small percentage124 of tests (10 of 12,144) that will indicate a round off error at the last125 digit.</para>126 127 <screen><userinput remap="test">echo "quit" | ./bc/bc -l Test/checklib.b</userinput></screen>128 -->129 77 130 78 <para>To test bc, run:</para> -
chapter06/bzip2.xml
r9d719e2 refcb393 91 91 <screen><userinput remap="install">cp -v bzip2-shared /bin/bzip2 92 92 cp -av libbz2.so* /lib 93 ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so 94 rm -v /usr/bin/{bunzip2,bzcat,bzip2} 95 ln -sv bzip2 /bin/bunzip2 96 ln -sv bzip2 /bin/bzcat</userinput></screen> 93 rm -v /usr/bin/{bunzip2,bzcat,bzip2}</userinput></screen> 97 94 98 95 </sect2> -
chapter06/chapter06.xml
r9d719e2 refcb393 13 13 14 14 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="introduction.xml"/> 15 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="kernfs.xml"/>16 15 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="pkgmgt.xml"/> 17 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="chroot.xml"/> 18 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="creatingdirs.xml"/> 19 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="createfiles.xml"/> 20 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/> 16 <!-- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/>--> 21 17 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="man-pages.xml"/> 18 <!-- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="adjusting.xml"/>--> 22 19 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/> 23 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="adjusting.xml"/>24 20 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zlib.xml"/> 25 21 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="bzip2.xml"/> -
chapter06/check.xml
r9d719e2 refcb393 57 57 (up to 4 SBU) time.</para> 58 58 59 <para>Install the package and fix a script:</para>59 <para>Install the package:</para> 60 60 61 <screen><userinput remap="install">make docdir=/usr/share/doc/check-&check-version; install && 62 sed -i '1 s/tools/usr/' /usr/bin/checkmk</userinput></screen> 63 <!-- Removes a hardcoded call to /tools/bin/gawk at line 1 of checkmk. --> 61 <screen><userinput remap="install">make docdir=/usr/share/doc/check-&check-version; install</userinput></screen> 64 62 65 63 </sect2> -
chapter06/coreutils.xml
r9d719e2 refcb393 124 124 <screen><userinput remap="test">chown -Rv nobody . </userinput></screen> 125 125 126 <para>Now run the tests. Make sure the PATH in the <userinput>su</userinput> 127 environment includes /tools/bin.</para> 126 <para>Now run the tests:</para> 128 127 129 128 <screen><userinput remap="test">su nobody -s /bin/bash \ -
chapter06/e2fsprogs.xml
r9d719e2 refcb393 53 53 <para>Prepare E2fsprogs for compilation:</para> 54 54 55 <!--<screen><userinput remap="configure">LIBS=-L/tools/lib \56 CFLAGS=-I/tools/include \57 CFLAGS=-I/tools/include \58 PKG_CONFIG_PATH=/tools/lib/pkgconfig \59 ../configure - -prefix=/usr \-->60 55 <screen><userinput remap="configure">../configure --prefix=/usr \ 61 56 --bindir=/bin \ … … 69 64 <variablelist> 70 65 <title>The meaning of the environment variable and configure options:</title> 71 <!-- 72 <varlistentry> 73 <term><parameter>PKG_CONFIG_PATH, LIBS, CFLAGS</parameter></term> 74 <listitem> 75 <para>These variables enable e2fsprogs to be built using the 76 <xref linkend="ch-tools-util-linux"/> package built earlier.</para> 77 </listitem> 78 </varlistentry> 79 --> 66 80 67 <varlistentry> 81 68 <term><parameter>--with-root-prefix=""</parameter> and … … 118 105 119 106 <screen><userinput remap="make">make</userinput></screen> 120 <!--121 <para>To set up and run the test suite we need to first link some122 libraries from /tools/lib to a location where the test programs look.123 To run the tests, issue:</para>124 -->125 107 126 108 <para>To run the tests, issue:</para> 127 109 128 110 <screen><userinput remap="test">make check</userinput></screen> 129 <!--ln -sfv /tools/lib/lib{blk,uu}id.so.1 lib -->130 <!--make LD_LIBRARY_PATH=/tools/lib check</userinput></screen>-->131 111 132 112 <para>One of the E2fsprogs tests will attempt to allocate 256 MB of memory. -
chapter06/flex.xml
r9d719e2 refcb393 51 51 Now, prepare Flex for compilation:</para> 52 52 53 <screen><userinput remap="configure">HELP2MAN=/ tools/bin/true \53 <screen><userinput remap="configure">HELP2MAN=/bin/true \ 54 54 ./configure --prefix=/usr --docdir=/usr/share/doc/flex-&flex-version;</userinput></screen> 55 55 -
chapter06/gcc.xml
r9d719e2 refcb393 59 59 <para>Prepare GCC for compilation:</para> 60 60 61 <screen><userinput remap="configure"> SED=sed\62 ../configure --prefix=/usr\61 <screen><userinput remap="configure">../configure --prefix=/usr \ 62 LD=ld \ 63 63 --enable-languages=c,c++ \ 64 64 --disable-multilib \ … … 72 72 73 73 <variablelist> 74 <title>The meaning of the new configure parameters:</title> 75 76 <varlistentry> 77 <term><envar>SED=sed</envar></term> 78 <listitem> 79 <para>Setting this environment variable prevents a hard-coded 80 path to /tools/bin/sed.</para> 81 </listitem> 82 </varlistentry> 83 <!-- 84 <varlistentry> 85 <term><parameter>- -disable-libmpx</parameter></term> 86 <listitem> 87 <para>This switch tells GCC to not build mpx (Memory Protection 88 Extensions) that can cause problems on some processors. It has 89 been removed from the next version of gcc.</para> 90 </listitem> 91 </varlistentry> 92 --> 74 <title>The meaning of the new configure parameter:</title> 75 93 76 <varlistentry> 94 77 <term><parameter>--with-system-zlib</parameter></term> … … 171 154 172 155 <screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen> 173 156 <!-- already done earlier 174 157 <para>Many packages use the name <command>cc</command> to call the C 175 158 compiler. To satisfy those packages, create a symlink:</para> 176 159 177 160 <screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen> 178 161 --> 179 162 <para>Add a compatibility symlink to enable building programs with 180 163 Link Time Optimization (LTO):</para> -
chapter06/glibc.xml
r9d719e2 refcb393 44 44 <title>Installation of Glibc</title> 45 45 46 <note><para>The Glibc build system is self-contained and will install47 perfectly, even though the compiler specs file and linker are still48 pointing to <filename class="directory">/tools</filename>. The specs49 and linker cannot be adjusted before the Glibc install because the50 Glibc autoconf tests would give false results and defeat the goal51 of achieving a clean build.</para></note>52 53 46 <para>Some of the Glibc programs use the non-FHS compliant 54 47 <filename class="directory">/var/db</filename> directory to store … … 67 60 <screen><userinput remap="pre">sed -i '/asm.socket.h/a# include <linux/sockios.h>' \ 68 61 sysdeps/unix/sysv/linux/bits/socket.h</userinput></screen> 69 --> 62 === already done === 70 63 <para>Create a symlink for LSB 71 64 compliance. Additionally, for x86_64, create a compatibility symlink … … 79 72 ;; 80 73 esac</userinput></screen> 81 <!-- 74 82 75 <para>Remove a file that may be left over from a previous build attempt: 83 76 </para> … … 93 86 <para>Prepare Glibc for compilation:</para> 94 87 95 <screen><userinput remap="configure">CC="gcc -ffile-prefix-map=/tools=/usr" \ 96 ../configure --prefix=/usr \ 97 --disable-werror \ 98 --enable-kernel=&min-kernel; \ 99 --enable-stack-protector=strong \ 100 --with-headers=/usr/include \ 88 <screen><userinput remap="configure">../configure --prefix=/usr \ 89 --disable-werror \ 90 --enable-kernel=&min-kernel; \ 91 --enable-stack-protector=strong \ 92 --with-headers=/usr/include \ 101 93 libc_cv_slibdir=/lib</userinput></screen> 102 103 <variablelist>94 <!-- WIP --> 95 <variablelist> 104 96 <title>The meaning of the options and new configure parameters:</title> 105 97 106 98 <varlistentry> 107 <term><parameter>CC="gcc -ffile-prefix-map=/tools=/usr"</parameter></term> 108 <listitem> 109 <para>Make GCC record any references to files in /tools in result 110 of the compilation as if the files resided in /usr. This avoids 111 introduction of invalid paths in debugging symbols.</para> 99 <term><parameter>CC="gcc -ffile-prefix-map=$LFS_DIR=$DIR"</parameter></term> 100 <listitem> 101 <para>Make GCC record any references to files in <filename 102 class="directory">/usr/lib/gcc/x86_64-lfs-linux-gnu</filename> 103 in result of the compilation as if the files resided in <filename 104 class="directory">/usr/lib/gcc/x86_64-pc-linux-gnu</filename>. 105 This avoids introduction of invalid paths in debugging 106 symbols.</para> 112 107 </listitem> 113 108 </varlistentry> … … 129 124 </listitem> 130 125 </varlistentry> 131 126 <!-- do we need this one? --> 132 127 <varlistentry> 133 128 <term><parameter>--with-headers=/usr/include</parameter></term> 134 129 <listitem> 135 130 <para>This option tells the build system where to find the 136 kernel API headers. By default, those headers are sought in 137 <filename class="directory">/tools/include</filename>.</para> 131 kernel API headers.</para> 138 132 </listitem> 139 133 </varlistentry> -
chapter06/introduction.xml
r9d719e2 refcb393 37 37 at the same time.</para> 38 38 39 <para>The order that packages are installed in this chapter needs to be40 strictly followed to ensure that no program accidentally acquires a path41 referring to <filename class="directory">/tools</filename> hard-wired into42 it. For the same reason, do not compile separate packages in parallel.43 Compiling in parallel may save time (especially on dual-CPU machines), but it44 could result in a program containing a hard-wired path to <filename45 class="directory">/tools</filename>, which will cause the program to stop46 working when that directory is removed.</para>47 48 39 <para>Before the installation instructions, each installation page provides 49 40 information about the package, including a concise description of what it -
chapter06/kbd.xml
r9d719e2 refcb393 61 61 <para>Prepare Kbd for compilation:</para> 62 62 63 <screen><userinput remap="configure"> PKG_CONFIG_PATH=/tools/lib/pkgconfig./configure --prefix=/usr --disable-vlock</userinput></screen>63 <screen><userinput remap="configure">./configure --prefix=/usr --disable-vlock</userinput></screen> 64 64 65 65 <variablelist> 66 66 <title>The meaning of the configure options:</title> 67 <!-- 68 <varlistentry> 69 <term><parameter>- -datadir=/lib/kbd</parameter></term> 70 <listitem> 71 <para>This option puts keyboard layout data in a directory that will 72 always be on the root partition instead of the default <filename 73 class="directory">/usr/share/kbd</filename>.</para> 74 </listitem> 75 </varlistentry> 76 --> 67 77 68 <varlistentry> 78 69 <term><parameter>--disable-vlock</parameter></term> … … 105 96 </note> 106 97 107 <!--108 <para>Some of the scripts in the LFS-Bootscripts package depend on109 <command>kbd_mode</command>, <command>loadkeys</command>,110 <command>openvt</command>, and111 <command>setfont</command>. As <filename class="directory">/usr</filename>112 may not be available during the early stages of booting, those binaries113 need to be on the root partition:</para>114 115 <screen><userinput remap="install">mv -v /usr/bin/{kbd_mode,loadkeys,openvt,setfont} /bin</userinput></screen>116 -->117 98 <para>If desired, install the documentation:</para> 118 99 -
chapter06/libpipeline.xml
r9d719e2 refcb393 46 46 <screen><userinput remap="configure">./configure --prefix=/usr</userinput></screen> 47 47 48 <!--49 <screen><userinput remap="configure">PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure - -prefix=/usr</userinput></screen>50 51 <variablelist>52 <title>The meaning of the configure options:</title>53 54 <varlistentry>55 <term><parameter>PKG_CONFIG_PATH</parameter></term>56 <listitem>57 <para>Use pkg-config to obtain the location of the test58 library metadata built in <xref linkend="ch-system-check"/>.</para>59 </listitem>60 </varlistentry>61 62 </variablelist>63 -->64 48 <para>Compile the package:</para> 65 49 -
chapter06/readline.xml
r9d719e2 refcb393 74 74 <para>Compile the package:</para> 75 75 76 <screen><userinput remap="make">make SHLIB_LIBS="- L/tools/lib -lncursesw"</userinput></screen>76 <screen><userinput remap="make">make SHLIB_LIBS="-lncursesw"</userinput></screen> 77 77 78 78 <variablelist> … … 80 80 81 81 <varlistentry> 82 <term><parameter>SHLIB_LIBS="- L/tools/lib -lncursesw"</parameter></term>82 <term><parameter>SHLIB_LIBS="-lncursesw"</parameter></term> 83 83 <listitem> 84 84 <para>This option forces Readline to link against the … … 93 93 <para>Install the package:</para> 94 94 95 <screen><userinput remap="install">make SHLIB_LIBS="- L/tools/lib -lncursesw" install</userinput></screen>95 <screen><userinput remap="install">make SHLIB_LIBS="-lncursesw" install</userinput></screen> 96 96 97 97 <para>Now move the dynamic libraries to a more appropriate location -
chapter06/revisedchroot.xml
r9d719e2 refcb393 27 27 /bin/bash --login</userinput></screen> 28 28 29 <para>The reason for this is that the programs in <filename 30 class="directory">/tools</filename> are no longer needed. For this reason 31 you can delete the <filename class="directory">/tools</filename> 32 directory if so desired.</para> 33 34 <note> 35 <para>Removing <filename class="directory">/tools</filename> will also 36 remove the temporary copies of Tcl, Expect, and DejaGNU which were used 37 for running the toolchain tests. If you need these programs later on, 38 they will need to be recompiled and re-installed. The BLFS book has 39 instructions for this (see <ulink url="&blfs-root;"/>).</para> 40 </note> 29 <para>Here the <parameter>+h</parameter> option is not used anymore, since 30 all the previous programs have been replaced: hashing is therefore 31 possible.</para> 41 32 42 33 <para>If the virtual kernel file systems have been unmounted, either manually -
chapter06/sed.xml
r9d719e2 refcb393 43 43 <para>First fix an issue in the LFS environment and remove a failing test:</para> 44 44 45 <screen><userinput remap="pre">sed -i 's/usr/tools/' build-aux/help2man 46 sed -i 's/testsuite.panic-tests.sh//' Makefile.in</userinput></screen> 45 <screen><userinput remap="pre">sed -i 's/testsuite.panic-tests.sh//' Makefile.in</userinput></screen> 47 46 48 47 <para>Prepare Sed for compilation:</para> 49 48 50 49 <screen><userinput remap="configure">./configure --prefix=/usr --bindir=/bin</userinput></screen> 51 <!--52 <variablelist>53 <title>The meaning of the new configure option:</title>54 50 55 <varlistentry>56 <term><parameter>-i -htmldir</parameter></term>57 <listitem>58 <para>This sets the installation directory for the HTML documentation.</para>59 </listitem>60 </varlistentry>61 </variablelist>62 -->63 51 <para>Compile the package and generate the HTML documentation:</para> 64 52 -
chapter06/shadow.xml
r9d719e2 refcb393 85 85 86 86 <screen><userinput remap="configure">touch /usr/bin/passwd 87 ./configure --sysconfdir=/etc --with-group-name-max-length=32</userinput></screen> 87 ./configure --sysconfdir=/etc \ 88 --with-group-name-max-length=32</userinput></screen> 88 89 89 90 <variablelist> -
chapter06/strippingagain.xml
r9d719e2 refcb393 57 57 unset LIB save_lib save_usrlib</userinput></screen> 58 58 59 <para>Before performing the stripping, take special care to ensure that59 <!-- <para>Before performing the stripping, take special care to ensure that 60 60 none of the binaries that are about to be stripped are running:</para> 61 61 62 62 <screen role="nodump"><userinput>exec /tools/bin/bash</userinput></screen> 63 63 64 <!-- 65 If 66 unsure whether the user entered chroot with the command given in 67 <xref linkend="ch-system-chroot" role=","/> first use the version 68 of bash we created in 69 chroot:</para> 64 <para>Now the binaries and libraries can be safely stripped:</para> 65 --> 66 <para>Now the binaries and libraries can be stripped:</para> 67 <screen><userinput>find /usr/lib -type f -name \*.a \ 68 -exec strip --strip-debug {} ';' 70 69 71 <screen role="nodump"><userinput>logout</userinput></screen> 70 find /lib /usr/lib -type f -name \*.so* ! -name \*dbg \ 71 -exec strip --strip-unneeded {} ';' 72 72 73 <para>Then reenter it with:</para> 74 75 <screen role="nodump"><userinput>chroot $LFS /tools/bin/env -i \ 76 HOME=/root TERM=$TERM \ 77 PS1='(lfs chroot) \u:\w\$ ' \ 78 PATH=/bin:/usr/bin:/sbin:/usr/sbin \ 79 /tools/bin/bash - -login</userinput></screen>--> 80 81 <para>Now the binaries and libraries can be safely stripped:</para> 82 83 <screen><userinput>/tools/bin/find /usr/lib -type f -name \*.a \ 84 -exec /tools/bin/strip --strip-debug {} ';' 85 86 /tools/bin/find /lib /usr/lib -type f \( -name \*.so* -a ! -name \*dbg \) \ 87 -exec /tools/bin/strip --strip-unneeded {} ';' 88 89 /tools/bin/find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \ 90 -exec /tools/bin/strip --strip-all {} ';'</userinput></screen> 73 find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \ 74 -exec strip --strip-all {} ';'</userinput></screen> 91 75 92 76 <para>A large number of files will be reported as having their file -
chapter06/systemd.xml
r9d719e2 refcb393 49 49 <para>Create a symlink to work around missing xsltproc:</para> 50 50 51 <screen><userinput remap="pre">ln -sf / tools/bin/true /usr/bin/xsltproc</userinput></screen>51 <screen><userinput remap="pre">ln -sf /bin/true /usr/bin/xsltproc</userinput></screen> 52 52 53 53 <para>Set up the man pages:</para> … … 102 102 <listitem> 103 103 <para>These switches provide location of binaries needed by 104 systemd at runtime that have not yet been installed, or who's 105 pkgconfig files are currently only in 106 <filename>/tools/lib/pkgconfig</filename>.</para> 104 systemd at runtime that have not yet been installed.</para> 107 105 </listitem> 108 106 </varlistentry> -
chapter06/util-linux.xml
r9d719e2 refcb393 55 55 <sect2 role="installation"> 56 56 <title>Installation of Util-linux</title> 57 <!--58 <para>First, fix one of the regression tests:</para>59 60 <screen><userinput remap="pre">sed -e 's/2^64/(2^64/' -e 's/E </E) <=/' -e 's/ne /eq /' \61 -i tests/ts/ipcs/limits2</userinput></screen>62 -->63 64 <para>Remove the earlier created symlinks and files:</para>65 66 <screen><userinput remap="pre">rm -vf /usr/include/{blkid,libfdisk,libmount,uuid}67 rm -vf /usr/lib/lib{blkid,fdisk,mount,uuid}.so*68 rm -vf /usr/lib/pkgconfig/{blkid,fdisk,mount,uuid}.pc</userinput></screen>69 57 70 58 <para>Prepare Util-linux for compilation:</para> -
chapter08/kernel.xml
r9d719e2 refcb393 300 300 <emphasis>always</emphasis> be the ones against which Glibc was compiled, 301 301 that is, the sanitised headers installed in <xref 302 linkend="ch- system-linux-headers"/>. Therefore, they should302 linkend="ch-tools-linux-headers"/>. Therefore, they should 303 303 <emphasis>never</emphasis> be replaced by either the raw kernel headers 304 304 or any other kernel sanitized headers.</para>
Note:
See TracChangeset
for help on using the changeset viewer.