Merge changes developed and tested in the jh branch

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9831 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
Bruce Dubbs 2012-04-25 19:26:21 +00:00
parent e625c495b0
commit 1a3e6a31a7
15 changed files with 257 additions and 196 deletions

View File

@ -36,6 +36,38 @@
</listitem> </listitem>
--> -->
<listitem>
<para>2012-04-25</para>
<itemizedlist>
<listitem>
<para>[bdubbs] - Incorporate changes developed and tested in the jh branch.
</para>
</listitem>
<listitem>
<para>[jhuntwork] - Update chapter 5 toolchain technical notes to match changes
in build method.</para>
</listitem>
<listitem>
<para>[jhuntwork] - Use --with-native-system-header-dir
switch in chapter 5 gcc. This replaces seds that were used previously
to alter the CROSS_SYSTEM_HEADER_DIR and NATIVE_SYSTEM_HEADER_DIR
values to keep the toolchain searching for headers only in
/tools/include and not /usr/include. Thanks to Pierre Labastie. Fixes
<ulink url="&lfs-ticket-root;3066">#3066</ulink>.</para>
</listitem>
<listitem>
<para>[jhuntwork] - Remove --without-cloog and --without-ppl from chapter 5 gcc.
These are unnecessary since it doesn't matter if pass 1 gcc is linked against
host libs and it should be impossible for the build of pass 2 gcc to find host
headers or libs.</para>
</listitem>
<listitem>
<para>[jhuntwork] - Adjust build method to use sysroot.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem> <listitem>
<para>2012-04-24</para> <para>2012-04-24</para>
<itemizedlist> <itemizedlist>

View File

@ -231,10 +231,6 @@
<para>&coreutils-i18n-patch;</para> <para>&coreutils-i18n-patch;</para>
</listitem> </listitem>
<listitem>
<para>&gcc-startfiles-patch;</para>
</listitem>
<listitem> <listitem>
<para>&glibc-gcc_fix-patch;</para> <para>&glibc-gcc_fix-patch;</para>
</listitem> </listitem>

View File

@ -58,14 +58,6 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>GCC Startfiles Fix Patch - <token>&gcc-startfiles-patch-size;</token>:</term>
<listitem>
<para>Download: <ulink url="&patches-root;&gcc-startfiles-patch;"/></para>
<para>MD5 sum: <literal>&gcc-startfiles-patch-md5;</literal></para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>Glibc GCC Fix Patch - <token>&glibc-gcc_fix-patch-size;</token>:</term> <term>Glibc GCC Fix Patch - <token>&glibc-gcc_fix-patch-size;</token>:</term>
<listitem> <listitem>

View File

@ -76,14 +76,43 @@ cd ../binutils-build</userinput></screen>
<para>Now prepare Binutils for compilation:</para> <para>Now prepare Binutils for compilation:</para>
<screen><userinput remap="configure">../binutils-&binutils-version;/configure --target=$LFS_TGT \ <screen><userinput remap="configure">
--prefix=/tools \ ../binutils-&binutils-version;/configure \
--disable-nls \ --prefix=/tools \
--disable-werror</userinput></screen> --with-sysroot=$LFS \
--with-lib-path=/tools/lib \
--target=$LFS_TGT \
--disable-nls \
--disable-werror</userinput></screen>
<variablelist> <variablelist>
<title>The meaning of the configure options:</title> <title>The meaning of the configure options:</title>
<varlistentry>
<term><parameter>--prefix=/tools</parameter></term>
<listitem>
<para>This tells the configure script to prepare to install the
Binutils programs in the <filename class="directory">/tools</filename>
directory.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--with-sysroot=$LFS</parameter></term>
<listitem>
<para>For cross compilation, this tells the build system to look in
$LFS for the target system libraries as needed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--with-lib-path=/tools/lib</parameter></term>
<listitem>
<para>This specifies which library path the linker should be
configured to use.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><envar>--target=$LFS_TGT</envar></term> <term><envar>--target=$LFS_TGT</envar></term>
<listitem> <listitem>
@ -95,15 +124,6 @@ cd ../binutils-build</userinput></screen>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><parameter>--prefix=/tools</parameter></term>
<listitem>
<para>This tells the configure script to prepare to install the
Binutils programs in the <filename class="directory">/tools</filename>
directory.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><parameter>--disable-nls</parameter></term> <term><parameter>--disable-nls</parameter></term>
<listitem> <listitem>

