Rearrange "How things are going to be done" section. Simplify seds in "Locking in Glibc" and "Re-adjusting the toolchain" sections. Miscellaneous other fixes.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@2931 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
Greg Schafer 2003-10-07 00:41:12 +00:00
parent 04a335156f
commit f57e3d1ad9
8 changed files with 49 additions and 52 deletions

View File

@ -95,6 +95,10 @@
</itemizedlist> </itemizedlist>
</para></listitem> </para></listitem>
<listitem><para>October 6th, 2003 [greg]: Simplify seds in "Locking in Glibc"
and "Re-adjusting the toolchain" sections. Rearrange "How things are going to be
done" section.</para></listitem>
<listitem><para>October 5th, 2003 [greg]: Chapter 5: Add new section "Toolchain <listitem><para>October 5th, 2003 [greg]: Chapter 5: Add new section "Toolchain
technical notes". Integrate and scale back the old "Why we use static linking" technical notes". Integrate and scale back the old "Why we use static linking"
section. Closes Bug 658.</para></listitem> section. Closes Bug 658.</para></listitem>

View File

@ -9,13 +9,13 @@ programs like a compiler, linker and shell to build the new system. Normally
all the required tools are available if you selected <quote>development</quote> all the required tools are available if you selected <quote>development</quote>
as one of the options when you installed your distribution.</para> as one of the options when you installed your distribution.</para>
<para>In Chapter 3 you will first create a new Linux native partition and <para>In Chapter 3 you will first create a new Linux native partition and file
filesystem, the place where your new LFS system will be compiled and installed. system, the place where your new LFS system will be compiled and installed. Then
Then in Chapter 4 you download all the packages and patches required to build in Chapter 4 you download all the packages and patches required to build an LFS
an LFS system, and store them on the new filesystem.</para> system, and store them on the new file system.</para>
<para>Chapter 5 will then discuss the installation of a number of packages that <para>Chapter 5 will then discuss the installation of a number of packages that
will form the basic development suite (or tool-set) which is used to build the will form the basic development suite (or toolchain) which is used to build the
actual system in Chapter 6. Some of these packages are needed to resolve actual system in Chapter 6. Some of these packages are needed to resolve
circular dependencies. For example, to compile a compiler you need a circular dependencies. For example, to compile a compiler you need a
compiler.</para> compiler.</para>
@ -25,35 +25,17 @@ toolchain, which is made up of Binutils and GCC. The programs from these
packages will be linked statically in order for them to be used independently packages will be linked statically in order for them to be used independently
of the host system. The second thing to do is build Glibc, the C library. Glibc of the host system. The second thing to do is build Glibc, the C library. Glibc
will be compiled by the toolchain programs we just built in the first will be compiled by the toolchain programs we just built in the first
pass.</para> pass. The third thing to do is build a second pass of the toolchain. This time
<para>The third thing to do is build a second pass of the toolchain. This time
the toolchain will be dynamically linked against the newly built Glibc. The the toolchain will be dynamically linked against the newly built Glibc. The
remaining Chapter 5 packages are all built using this second pass toolchain and remaining Chapter 5 packages are all built using this second pass toolchain and
dynamically linked against the new host-independent Glibc. When this is done, dynamically linked against the new host-independent Glibc. When this is done,
the LFS installation process will no longer depend on the host distribution, the LFS installation process will no longer depend on the host distribution,
with the exception of the running kernel. This is known as <quote>self with the exception of the running kernel.</para>
contained</quote> and <quote>self hosted</quote>. There is a discussion of the
differences between statically and dynamically linked programs at the beginning
of Chapter 5.</para>
<para>You may be asking yourself <quote>that seems like a lot of work, just to <para>You may be asking yourself <quote>that seems like a lot of work, just to
get away from my host distribution</quote>. Let us take a few minutes to get away from my host distribution?</quote>. A full technical and in-depth
discuss this question. The work involved in building the packages in Chapter 5 explanation is provided at the start of Chapter 5, including some notes on the
is to ensure that as little information as possible from your host makes it into differences between statically and dynamically linked programs.</para>
your brand new LFS system. When you build the first two packages in Chapter 5,
Binutils and GCC, they will be compiled statically. This means that the
version of the C library on your host distribution will be embedded inside all
the binary programs you just compiled. This has the potential to cause
problems for you down the road. The host's Glibc is usually an unknown
quantity and might even contain bugs or anything else we don't know about
until it is too late. A well known issue is that statically linked binaries
compiled on a Glibc-2.2.x based system that contain calls to the
<emphasis>getpwuid()</emphasis> function crash when run on a Glibc-2.3.x based
system. Seeing as we are about to build a Glibc-2.3.x based system, we need to
shield ourselves from problems of this nature. The procedure employed in
Chapter 5 achieves this goal. With all these things in mind, you can see that
the extra effort to compile Binutils and GCC twice is well worth it.</para>
<para>In Chapter 6 your real LFS system will be built. The chroot (change root) <para>In Chapter 6 your real LFS system will be built. The chroot (change root)
program is used to enter a virtual environment and start a new shell whose root program is used to enter a virtual environment and start a new shell whose root

