mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-03-06 06:14:47 +00:00
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:
parent
e625c495b0
commit
1a3e6a31a7
@ -36,6 +36,38 @@
|
||||
</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>
|
||||
<para>2012-04-24</para>
|
||||
<itemizedlist>
|
||||
|
@ -231,10 +231,6 @@
|
||||
<para>&coreutils-i18n-patch;</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>&gcc-startfiles-patch;</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>&glibc-gcc_fix-patch;</para>
|
||||
</listitem>
|
||||
|
@ -58,14 +58,6 @@
|
||||
</listitem>
|
||||
</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>
|
||||
<term>Glibc GCC Fix Patch - <token>&glibc-gcc_fix-patch-size;</token>:</term>
|
||||
<listitem>
|
||||
|
@ -76,14 +76,43 @@ cd ../binutils-build</userinput></screen>
|
||||
|
||||
<para>Now prepare Binutils for compilation:</para>
|
||||
|
||||
<screen><userinput remap="configure">../binutils-&binutils-version;/configure --target=$LFS_TGT \
|
||||
--prefix=/tools \
|
||||
--disable-nls \
|
||||
--disable-werror</userinput></screen>
|
||||
<screen><userinput remap="configure">
|
||||
../binutils-&binutils-version;/configure \
|
||||
--prefix=/tools \
|
||||
--with-sysroot=$LFS \
|
||||
--with-lib-path=/tools/lib \
|
||||
--target=$LFS_TGT \
|
||||
--disable-nls \
|
||||
--disable-werror</userinput></screen>
|
||||
|
||||
<variablelist>
|
||||
<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>
|
||||
<term><envar>--target=$LFS_TGT</envar></term>
|
||||
<listitem>
|
||||
@ -95,15 +124,6 @@ cd ../binutils-build</userinput></screen>
|
||||
</listitem>
|
||||
</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>
|
||||
<term><parameter>--disable-nls</parameter></term>
|
||||
<listitem>
|
||||
|
@ -54,19 +54,20 @@ cd ../binutils-build</userinput></screen>
|
||||
|
||||
<para>Prepare Binutils for compilation:</para>
|
||||
|
||||
<screen><userinput remap="configure">CC="$LFS_TGT-gcc -B/tools/lib/" \
|
||||
AR=$LFS_TGT-ar \
|
||||
RANLIB=$LFS_TGT-ranlib \
|
||||
../binutils-&binutils-version;/configure \
|
||||
--prefix=/tools \
|
||||
--disable-nls \
|
||||
--with-lib-path=/tools/lib</userinput></screen>
|
||||
<screen><userinput remap="configure">
|
||||
CC=$LFS_TGT-gcc \
|
||||
AR=$LFS_TGT-ar \
|
||||
RANLIB=$LFS_TGT-ranlib \
|
||||
../binutils-&binutils-version;/configure \
|
||||
--prefix=/tools \
|
||||
--disable-nls \
|
||||
--with-lib-path=/tools/lib</userinput></screen>
|
||||
|
||||
<variablelist>
|
||||
<title>The meaning of the new configure options:</title>
|
||||
|
||||
<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>
|
||||
<para>Because this is really a native build of Binutils, setting these
|
||||
variables ensures that the build system uses the cross-compiler and
|
||||
|
@ -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="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="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="gcc-pass2.xml"/>
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/>
|
||||
|
@ -62,6 +62,43 @@ mv -v gmp-&gmp-version; gmp
|
||||
tar -zxf ../mpc-&mpc-version;.tar.gz
|
||||
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&@g' \
|
||||
-e 's@/usr@/tools@g' $file.orig > $file
|
||||
echo '
|
||||
#undef STANDARD_STARTFILE_PREFIX_1
|
||||
#undef STANDARD_STARTFILE_PREFIX_2
|
||||
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
|
||||
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
|
||||
touch $file.orig
|
||||
done</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
|
||||
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 \
|
||||
--target=$LFS_TGT \
|
||||
--prefix=/tools \
|
||||
--with-sysroot=$LFS \
|
||||
--with-newlib \
|
||||
--without-headers \
|
||||
--with-local-prefix=/tools \
|
||||
--with-native-system-header-dir=/tools/include \
|
||||
--disable-nls \
|
||||
--disable-shared \
|
||||
--disable-multilib \
|
||||
@ -83,14 +125,53 @@ cd ../gcc-build</userinput></screen>
|
||||
--disable-libgomp \
|
||||
--disable-libquadmath \
|
||||
--enable-languages=c \
|
||||
--without-ppl \
|
||||
--without-cloog \
|
||||
--with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \
|
||||
--with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen>
|
||||
|
||||
<variablelist>
|
||||
<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>
|
||||
<term><parameter>--disable-shared</parameter></term>
|
||||
<listitem>
|
||||
@ -127,15 +208,6 @@ cd ../gcc-build</userinput></screen>
|
||||
</listitem>
|
||||
</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>
|
||||
|
||||
<para>Compile GCC by running:</para>
|
||||
|
@ -43,15 +43,20 @@
|
||||
<sect2 role="installation">
|
||||
<title>Installation of GCC</title>
|
||||
|
||||
<para>Versions of GCC later than 4.3 will treat this build as if
|
||||
it were a relocated compiler and disallow searching for startfiles in
|
||||
the location specified by <parameter>--prefix</parameter>. Since this
|
||||
will not be a relocated compiler, and the startfiles in
|
||||
<filename class="directory">/tools</filename> are crucial to building
|
||||
a working compiler linked to the libs in <filename class="directory">/tools</filename>,
|
||||
apply the following patch which partially reverts GCC to its old behavior:</para>
|
||||
<para>Our first build of GCC has installed a couple of internal system
|
||||
headers. Normally one of them, <filename>limits.h</filename> will in turn
|
||||
include the corresponding system <filename>limits.h</filename> header, in
|
||||
this case, <filename>/tools/include/limits.h</filename>. However, at the
|
||||
time of the first build of gcc <filename>/tools/include/limits.h</filename>
|
||||
did not exist, so the internal header that GCC installed is a partial,
|
||||
self-contained file and does not include the extended features of the
|
||||
system header. This was adequate for building the temporary libc, but this
|
||||
build of GCC now requires the full internal header. Create a full version
|
||||
of the internal header using a command that is identical to what the GCC
|
||||
build system does in normal circumstances:</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 > \
|
||||
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h</userinput></screen>
|
||||
|
||||
<para>Under normal circumstances the GCC <command>fixincludes</command> script
|
||||
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 > gcc/Makefile.in</userin
|
||||
sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \
|
||||
> gcc/Makefile.in</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.
|
||||
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>
|
||||
<para>Once again, change the location of GCC's default dynamic linker to
|
||||
use the one installed in <filename
|
||||
class="directory">/tools</filename>.</para>
|
||||
|
||||
<screen><userinput remap="pre">for file in \
|
||||
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
|
||||
@ -94,40 +94,11 @@ do
|
||||
echo '
|
||||
#undef STANDARD_STARTFILE_PREFIX_1
|
||||
#undef STANDARD_STARTFILE_PREFIX_2
|
||||
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib"
|
||||
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
|
||||
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $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>. 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 > $file
|
||||
done
|
||||
;;
|
||||
esac</userinput></screen>
|
||||
|
||||
<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
|
||||
names:</para>
|
||||
@ -149,12 +120,13 @@ cd ../gcc-build</userinput></screen>
|
||||
|
||||
<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 \
|
||||
RANLIB=$LFS_TGT-ranlib \
|
||||
../gcc-&gcc-version;/configure \
|
||||
--prefix=/tools \
|
||||
--with-local-prefix=/tools \
|
||||
--with-native-system-header-dir=/tools/include \
|
||||
--enable-clocale=gnu \
|
||||
--enable-shared \
|
||||
--enable-threads=posix \
|
||||
@ -164,8 +136,6 @@ RANLIB=$LFS_TGT-ranlib \
|
||||
--disable-multilib \
|
||||
--disable-bootstrap \
|
||||
--disable-libgomp \
|
||||
--without-ppl \
|
||||
--without-cloog \
|
||||
--with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \
|
||||
--with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen>
|
||||
|
||||
|
@ -202,6 +202,42 @@ esac</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(){}' > 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 role="content">
|
||||
|
@ -71,9 +71,8 @@
|
||||
capable hardware.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Careful manipulation of <command>gcc</command>'s
|
||||
<filename>specs</filename> file tells the compiler which target dynamic
|
||||
linker will be used</para>
|
||||
<para>Careful manipulation of the GCC source tells the compiler which target
|
||||
dynamic linker will be used.</para>
|
||||
</listitem>
|
||||
</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,
|
||||
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
|
||||
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
|
||||
@ -136,31 +139,19 @@ checking what linker to use... /tools/i686-lfs-linux-gnu/bin/ld</computeroutput>
|
||||
package—it is very self-sufficient in terms of its build machinery and
|
||||
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 <name of binary> | 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
|
||||
<parameter>--with-lib-path</parameter> configure switch to control
|
||||
<command>ld</command>'s library search path. 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>
|
||||
<command>ld</command>'s library search path.</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. 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
|
||||
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
|
||||
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—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—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>
|
||||
|
@ -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="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="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="file.xml"/>
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="binutils.xml"/>
|
||||
|
@ -156,27 +156,27 @@ cd ../gcc-build</userinput></screen>
|
||||
the same sanity checks as we did earlier in the chapter:</para>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='a'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='b'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='c'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='d'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='e'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='f'])"/>
|
||||
|
||||
<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>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='g'])"/>
|
||||
|
||||
<screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='h'])"/>
|
||||
|
||||
<screen><computeroutput>#include <...> search starts here:
|
||||
@ -217,15 +217,15 @@ cd ../gcc-build</userinput></screen>
|
||||
directory is required to be in place.</para></note>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='i'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='j'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='k'])"/>
|
||||
|
||||
<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
|
||||
@ -246,47 +246,47 @@ SEARCH_DIR("/lib")
|
||||
SEARCH_DIR("/usr/lib");</computeroutput></screen>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='l'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='m'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='n'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='o'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='p'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='q'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='r'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='s'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='t'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='u'])"/>
|
||||
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
href="readjusting.xml"
|
||||
href="adjusting.xml"
|
||||
xpointer="xpointer(//*[@os='v'])"/>
|
||||
|
||||
<para>Finally, move a misplaced file:</para>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!ENTITY version "SVN-20120424">
|
||||
<!ENTITY releasedate "Apr 24, 2012">
|
||||
<!ENTITY version "SVN-20120425">
|
||||
<!ENTITY releasedate "Apr 25, 2012">
|
||||
<!ENTITY copyrightdate "1999-2012"><!-- jhalfs needs a literal dash, not – -->
|
||||
<!ENTITY milestone "7.2">
|
||||
<!ENTITY generic-version "development"> <!-- Use "development", "testing", or "x.y[-pre{x}]" -->
|
||||
|
@ -373,9 +373,9 @@
|
||||
<!ENTITY man-db-ch6-sbu "0.4 SBU">
|
||||
|
||||
<!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-md5 "3feafd75f9bb2132bc5055347329b198">
|
||||
<!ENTITY man-pages-md5 "7d660682e2cf56c9d2195529eb2418d3">
|
||||
<!ENTITY man-pages-home "http://www.kernel.org/doc/man-pages/">
|
||||
<!ENTITY man-pages-ch6-du "21 MB">
|
||||
<!ENTITY man-pages-ch6-sbu "less than 0.1 SBU">
|
||||
|
Loading…
Reference in New Issue
Block a user