View File

@ -54,19 +54,20 @@ cd ../binutils-build</userinput></screen>
<para>Prepare Binutils for compilation:</para> <para>Prepare Binutils for compilation:</para>
<screen><userinput remap="configure">CC="$LFS_TGT-gcc -B/tools/lib/" \ <screen><userinput remap="configure">
AR=$LFS_TGT-ar \ CC=$LFS_TGT-gcc \
RANLIB=$LFS_TGT-ranlib \ AR=$LFS_TGT-ar \
../binutils-&binutils-version;/configure \ RANLIB=$LFS_TGT-ranlib \
--prefix=/tools \ ../binutils-&binutils-version;/configure \
--disable-nls \ --prefix=/tools \
--with-lib-path=/tools/lib</userinput></screen> --disable-nls \
--with-lib-path=/tools/lib</userinput></screen>
<variablelist> <variablelist>
<title>The meaning of the new configure options:</title> <title>The meaning of the new configure options:</title>
<varlistentry> <varlistentry>
<term><parameter>CC="$LFS_TGT-gcc -B/tools/lib/" AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib</parameter></term> <term><parameter>CC="$LFS_TGT-gcc" AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib</parameter></term>
<listitem> <listitem>
<para>Because this is really a native build of Binutils, setting these <para>Because this is really a native build of Binutils, setting these
variables ensures that the build system uses the cross-compiler and variables ensures that the build system uses the cross-compiler and

View File

@ -18,7 +18,6 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass1.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass1.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="adjusting.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils-pass2.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils-pass2.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/>

View File

@ -62,6 +62,43 @@ mv -v gmp-&gmp-version; gmp
tar -zxf ../mpc-&mpc-version;.tar.gz tar -zxf ../mpc-&mpc-version;.tar.gz
mv -v mpc-&mpc-version; mpc</userinput></screen> mv -v mpc-&mpc-version; mpc</userinput></screen>
<para>The following command will change the location of GCC's default
dynamic linker to use the one installed in <filename
class="directory">/tools</filename>. It also removes <filename
class="directory">/usr/include</filename> from GCC's include search path.
Issue:</para>
<screen><userinput remap="pre">for file in \
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
cp -uv $file{,.orig}
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g' \
-e 's@/usr@/tools@g' $file.orig &gt; $file
echo '
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file
touch $file.orig
done</userinput></screen>
<para>In case the above seems hard to follow, let's break it down a bit.
First we find all the files under the <filename
class="directory">gcc/config</filename> directory that are named either
<filename>linux.h</filename>, <filename>linux64.h</filename> or
<filename>sysv4.h</filename>. For each file found, we copy it to a file of
the same name but with an added suffix of <quote>.orig</quote>. Then the
first sed expression prepends <quote>/tools</quote> to every instance of
<quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or
<quote>/lib32/ld</quote>, while the second one replaces hard-coded
instances of <quote>/usr</quote>. Next, we add our define statements which
alter the default startfile prefix to the end of the file. Note that the
trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required.
Finally, we use <command>touch</command> to update the timestamp on the
copied files. When used in conjunction with <command>cp -u</command>, this
prevents unexpected changes to the original files in case the commands are
inadvertently run twice. </para>
<para>The GCC documentation recommends building GCC outside of the <para>The GCC documentation recommends building GCC outside of the
source directory in a dedicated build directory:</para> source directory in a dedicated build directory:</para>
@ -73,6 +110,11 @@ cd ../gcc-build</userinput></screen>
<screen><userinput remap="configure">../gcc-&gcc-version;/configure \ <screen><userinput remap="configure">../gcc-&gcc-version;/configure \
--target=$LFS_TGT \ --target=$LFS_TGT \
--prefix=/tools \ --prefix=/tools \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
--with-local-prefix=/tools \
--with-native-system-header-dir=/tools/include \
--disable-nls \ --disable-nls \
--disable-shared \ --disable-shared \
--disable-multilib \ --disable-multilib \
@ -83,14 +125,53 @@ cd ../gcc-build</userinput></screen>
--disable-libgomp \ --disable-libgomp \
--disable-libquadmath \ --disable-libquadmath \
--enable-languages=c \ --enable-languages=c \
--without-ppl \
--without-cloog \
--with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \ --with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \
--with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen> --with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen>
<variablelist> <variablelist>
<title>The meaning of the configure options:</title> <title>The meaning of the configure options:</title>
<varlistentry>
<term><parameter>--with-newlib</parameter></term>
<listitem>
<para>Since a working C library is not yet available, this ensures
that the inhibit_libc constant is defined when building libgcc. This prevents
the compiling of any code that requires libc support.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--without-headers</parameter></term>
<listitem>
<para>When creating a complete cross-compiler, GCC requires
standard headers compatible with the target system. For our
purposes these headers will not be needed. This switch prevents
GCC from looking for them.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--with-local-prefix=/tools</parameter></term>
<listitem>
<para>The local prefix is the location in the system that GCC will search
for locally installed include files. The default is <filename>/usr/local</filename>.
Setting this to <filename>/tools</filename> helps keep the host location of
<filename>/usr/local</filename> out of this GCC's search path.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--with-native-system-header-dir=/tools/include</parameter></term>
<listitem>
<para>By default GCC searches <filename>/usr/include</filename> for system
headers. In conjunction with the sysroot switch, this would translate normally
to <filename>$LFS/usr/include</filename>. However the headers that will be installed
in the next two sections will go to <filename>$LFS/tools/include</filename>. This
switch ensures that gcc will find them correctly. In the second pass of GCC, this
same switch will ensure that no headers from the host system are found.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><parameter>--disable-shared</parameter></term> <term><parameter>--disable-shared</parameter></term>
<listitem> <listitem>
@ -127,15 +208,6 @@ cd ../gcc-build</userinput></screen>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><parameter>--without-ppl, --without-cloog</parameter></term>
<listitem>
<para>These switches prevent GCC from building against the PPL and
CLooG libraries which may be present on the host system, but will not
be available in the chroot environment.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
<para>Compile GCC by running:</para> <para>Compile GCC by running:</para>