View File

@ -155,7 +155,7 @@ to continue on.</para>
<note><para>At this point it is strongly recommended to repeat the sanity check <note><para>At this point it is strongly recommended to repeat the sanity check
we performed earlier in the chapter. Refer back to the "Locking in" Glibc section we performed earlier in the chapter. Refer back to the "Locking in" Glibc section
and repeat the check. If the results are wrong then most likely, you forgot to and repeat the check. If the results are wrong then most likely, you forgot to
apply the abovementioned GCC Specs patch.</para></note> apply the above mentioned GCC Specs patch.</para></note>
</sect2> </sect2>

View File

@ -23,16 +23,20 @@ Binutils build and source directories.</para>
to the new dynamic linker. A simple sed will accomplish this:</para> to the new dynamic linker. A simple sed will accomplish this:</para>
<para><screen><userinput>SPECFILE=/tools/lib/gcc-lib/*/*/specs <para><screen><userinput>SPECFILE=/tools/lib/gcc-lib/*/*/specs
sed -e 's@/lib/ld.so.1@/tools/lib/ld.so.1@g' \ sed -e 's@/lib/ld-linux.so.2@/tools/lib/ld-linux.so.2@g' \
&nbsp;&nbsp;&nbsp;&nbsp;-e 's@/lib/ld-linux.so.2@/tools/lib/ld-linux.so.2@g' \
&nbsp;&nbsp;&nbsp;&nbsp;$SPECFILE > tempspecfile &nbsp;&nbsp;&nbsp;&nbsp;$SPECFILE > tempspecfile
mv tempspecfile $SPECFILE mv tempspecfile $SPECFILE
unset SPECFILE</userinput></screen></para> unset SPECFILE</userinput></screen></para>
<para>We recommend that you cut-and-paste the above rather than try and type it <para>We recommend that you cut-and-paste the above rather than try and type it
all in. Or you can edit the specs file by hand if you want to: just replace all in. Or you can edit the specs file by hand if you want to: just replace any
"/lib/ld-linux.so.2" with "/tools/lib/ld-linux.so.2" and "/lib/ld.so.1" with occurrence of "/lib/ld-linux.so.2" with "/tools/lib/ld-linux.so.2".</para>
"/tools/lib/ld.so.1".</para>
<important><para>If you are working on a platform where the name of the dynamic
linker is something other than <filename>ld-linux.so.2</filename>, you
<emphasis>must</emphasis> substitute <filename>ld-linux.so.2</filename> with the
name of your platform's dynamic linker in the above commands. Refer back to the
"Toolchain technical notes" section if necessary.</para></important>
<para>Lastly, there is a possibility that some include files from the host <para>Lastly, there is a possibility that some include files from the host
system have found their way into GCC's private include dir. This can happen system have found their way into GCC's private include dir. This can happen

View File

@ -122,8 +122,8 @@ adjusted ld, which has a hard-wired search path limited to
file to point to our new dynamic linker in file to point to our new dynamic linker in
<filename class="directory">/tools/lib</filename>. This last step is <filename class="directory">/tools/lib</filename>. This last step is
<emphasis>vital</emphasis> to the whole process. As mentioned above, a <emphasis>vital</emphasis> to the whole process. As mentioned above, a
hard-wired path to a dynamic linker is embedded into every executable binary. hard-wired path to a dynamic linker is embedded into every ELF shared
You can inspect this by running: executable. You can inspect this by running:
<userinput>`readelf -l &lt;name of binary&gt; | grep interpreter`</userinput>. <userinput>`readelf -l &lt;name of binary&gt; | grep interpreter`</userinput>.
By amending the GCC specs file, we are ensuring that every program compiled from By amending the GCC specs file, we are ensuring that every program compiled from
here through the end of Chapter 5 will use our new dynamic linker in here through the end of Chapter 5 will use our new dynamic linker in

