2004-05-03 11:59:46 +01:00
|
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2007-03-21 18:42:58 +00:00
|
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
2004-05-03 11:59:46 +01:00
|
|
|
<!ENTITY % general-entities SYSTEM "../general.ent">
|
|
|
|
%general-entities;
|
|
|
|
]>
|
2006-01-20 21:02:23 +00:00
|
|
|
|
2004-05-16 01:06:08 +01:00
|
|
|
<sect1 id="ch-tools-gcc-pass1" role="wrap">
|
2006-01-20 21:02:23 +00:00
|
|
|
<?dbhtml filename="gcc-pass1.html"?>
|
|
|
|
|
2007-09-07 20:16:43 +01:00
|
|
|
<sect1info condition="script">
|
|
|
|
<productname>gcc</productname>
|
|
|
|
<productnumber>&gcc-version;</productnumber>
|
|
|
|
<address>&gcc-url;</address>
|
|
|
|
</sect1info>
|
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<title>GCC-&gcc-version; - Pass 1</title>
|
|
|
|
|
|
|
|
<indexterm zone="ch-tools-gcc-pass1">
|
|
|
|
<primary sortas="a-GCC">GCC</primary>
|
|
|
|
<secondary>tools, pass 1</secondary>
|
|
|
|
</indexterm>
|
|
|
|
|
|
|
|
<sect2 role="package">
|
|
|
|
<title/>
|
2003-05-02 19:20:20 +01:00
|
|
|
|
2010-04-21 21:16:28 +01:00
|
|
|
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
2006-01-20 21:02:23 +00:00
|
|
|
href="../chapter06/gcc.xml"
|
|
|
|
xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
|
2005-02-19 22:16:42 +00:00
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<segmentedlist>
|
|
|
|
<segtitle>&buildtime;</segtitle>
|
|
|
|
<segtitle>&diskspace;</segtitle>
|
2004-01-12 23:23:50 +00:00
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<seglistitem>
|
2006-05-14 21:16:56 +01:00
|
|
|
<seg>&gcc-ch5p1-sbu;</seg>
|
|
|
|
<seg>&gcc-ch5p1-du;</seg>
|
2006-01-20 21:02:23 +00:00
|
|
|
</seglistitem>
|
|
|
|
</segmentedlist>
|
2004-05-03 11:59:46 +01:00
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
</sect2>
|
2003-11-01 22:31:50 +00:00
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<sect2 role="installation">
|
2008-12-05 20:46:02 +00:00
|
|
|
<title>Installation of Cross GCC</title>
|
2003-11-01 22:31:50 +00:00
|
|
|
|
2010-04-20 21:08:12 +01:00
|
|
|
<para>GCC now requires the GMP, MPFR and MPC packages. As these packages may
|
2008-10-03 21:14:18 +01:00
|
|
|
not be included in your host distribution, they will be built with
|
2010-10-27 02:20:20 +01:00
|
|
|
GCC. Unpack each package into the GCC source directory and rename the
|
|
|
|
resulting directories so the GCC build procedures will automatically
|
|
|
|
use them:</para>
|
2008-10-03 21:14:18 +01:00
|
|
|
|
2012-02-01 18:17:30 +00:00
|
|
|
<note><para>There are frequent misunderstandings about this chapter. The
|
|
|
|
procedures are the same as every other chapter as explained earlier (<xref
|
|
|
|
linkend='buildinstr'/>). First extract the gcc tarball from the sources
|
|
|
|
directory and then change to the directory created. Only then should you
|
|
|
|
proceed with the instructions below.</para></note>
|
|
|
|
|
2014-04-08 03:52:50 +01:00
|
|
|
<screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
|
2009-05-24 00:00:57 +01:00
|
|
|
mv -v mpfr-&mpfr-version; mpfr
|
2014-04-08 03:52:50 +01:00
|
|
|
tar -xf ../gmp-&gmp-version;.tar.xz
|
|
|
|
mv -v gmp-&gmp-extracted-version; gmp
|
|
|
|
tar -xf ../mpc-&mpc-version;.tar.gz
|
2010-04-20 21:08:12 +01:00
|
|
|
mv -v mpc-&mpc-version; mpc</userinput></screen>
|
2008-10-03 21:14:18 +01:00
|
|
|
|
2012-04-25 20:26:21 +01:00
|
|
|
<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>
|
2015-03-31 22:25:42 +01:00
|
|
|
<!--
|
2012-08-05 15:25:02 +01:00
|
|
|
<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>
|
2015-03-31 22:25:42 +01:00
|
|
|
-->
|
|
|
|
|
2014-10-31 16:27:24 +00:00
|
|
|
<!--
|
2014-08-03 17:37:17 +01:00
|
|
|
<para>Also fix a problem identified upstream:</para>
|
|
|
|
|
|
|
|
<screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&\& \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>
|
2014-10-31 16:27:24 +00:00
|
|
|
-->
|
2006-01-20 21:02:23 +00:00
|
|
|
<para>The GCC documentation recommends building GCC outside of the
|
|
|
|
source directory in a dedicated build directory:</para>
|
2004-12-22 12:06:22 +00:00
|
|
|
|
2007-09-18 22:11:00 +01:00
|
|
|
<screen><userinput remap="pre">mkdir -v ../gcc-build
|
2003-11-01 22:31:50 +00:00
|
|
|
cd ../gcc-build</userinput></screen>
|
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<para>Prepare GCC for compilation:</para>
|
2003-11-01 22:31:50 +00:00
|
|
|
|
2015-04-20 12:20:56 +01:00
|
|
|
<screen><userinput remap="configure">../gcc-&gcc-version;/configure \
|
|
|
|
--target=$LFS_TGT \
|
|
|
|
--prefix=/tools \
|
|
|
|
--with-glibc-version=2.11 \
|
|
|
|
--with-sysroot=$LFS \
|
|
|
|
--with-newlib \
|
|
|
|
--without-headers \
|
|
|
|
--with-local-prefix=/tools \
|
|
|
|
--with-native-system-header-dir=/tools/include \
|
|
|
|
--disable-nls \
|
|
|
|
--disable-shared \
|
|
|
|
--disable-multilib \
|
|
|
|
--disable-decimal-float \
|
|
|
|
--disable-threads \
|
|
|
|
--disable-libatomic \
|
|
|
|
--disable-libgomp \
|
|
|
|
--disable-libquadmath \
|
|
|
|
--disable-libssp \
|
|
|
|
--disable-libvtv \
|
2015-06-24 01:56:29 +01:00
|
|
|
--disable-libstdcxx \
|
2014-05-20 01:44:22 +01:00
|
|
|
--enable-languages=c,c++</userinput></screen>
|
2006-01-20 21:02:23 +00:00
|
|
|
<variablelist>
|
|
|
|
<title>The meaning of the configure options:</title>
|
|
|
|
|
2012-04-25 20:26:21 +01:00
|
|
|
<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>
|
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<varlistentry>
|
2008-10-12 05:09:47 +01:00
|
|
|
<term><parameter>--disable-shared</parameter></term>
|
2006-01-20 21:02:23 +00:00
|
|
|
<listitem>
|
2008-10-13 14:32:41 +01:00
|
|
|
<para>This switch forces GCC to link its internal libraries
|
2008-10-12 05:09:47 +01:00
|
|
|
statically. We do this to avoid possible issues with the host
|
|
|
|
system.</para>
|
2006-01-20 21:02:23 +00:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2008-10-30 06:52:46 +00:00
|
|
|
<varlistentry>
|
2013-03-28 17:38:55 +00:00
|
|
|
<term><parameter>--disable-decimal-float, --disable-threads,
|
2015-06-24 01:56:29 +01:00
|
|
|
--disable-libatomic, --disable-libgomp, --disable-libquadmath,
|
|
|
|
--disable-libssp, --disable-libvtv, --disable-libstdcxx</parameter></term>
|
2008-10-30 06:52:46 +00:00
|
|
|
<listitem>
|
2011-03-30 21:24:53 +01:00
|
|
|
<para>These switches disable support for the decimal floating point
|
2015-06-24 01:56:29 +01:00
|
|
|
extension, threading, libatomic, libgomp, libquadmath, libssp,
|
|
|
|
libvtv, and the C++ standard library respectively. These features
|
|
|
|
will fail to compile when building a cross-compiler and are not
|
|
|
|
necessary for the task of cross-compiling the temporary libc.</para>
|
2008-10-30 06:52:46 +00:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<varlistentry>
|
2008-12-05 20:46:02 +00:00
|
|
|
<term><parameter>--disable-multilib</parameter></term>
|
2006-01-20 21:02:23 +00:00
|
|
|
<listitem>
|
2008-12-05 20:46:02 +00:00
|
|
|
<para>On x86_64, LFS does not yet support a multilib configuration.
|
|
|
|
This switch is harmless for x86.</para>
|
2006-01-20 21:02:23 +00:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2008-12-03 22:46:04 +00:00
|
|
|
<varlistentry>
|
2013-03-28 17:38:55 +00:00
|
|
|
<term><parameter>--enable-languages=c,c++</parameter></term>
|
2008-12-03 22:46:04 +00:00
|
|
|
<listitem>
|
2013-03-28 17:38:55 +00:00
|
|
|
<para>This option ensures that only the C and C++ compilers are built.
|
|
|
|
These are the only languages needed now.</para>
|
2008-12-03 22:46:04 +00:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
</variablelist>
|
|
|
|
|
2008-12-05 20:46:02 +00:00
|
|
|
<para>Compile GCC by running:</para>
|
2007-09-15 21:45:13 +01:00
|
|
|
|
2007-09-18 22:11:00 +01:00
|
|
|
<screen><userinput remap="make">make</userinput></screen>
|
2005-02-19 22:16:42 +00:00
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<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>
|
2003-11-01 22:31:50 +00:00
|
|
|
|
2007-09-18 22:11:00 +01:00
|
|
|
<screen><userinput remap="install">make install</userinput></screen>
|
2014-04-25 20:04:56 +01:00
|
|
|
<!--
|
|
|
|
<para>Using <parameter>- -disable-shared</parameter> means that the
|
2008-10-12 05:09:47 +01:00
|
|
|
<filename>libgcc_eh.a</filename> file isn't created and installed. The
|
|
|
|
Glibc package depends on this library as it uses
|
2008-12-05 20:46:02 +00:00
|
|
|
<parameter>-lgcc_eh</parameter> within its build system. This dependency
|
|
|
|
can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
|
2008-10-12 05:09:47 +01:00
|
|
|
since that file will end up containing the objects normally contained in
|
2009-08-12 20:16:30 +01:00
|
|
|
<filename>libgcc_eh.a</filename>:</para>
|
2008-10-12 05:09:47 +01:00
|
|
|
|
2012-10-02 23:40:39 +01:00
|
|
|
<screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`</userinput></screen>
|
2014-04-25 20:04:56 +01:00
|
|
|
-->
|
2006-01-20 21:02:23 +00:00
|
|
|
</sect2>
|
2003-05-02 19:20:20 +01:00
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<sect2 role="content">
|
|
|
|
<title/>
|
2005-02-19 22:16:42 +00:00
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
<para>Details on this package are located in
|
|
|
|
<xref linkend="contents-gcc" role="."/></para>
|
2005-02-19 22:16:42 +00:00
|
|
|
|
2006-01-20 21:02:23 +00:00
|
|
|
</sect2>
|
|
|
|
|
|
|
|
</sect1>
|