View File

@ -43,15 +43,20 @@
<sect2 role="installation"> <sect2 role="installation">
<title>Installation of GCC</title> <title>Installation of GCC</title>
<para>Versions of GCC later than 4.3 will treat this build as if <para>Our first build of GCC has installed a couple of internal system
it were a relocated compiler and disallow searching for startfiles in headers. Normally one of them, <filename>limits.h</filename> will in turn
the location specified by <parameter>--prefix</parameter>. Since this include the corresponding system <filename>limits.h</filename> header, in
will not be a relocated compiler, and the startfiles in this case, <filename>/tools/include/limits.h</filename>. However, at the
<filename class="directory">/tools</filename> are crucial to building time of the first build of gcc <filename>/tools/include/limits.h</filename>
a working compiler linked to the libs in <filename class="directory">/tools</filename>, did not exist, so the internal header that GCC installed is a partial,
apply the following patch which partially reverts GCC to its old behavior:</para> self-contained file and does not include the extended features of the
system header. This was adequate for building the temporary libc, but this
build of GCC now requires the full internal header. Create a full version
of the internal header using a command that is identical to what the GCC
build system does in normal circumstances:</para>
<screen><userinput remap="pre">patch -Np1 -i ../&gcc-startfiles-patch;</userinput></screen> <screen><userinput remap="pre">cat gcc/limitx.h gcc/glimits.h gcc/limity.h &gt; \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h</userinput></screen>
<para>Under normal circumstances the GCC <command>fixincludes</command> script <para>Under normal circumstances the GCC <command>fixincludes</command> script
is run in order to fix potentially broken header files. As GCC-&gcc-version; is run in order to fix potentially broken header files. As GCC-&gcc-version;
@ -76,14 +81,9 @@ sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig &gt; gcc/Makefile.in</userin
sed 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in.tmp \ sed 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in.tmp \
&gt; gcc/Makefile.in</userinput></screen> &gt; gcc/Makefile.in</userinput></screen>
<para>The following command will change the location of GCC's default <para>Once again, change the location of GCC's default dynamic linker to
dynamic linker to use the one installed in use the one installed in <filename
<filename class="directory">/tools</filename>. It also removes <filename class="directory">/tools</filename>.</para>
class="directory">/usr/include</filename> from GCC's include search path.
Doing this now rather than adjusting the specs file after installation
ensures that the new dynamic linker is used during the actual build of
GCC. That is, all of the binaries created during the build will link
against the new Glibc. Issue:</para>
<screen><userinput remap="pre">for file in \ <screen><userinput remap="pre">for file in \
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h) $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
@ -94,40 +94,11 @@ do
echo ' echo '
#undef STANDARD_STARTFILE_PREFIX_1 #undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2 #undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib" #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file #define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file
touch $file.orig touch $file.orig
done</userinput></screen> done</userinput></screen>
<para>In case the above seems hard to follow, let's break it down a bit.
First we find all the files under the
<filename class="directory">gcc/config</filename> directory that are named
either <filename>linux.h</filename>, <filename>linux64.h</filename> or
<filename>sysv4.h</filename>.
For each file found, we copy it to a file of the same name but with an added
suffix of <quote>.orig</quote>. Then the first sed expression prepends
<quote>/tools</quote> to every instance of <quote>/lib/ld</quote>,
<quote>/lib64/ld</quote> or <quote>/lib32/ld</quote>, while the second one
replaces hard-coded instances of <quote>/usr</quote>. Then we add our define
statements which alter the include search path and the default startfile prefix
to the end of the file.
Finally, we use <command>touch</command> to update the timestamp on the copied files.
When used in conjunction with <command>cp -u</command>, this prevents unexpected
changes to the original files in case the commands are inadvertently run twice.
</para>
<para>On x86_64, unsetting the multilib spec for GCC ensures that it
won't attempt to link against libraries on the host:</para>
<screen><userinput remap="pre">case $(uname -m) in
x86_64)
for file in $(find gcc/config -name t-linux64) ; do \
cp -v $file{,.orig}
sed '/MULTILIB_OSDIRNAMES/d' $file.orig &gt; $file
done
;;
esac</userinput></screen>
<para>As in the first build of GCC it requires the GMP, MPFR and MPC <para>As in the first build of GCC it requires the GMP, MPFR and MPC
packages. Unpack the tarballs and move them into the required directory packages. Unpack the tarballs and move them into the required directory
names:</para> names:</para>
@ -149,12 +120,13 @@ cd ../gcc-build</userinput></screen>
<para>Now prepare GCC for compilation:</para> <para>Now prepare GCC for compilation:</para>
<screen><userinput remap="configure">CC="$LFS_TGT-gcc -B/tools/lib/" \ <screen><userinput remap="configure">CC="$LFS_TGT-gcc" \
AR=$LFS_TGT-ar \ AR=$LFS_TGT-ar \
RANLIB=$LFS_TGT-ranlib \ RANLIB=$LFS_TGT-ranlib \
../gcc-&gcc-version;/configure \ ../gcc-&gcc-version;/configure \
--prefix=/tools \ --prefix=/tools \
--with-local-prefix=/tools \ --with-local-prefix=/tools \
--with-native-system-header-dir=/tools/include \
--enable-clocale=gnu \ --enable-clocale=gnu \
--enable-shared \ --enable-shared \
--enable-threads=posix \ --enable-threads=posix \
@ -164,8 +136,6 @@ RANLIB=$LFS_TGT-ranlib \
--disable-multilib \ --disable-multilib \
--disable-bootstrap \ --disable-bootstrap \
--disable-libgomp \ --disable-libgomp \
--without-ppl \
--without-cloog \
--with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \ --with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \
--with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen> --with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen>