View File

@ -17,8 +17,8 @@ adjusted linker by running the following from within the
<note><para>If you somehow missed the earlier warning to retain the Binutils <note><para>If you somehow missed the earlier warning to retain the Binutils
source and build directories from the second pass in Chapter 5 or otherwise source and build directories from the second pass in Chapter 5 or otherwise
accidentally deleted them or just don't have access to them, don't worry, all is accidentally deleted them or just don't have access to them, don't worry, all is
not lost. Just ignore this step. The result will be that the next package, not lost. Just ignore the above command. The result will be that the next
Binutils, will link against the Glibc libraries in package, Binutils, will link against the Glibc libraries in
<filename class="directory">/tools</filename> rather than <filename class="directory">/tools</filename> rather than
<filename class="directory">/usr</filename>. This is not ideal, however, our <filename class="directory">/usr</filename>. This is not ideal, however, our
testing has shown that the resulting Binutils program binaries should be testing has shown that the resulting Binutils program binaries should be
@ -41,8 +41,7 @@ to the new dynamic linker. Just like earlier on, we use a sed to accomplish
this:</para> this:</para>
<para><screen><userinput>SPECFILE=/tools/lib/gcc-lib/*/*/specs <para><screen><userinput>SPECFILE=/tools/lib/gcc-lib/*/*/specs
sed -e 's@/tools/lib/ld.so.1@/lib/ld.so.1@g' \ sed -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \
&nbsp;&nbsp;&nbsp;&nbsp;-e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \
&nbsp;&nbsp;&nbsp;&nbsp;$SPECFILE > newspecfile &nbsp;&nbsp;&nbsp;&nbsp;$SPECFILE > newspecfile
mv newspecfile $SPECFILE mv newspecfile $SPECFILE
unset SPECFILE</userinput></screen></para> unset SPECFILE</userinput></screen></para>
@ -51,6 +50,12 @@ unset SPECFILE</userinput></screen></para>
before, it is a good idea to check the specs file to ensure the intended before, it is a good idea to check the specs file to ensure the intended
changes were actually made.</para> changes were actually made.</para>
<important><para>If you are working on a platform where the name of the dynamic
linker is something other than <filename>ld-linux.so.2</filename>, you
<emphasis>must</emphasis> substitute <filename>ld-linux.so.2</filename> with the
name of your platform's dynamic linker in the above commands. Refer back to the
"Toolchain technical notes" section if necessary.</para></important>
<caution><para>It is imperative at this point to stop and ensure that the <caution><para>It is imperative at this point to stop and ensure that the
basic functions (compiling and linking) of the adjusted toolchain are working basic functions (compiling and linking) of the adjusted toolchain are working
as expected. For this we are going to perform a simple sanity check:</para> as expected. For this we are going to perform a simple sanity check:</para>

View File

@ -24,7 +24,9 @@ compilers. Instructions for building these can be found at
patch -Np1 -i ../gcc-&gcc-suppress-libiberty-patch-version;.patch</userinput></screen></para> patch -Np1 -i ../gcc-&gcc-suppress-libiberty-patch-version;.patch</userinput></screen></para>
<para>The second patch here suppresses the installation of libiberty from GCC, <para>The second patch here suppresses the installation of libiberty from GCC,
as we will use the one provided by binutils instead.</para> as we will use the one provided by binutils instead. Be careful
<emphasis>not</emphasis> to apply the GCC specs patch from Chapter 5
here.</para>
<para>The GCC documentation recommends building GCC outside of the source <para>The GCC documentation recommends building GCC outside of the source
directory in a dedicated build directory:</para> directory in a dedicated build directory:</para>

View File

@ -3,8 +3,8 @@
"/usr/share/docbook/docbookx.dtd" [ "/usr/share/docbook/docbookx.dtd" [
<!ENTITY version "20031006"> <!ENTITY version "20031007">
<!ENTITY releasedate "October 6th, 2003"> <!ENTITY releasedate "October 7th, 2003">
<!ENTITY nbsp " "> <!ENTITY nbsp " ">
<!ENTITY ftp-root "ftp://ftp.linuxfromscratch.org"> <!ENTITY ftp-root "ftp://ftp.linuxfromscratch.org">