aboutsummaryrefslogtreecommitdiffstats
path: root/chapter05/gcc-pass1.xml
diff options
context:
space:
mode:
Diffstat (limited to 'chapter05/gcc-pass1.xml')
-rw-r--r--chapter05/gcc-pass1.xml120
1 files changed, 23 insertions, 97 deletions
diff --git a/chapter05/gcc-pass1.xml b/chapter05/gcc-pass1.xml
index d209cd44f..1bd308f09 100644
--- a/chapter05/gcc-pass1.xml
+++ b/chapter05/gcc-pass1.xml
@@ -43,7 +43,7 @@
<sect2 role="installation">
<title>Installation of Cross GCC</title>
- <para>GCC now requires the GMP, MPFR and MPC packages. As these packages may
+ <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
not be included in your host distribution, they will be built with
GCC. Unpack each package into the GCC source directory and rename the
resulting directories so the GCC build procedures will automatically
@@ -62,42 +62,7 @@ mv -v gmp-&gmp-version; gmp
tar -xf ../mpc-&mpc-version;.tar.gz
mv -v mpc-&mpc-version; mpc</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 gcc/config/{linux,i386/linux{,64}}.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 copy the files <filename>gcc/config/linux.h</filename>,
- <filename>gcc/config/i386/linux.h</filename>, and
- <filename>gcc/config/i386/linux64.h</filename> 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>Finally, on x86_64 hosts, set the default directory name for
+ <para>On x86_64 hosts, set the default directory name for
64-bit libraries to <quote>lib</quote>:</para>
<screen><userinput remap="pre">case $(uname -m) in
@@ -107,19 +72,6 @@ done</userinput></screen>
;;
esac</userinput></screen>
-<!--
- <para>GCC doesn't detect stack protection correctly, which causes problems
- for the build of Glibc-&glibc-version;, so fix that by issuing the following
- command:</para>
-
-<screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen>
--->
-
-<!--
- <para>Also fix a problem identified upstream:</para>
-
-<screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&amp;\&amp; \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>
--->
<para>The GCC documentation recommends building GCC
in a dedicated build directory:</para>
@@ -130,13 +82,12 @@ cd build</userinput></screen>
<screen><userinput remap="configure">../configure \
--target=$LFS_TGT \
- --prefix=/tools \
+ --prefix=$LFS/tools \
--with-glibc-version=2.11 \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
- --with-local-prefix=/tools \
- --with-native-system-header-dir=/tools/include \
+ --enable-initfini-array \
--disable-nls \
--disable-shared \
--disable-multilib \
@@ -181,35 +132,11 @@ cd build</userinput></screen>
</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
- normally translate 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>
<para>This switch forces GCC to link its internal libraries
- statically. We do this to avoid possible issues with the host
- system.</para>
+ statically. We need this because the shared libraries require glibc,
+ which is not yet installed on the target system.</para>
</listitem>
</varlistentry>
@@ -249,26 +176,25 @@ cd build</userinput></screen>
<screen><userinput remap="make">make</userinput></screen>
- <para>Compilation is now complete. At this point, the test suite would
- normally be run, but, as mentioned before, the test suite framework is
- not in place yet. The benefits of running the tests at this point
- are minimal since the programs from this first pass will soon be
- replaced.</para>
-
<para>Install the package:</para>
-<screen><userinput remap="install">make install</userinput></screen>
-<!--
- <para>Using <parameter>- -disable-shared</parameter> means that the
- <filename>libgcc_eh.a</filename> file isn't created and installed. The
- Glibc package depends on this library as it uses
- <parameter>-lgcc_eh</parameter> within its build system. This dependency
- can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
- since that file will end up containing the objects normally contained in
- <filename>libgcc_eh.a</filename>:</para>
-
-<screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&amp;_eh/'`</userinput></screen>
--->
+ <screen><userinput remap="install">make install</userinput></screen>
+
+ <para>This build of GCC has installed a couple of internal system
+ headers. Normally one of them, <filename>limits.h</filename>, would in turn
+ include the corresponding system <filename>limits.h</filename> header, in
+ this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
+ time of this build of gcc <filename>$LFS/usr/include/limits.h</filename>
+ does not exist, so the internal header that has just been installed is a
+ partial, self-contained file and does not include the extended features of
+ the system header. This is adequate for building glibc, but the full
+ internal header will be needed later. Create a full version of the internal
+ header using a command that is identical to what the GCC build system does
+ in normal circumstances:</para>
+
+<screen><userinput remap="install">cd ..
+cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
+ `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
</sect2>
<sect2 role="content">