View File

@ -202,6 +202,42 @@ esac</userinput></screen>
<screen><userinput remap="install">make install</userinput></screen> <screen><userinput remap="install">make install</userinput></screen>
<caution>
<para>At this point, it is imperative to stop and ensure that the basic
functions (compiling and linking) of the new toolchain are working as
expected. To perform a sanity check, run the following commands:</para>
<screen><userinput>echo 'main(){}' &gt; dummy.c
$LFS_TGT-gcc dummy.c
readelf -l a.out | grep ': /tools'</userinput></screen>
<para>If everything is working correctly, there should be no errors,
and the output of the last command will be of the form:</para>
<screen><computeroutput>[Requesting program interpreter: /tools/lib/ld-linux.so.2]</computeroutput></screen>
<para>Note that <filename class="directory">/tools/lib</filename>, or
<filename class="directory">/tools/lib64</filename> for 64-bit machines
appears as the prefix of the dynamic linker.</para>
<para>If the output is not shown as above or there was no output at all,
then something is wrong. Investigate and retrace the steps to find out
where the problem is and correct it. This issue must be resolved before
continuing on. Something may have gone wrong with the specs file amendment
above. In this case, redo the specs file amendment, being careful to
copy-and-paste the commands.</para>
<para>Once all is well, clean up the test files:</para>
<screen><userinput>rm -v dummy.c a.out</userinput></screen>
</caution>
<note><para>Building Binutils in the next section will serve as an additional check that
the toolchain has been built properly. If Binutils fails to build, it is an
indication that something has gone wrong with the previous Binutils, GCC, or Glibc
installations.</para></note>
</sect2> </sect2>
<sect2 role="content"> <sect2 role="content">

View File

@ -71,9 +71,8 @@
capable hardware.</para> capable hardware.</para>
</listitem> </listitem>
<listitem> <listitem>
<para>Careful manipulation of <command>gcc</command>'s <para>Careful manipulation of the GCC source tells the compiler which target
<filename>specs</filename> file tells the compiler which target dynamic dynamic linker will be used.</para>
linker will be used</para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
@ -118,6 +117,10 @@ checking what linker to use... /tools/i686-lfs-linux-gnu/bin/ld</computeroutput>
detailed information about the preprocessor, compilation, and assembly stages, detailed information about the preprocessor, compilation, and assembly stages,
including <command>gcc</command>'s included search paths and their order.</para> including <command>gcc</command>'s included search paths and their order.</para>
<para>Next installed are sanitized Linux API headers. These allow the standard
C library (Glibc) to interface with features that the Linux kernel will
provide.</para>
<para>The next package installed is Glibc. The most important considerations <para>The next package installed is Glibc. The most important considerations
for building Glibc are the compiler, binary tools, and kernel headers. The for building Glibc are the compiler, binary tools, and kernel headers. The
compiler is generally not an issue since Glibc will always use the compiler compiler is generally not an issue since Glibc will always use the compiler
@ -136,31 +139,19 @@ checking what linker to use... /tools/i686-lfs-linux-gnu/bin/ld</computeroutput>
package&mdash;it is very self-sufficient in terms of its build machinery and package&mdash;it is very self-sufficient in terms of its build machinery and
generally does not rely on toolchain defaults.</para> generally does not rely on toolchain defaults.</para>
<para>After the Glibc installation, change <command>gcc</command>'s specs file
to point to the new dynamic linker in <filename
class="directory">/tools/lib</filename>. This last step is vital in ensuring
that searching and linking take place only within the <filename
class="directory">/tools</filename> prefix. A hard-wired
path to a dynamic linker is embedded into every Executable and Link Format
(ELF)-shared executable. This can be inspected by running:
<userinput>readelf -l &lt;name of binary&gt; | grep interpreter</userinput>.
Amending <command>gcc</command>'s specs file ensures that every program
compiled from here through the end of this chapter will use the new dynamic
linker in <filename class="directory">/tools/lib</filename>.</para>
<para>For the second pass of GCC, its sources also need to be modified
to tell GCC to use the new dynamic linker. Failure to do
so will result in the GCC programs themselves having the name of the
dynamic linker from the host system's <filename
class="directory">/lib</filename> directory embedded into them, which
would defeat the goal of getting away from the host.</para>
<para>During the second pass of Binutils, we are able to utilize the <para>During the second pass of Binutils, we are able to utilize the
<parameter>--with-lib-path</parameter> configure switch to control <parameter>--with-lib-path</parameter> configure switch to control
<command>ld</command>'s library search path. From this point onwards, <command>ld</command>'s library search path.</para>
the core toolchain is self-contained and self-hosted. The remainder of
the <xref linkend="chapter-temporary-tools"/> packages all build against <para>For the second pass of GCC, its sources also need to be modified to
the new Glibc in <filename class="directory">/tools</filename>.</para> tell GCC to use the new dynamic linker. Failure to do so will result in the
GCC programs themselves having the name of the dynamic linker from the host
system's <filename class="directory">/lib</filename> directory embedded into
them, which would defeat the goal of getting away from the host. From this
point onwards, the core toolchain is self-contained and self-hosted. The
remainder of the <xref linkend="chapter-temporary-tools"/> packages all build
against the new Glibc in <filename
class="directory">/tools</filename>.</para>
<para>Upon entering the chroot environment in <xref <para>Upon entering the chroot environment in <xref
linkend="chapter-building-system"/>, the first major package to be linkend="chapter-building-system"/>, the first major package to be
@ -170,52 +161,4 @@ checking what linker to use... /tools/i686-lfs-linux-gnu/bin/ld</computeroutput>
toolchain defaults, and then proceed in building the rest of the target toolchain defaults, and then proceed in building the rest of the target
LFS system.</para> LFS system.</para>
<!-- FIXME: Removed as part of the fix for bug 1061 - we no longer build pass1
packages statically, therefore this explanation isn't required
<sect2>
<title>Notes on Static Linking</title>
<para>Besides their specific task, most programs have to perform many
common and sometimes trivial operations. These include allocating
memory, searching directories, reading and writing files, string
handling, pattern matching, arithmetic, and other tasks. Instead of
obliging each program to reinvent the wheel, the GNU system provides
all these basic functions in ready-made libraries. The major library
on any Linux system is Glibc.</para>
<para>There are two primary ways of linking the functions from a
library to a program that uses them&mdash;statically or dynamically. When
a program is linked statically, the code of the used functions is
included in the executable, resulting in a rather bulky program. When
a program is dynamically linked, it includes a reference to the
dynamic linker, the name of the library, and the name of the function,
resulting in a much smaller executable. A third option is to use the
programming interface of the dynamic linker (see <filename>dlopen(3)</filename>
for more information).</para>
<para>Dynamic linking is the default on Linux and has three major
advantages over static linking. First, only one copy of the executable
library code is needed on the hard disk, instead of having multiple
copies of the same code included in several programs, thus saving
disk space. Second, when several programs use the same library
function at the same time, only one copy of the function's code is
required in core, thus saving memory space. Third, when a library
function gets a bug fixed or is otherwise improved, only the one
library needs to be recompiled instead of recompiling all programs
that make use of the improved function.</para>
<para>If dynamic linking has several advantages, why then do we
statically link the first two packages in this chapter? The reasons
are threefold&mdash;historical, educational, and technical. The
historical reason is that earlier versions of LFS statically linked
every program in this chapter. Educationally, knowing the difference
between static and dynamic linking is useful. The technical benefit is
a gained element of independence from the host, meaning that those
programs can be used independently of the host system. However, it is
worth noting that an overall successful LFS build can still be
achieved when the first two packages are built dynamically.</para>
</sect2>-->
</sect1> </sect1>

View File

@ -20,7 +20,7 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="linux-headers.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="man-pages.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="man-pages.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="readjusting.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="adjusting.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zlib.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zlib.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils.xml"/>

View File

@ -156,27 +156,27 @@ cd ../gcc-build</userinput></screen>
the same sanity checks as we did earlier in the chapter:</para> the same sanity checks as we did earlier in the chapter:</para>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='a'])"/> xpointer="xpointer(//*[@os='a'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='b'])"/> xpointer="xpointer(//*[@os='b'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='c'])"/> xpointer="xpointer(//*[@os='c'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='d'])"/> xpointer="xpointer(//*[@os='d'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='e'])"/> xpointer="xpointer(//*[@os='e'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='f'])"/> xpointer="xpointer(//*[@os='f'])"/>
<screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded <screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
@ -193,13 +193,13 @@ cd ../gcc-build</userinput></screen>
<filename class="directory">/usr/lib</filename> directory.</para> <filename class="directory">/usr/lib</filename> directory.</para>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='g'])"/> xpointer="xpointer(//*[@os='g'])"/>
<screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen> <screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='h'])"/> xpointer="xpointer(//*[@os='h'])"/>
<screen><computeroutput>#include &lt;...&gt; search starts here: <screen><computeroutput>#include &lt;...&gt; search starts here:
@ -217,15 +217,15 @@ cd ../gcc-build</userinput></screen>
directory is required to be in place.</para></note> directory is required to be in place.</para></note>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='i'])"/> xpointer="xpointer(//*[@os='i'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='j'])"/> xpointer="xpointer(//*[@os='j'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='k'])"/> xpointer="xpointer(//*[@os='k'])"/>
<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib") <screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
@ -246,47 +246,47 @@ SEARCH_DIR("/lib")
SEARCH_DIR("/usr/lib");</computeroutput></screen> SEARCH_DIR("/usr/lib");</computeroutput></screen>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='l'])"/> xpointer="xpointer(//*[@os='l'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='m'])"/> xpointer="xpointer(//*[@os='m'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='n'])"/> xpointer="xpointer(//*[@os='n'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='o'])"/> xpointer="xpointer(//*[@os='o'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='p'])"/> xpointer="xpointer(//*[@os='p'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='q'])"/> xpointer="xpointer(//*[@os='q'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='r'])"/> xpointer="xpointer(//*[@os='r'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='s'])"/> xpointer="xpointer(//*[@os='s'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='t'])"/> xpointer="xpointer(//*[@os='t'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='u'])"/> xpointer="xpointer(//*[@os='u'])"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="readjusting.xml" href="adjusting.xml"
xpointer="xpointer(//*[@os='v'])"/> xpointer="xpointer(//*[@os='v'])"/>
<para>Finally, move a misplaced file:</para> <para>Finally, move a misplaced file:</para>

View File

@ -1,5 +1,5 @@
<!ENTITY version "SVN-20120424"> <!ENTITY version "SVN-20120425">
<!ENTITY releasedate "Apr 24, 2012"> <!ENTITY releasedate "Apr 25, 2012">
<!ENTITY copyrightdate "1999-2012"><!-- jhalfs needs a literal dash, not &ndash; --> <!ENTITY copyrightdate "1999-2012"><!-- jhalfs needs a literal dash, not &ndash; -->
<!ENTITY milestone "7.2"> <!ENTITY milestone "7.2">
<!ENTITY generic-version "development"> <!-- Use "development", "testing", or "x.y[-pre{x}]" --> <!ENTITY generic-version "development"> <!-- Use "development", "testing", or "x.y[-pre{x}]" -->

View File

@ -373,9 +373,9 @@
<!ENTITY man-db-ch6-sbu "0.4 SBU"> <!ENTITY man-db-ch6-sbu "0.4 SBU">
<!ENTITY man-pages-version "3.39"> <!ENTITY man-pages-version "3.39">
<!ENTITY man-pages-size "1,047 KB"> <!ENTITY man-pages-size "1,048 KB">
<!ENTITY man-pages-url "http://www.kernel.org/pub/linux/docs/man-pages/man-pages-&man-pages-version;.tar.xz"> <!ENTITY man-pages-url "http://www.kernel.org/pub/linux/docs/man-pages/man-pages-&man-pages-version;.tar.xz">
<!ENTITY man-pages-md5 "3feafd75f9bb2132bc5055347329b198"> <!ENTITY man-pages-md5 "7d660682e2cf56c9d2195529eb2418d3">
<!ENTITY man-pages-home "http://www.kernel.org/doc/man-pages/"> <!ENTITY man-pages-home "http://www.kernel.org/doc/man-pages/">
<!ENTITY man-pages-ch6-du "21 MB"> <!ENTITY man-pages-ch6-du "21 MB">
<!ENTITY man-pages-ch6-sbu "less than 0.1 SBU"> <!ENTITY man-pages-ch6-sbu "less than 0.1 SBU">