[7152faa] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[b06ca36] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[673b0d8] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[1f7ca93] | 7 |
|
---|
[1067bac] | 8 | <sect1 id="ch-tools-gcc-pass1" role="wrap" xreflabel="gcc-pass1">
|
---|
[1f7ca93] | 9 | <?dbhtml filename="gcc-pass1.html"?>
|
---|
| 10 |
|
---|
[e747759] | 11 | <sect1info condition="script">
|
---|
[6070f51] | 12 | <productname>gcc-pass1</productname>
|
---|
[e747759] | 13 | <productnumber>&gcc-version;</productnumber>
|
---|
| 14 | <address>&gcc-url;</address>
|
---|
| 15 | </sect1info>
|
---|
| 16 |
|
---|
[1f7ca93] | 17 | <title>GCC-&gcc-version; - Pass 1</title>
|
---|
| 18 |
|
---|
| 19 | <indexterm zone="ch-tools-gcc-pass1">
|
---|
| 20 | <primary sortas="a-GCC">GCC</primary>
|
---|
| 21 | <secondary>tools, pass 1</secondary>
|
---|
| 22 | </indexterm>
|
---|
| 23 |
|
---|
| 24 | <sect2 role="package">
|
---|
| 25 | <title/>
|
---|
[bc82645e] | 26 |
|
---|
[d9441360] | 27 | <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
---|
[fcc02767] | 28 | href="../chapter08/gcc.xml"
|
---|
[1f7ca93] | 29 | xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
|
---|
[81fd230] | 30 |
|
---|
[1f7ca93] | 31 | <segmentedlist>
|
---|
| 32 | <segtitle>&buildtime;</segtitle>
|
---|
| 33 | <segtitle>&diskspace;</segtitle>
|
---|
[5888299] | 34 |
|
---|
[1f7ca93] | 35 | <seglistitem>
|
---|
[fb386e0] | 36 | <seg>&gcc-tmpp1-sbu;</seg>
|
---|
| 37 | <seg>&gcc-tmpp1-du;</seg>
|
---|
[1f7ca93] | 38 | </seglistitem>
|
---|
| 39 | </segmentedlist>
|
---|
[673b0d8] | 40 |
|
---|
[1f7ca93] | 41 | </sect2>
|
---|
[73aedd1d] | 42 |
|
---|
[1f7ca93] | 43 | <sect2 role="installation">
|
---|
[4e82d47] | 44 | <title>Installation of Cross GCC</title>
|
---|
[73aedd1d] | 45 |
|
---|
[efcb393] | 46 | <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
|
---|
[6cc0516] | 47 | not be included in your host distribution, they will be built with
|
---|
[95c681a] | 48 | GCC. Unpack each package into the GCC source directory and rename the
|
---|
| 49 | resulting directories so the GCC build procedures will automatically
|
---|
| 50 | use them:</para>
|
---|
[6cc0516] | 51 |
|
---|
[3380af3] | 52 | <note><para>There are frequent misunderstandings about this chapter. The
|
---|
[f6820bb6] | 53 | procedures are the same as every other chapter, as explained earlier (<xref
|
---|
| 54 | linkend='buildinstr'/>). First, extract the gcc-&gcc-version; tarball from the sources
|
---|
| 55 | directory, and then change to the directory created. Only then should you
|
---|
[3380af3] | 56 | proceed with the instructions below.</para></note>
|
---|
| 57 |
|
---|
[ee648fd] | 58 | <screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
|
---|
[e311865] | 59 | mv -v mpfr-&mpfr-version; mpfr
|
---|
[ee648fd] | 60 | tar -xf ../gmp-&gmp-version;.tar.xz
|
---|
[b2f3f15] | 61 | mv -v gmp-&gmp-version; gmp
|
---|
[ee648fd] | 62 | tar -xf ../mpc-&mpc-version;.tar.gz
|
---|
[4916842] | 63 | mv -v mpc-&mpc-version; mpc</userinput></screen>
|
---|
[6cc0516] | 64 |
|
---|
[efcb393] | 65 | <para>On x86_64 hosts, set the default directory name for
|
---|
[be3d9f3] | 66 | 64-bit libraries to <quote>lib</quote>:</para>
|
---|
| 67 |
|
---|
| 68 | <screen><userinput remap="pre">case $(uname -m) in
|
---|
| 69 | x86_64)
|
---|
| 70 | sed -e '/m64=/s/lib64/lib/' \
|
---|
| 71 | -i.orig gcc/config/i386/t-linux64
|
---|
| 72 | ;;
|
---|
| 73 | esac</userinput></screen>
|
---|
| 74 |
|
---|
[a26f29f] | 75 | <para>The GCC documentation recommends building GCC
|
---|
[f1dd547] | 76 | in a dedicated build directory:</para>
|
---|
[3d36131c] | 77 |
|
---|
[f1dd547] | 78 | <screen><userinput remap="pre">mkdir -v build
|
---|
| 79 | cd build</userinput></screen>
|
---|
[73aedd1d] | 80 |
|
---|
[1f7ca93] | 81 | <para>Prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 82 |
|
---|
[43b6ecd] | 83 | <screen><userinput remap="configure">../configure \
|
---|
| 84 | --target=$LFS_TGT \
|
---|
| 85 | --prefix=$LFS/tools \
|
---|
[0fc98a0] | 86 | --with-glibc-version=&glibc-version; \
|
---|
[43b6ecd] | 87 | --with-sysroot=$LFS \
|
---|
| 88 | --with-newlib \
|
---|
| 89 | --without-headers \
|
---|
[0611f706] | 90 | --enable-default-pie \
|
---|
| 91 | --enable-default-ssp \
|
---|
[43b6ecd] | 92 | --disable-nls \
|
---|
| 93 | --disable-shared \
|
---|
| 94 | --disable-multilib \
|
---|
| 95 | --disable-threads \
|
---|
| 96 | --disable-libatomic \
|
---|
| 97 | --disable-libgomp \
|
---|
| 98 | --disable-libquadmath \
|
---|
| 99 | --disable-libssp \
|
---|
| 100 | --disable-libvtv \
|
---|
| 101 | --disable-libstdcxx \
|
---|
[8aa7fde] | 102 | --enable-languages=c,c++</userinput></screen>
|
---|
[1f7ca93] | 103 | <variablelist>
|
---|
| 104 | <title>The meaning of the configure options:</title>
|
---|
| 105 |
|
---|
[d876f0e] | 106 | <varlistentry>
|
---|
[0fc98a0] | 107 | <term><parameter>--with-glibc-version=&glibc-version;</parameter></term>
|
---|
[d876f0e] | 108 | <listitem>
|
---|
[f6820bb6] | 109 | <para>This option specifies the version of Glibc which will be
|
---|
[d6006ef] | 110 | used on the target. It is not relevant to the libc of the host
|
---|
[f6820bb6] | 111 | distro because everything compiled by pass1 GCC will run in the
|
---|
[d6006ef] | 112 | chroot environment, which is isolated from libc of the host
|
---|
| 113 | distro.</para>
|
---|
[d876f0e] | 114 | </listitem>
|
---|
| 115 | </varlistentry>
|
---|
| 116 |
|
---|
[1a3e6a3] | 117 | <varlistentry>
|
---|
| 118 | <term><parameter>--with-newlib</parameter></term>
|
---|
| 119 | <listitem>
|
---|
| 120 | <para>Since a working C library is not yet available, this ensures
|
---|
| 121 | that the inhibit_libc constant is defined when building libgcc. This prevents
|
---|
| 122 | the compiling of any code that requires libc support.</para>
|
---|
| 123 | </listitem>
|
---|
| 124 | </varlistentry>
|
---|
| 125 |
|
---|
| 126 | <varlistentry>
|
---|
| 127 | <term><parameter>--without-headers</parameter></term>
|
---|
| 128 | <listitem>
|
---|
| 129 | <para>When creating a complete cross-compiler, GCC requires
|
---|
| 130 | standard headers compatible with the target system. For our
|
---|
| 131 | purposes these headers will not be needed. This switch prevents
|
---|
| 132 | GCC from looking for them.</para>
|
---|
| 133 | </listitem>
|
---|
[1bade3f] | 134 | </varlistentry>
|
---|
| 135 |
|
---|
| 136 | <varlistentry>
|
---|
[8d3b254] | 137 | <term><parameter>--enable-default-pie and
|
---|
| 138 | --enable-default-ssp</parameter></term>
|
---|
[1bade3f] | 139 | <listitem>
|
---|
| 140 | <para>Those switches allow GCC to compile programs with
|
---|
[e502de1] | 141 | some hardening security features (more information on those in
|
---|
[a189579] | 142 | the <xref linkend="pie-ssp-info"/> in chapter 8) by default. They
|
---|
[e502de1] | 143 | are not strictly needed at this stage, since the compiler will
|
---|
| 144 | only produce temporary executables. But it is cleaner to have the
|
---|
| 145 | temporary packages be as close as possible to the final ones.
|
---|
[1bade3f] | 146 | </para>
|
---|
| 147 | </listitem>
|
---|
[79524a0] | 148 | </varlistentry>
|
---|
| 149 |
|
---|
[1f7ca93] | 150 | <varlistentry>
|
---|
[0eb90658] | 151 | <term><parameter>--disable-shared</parameter></term>
|
---|
[1f7ca93] | 152 | <listitem>
|
---|
[c49647b1] | 153 | <para>This switch forces GCC to link its internal libraries
|
---|
[f6820bb6] | 154 | statically. We need this because the shared libraries require Glibc,
|
---|
[79524a0] | 155 | which is not yet installed on the target system.</para>
|
---|
| 156 | </listitem>
|
---|
| 157 | </varlistentry>
|
---|
| 158 |
|
---|
| 159 | <varlistentry>
|
---|
| 160 | <term><parameter>--disable-multilib</parameter></term>
|
---|
| 161 | <listitem>
|
---|
| 162 | <para>On x86_64, LFS does not support a multilib configuration.
|
---|
| 163 | This switch is harmless for x86.</para>
|
---|
[1f7ca93] | 164 | </listitem>
|
---|
| 165 | </varlistentry>
|
---|
| 166 |
|
---|
[182d5d3] | 167 | <varlistentry>
|
---|
[31e9ff9] | 168 | <term><parameter>--disable-threads,
|
---|
| 169 | --disable-libatomic, --disable-libgomp,
|
---|
[42130d6] | 170 | --disable-libquadmath, --disable-libssp, --disable-libvtv,
|
---|
| 171 | --disable-libstdcxx</parameter></term>
|
---|
[182d5d3] | 172 | <listitem>
|
---|
[31e9ff9] | 173 | <para>These switches disable support for
|
---|
| 174 | threading, libatomic, libgomp, libquadmath, libssp,
|
---|
[05a0344] | 175 | libvtv, and the C++ standard library respectively. These features
|
---|
[31e9ff9] | 176 | may fail to compile when building a cross-compiler and are not
|
---|
[05a0344] | 177 | necessary for the task of cross-compiling the temporary libc.</para>
|
---|
[182d5d3] | 178 | </listitem>
|
---|
| 179 | </varlistentry>
|
---|
| 180 |
|
---|
[6e88633] | 181 | <varlistentry>
|
---|
[908077d] | 182 | <term><parameter>--enable-languages=c,c++</parameter></term>
|
---|
[6e88633] | 183 | <listitem>
|
---|
[908077d] | 184 | <para>This option ensures that only the C and C++ compilers are built.
|
---|
| 185 | These are the only languages needed now.</para>
|
---|
[6e88633] | 186 | </listitem>
|
---|
| 187 | </varlistentry>
|
---|
| 188 |
|
---|
[1f7ca93] | 189 | </variablelist>
|
---|
| 190 |
|
---|
[4e82d47] | 191 | <para>Compile GCC by running:</para>
|
---|
[b0a4c9a] | 192 |
|
---|
[0445a3d] | 193 | <screen><userinput remap="make">make</userinput></screen>
|
---|
[81fd230] | 194 |
|
---|
[1f7ca93] | 195 | <para>Install the package:</para>
|
---|
[73aedd1d] | 196 |
|
---|
[efcb393] | 197 | <screen><userinput remap="install">make install</userinput></screen>
|
---|
| 198 |
|
---|
| 199 | <para>This build of GCC has installed a couple of internal system
|
---|
| 200 | headers. Normally one of them, <filename>limits.h</filename>, would in turn
|
---|
| 201 | include the corresponding system <filename>limits.h</filename> header, in
|
---|
| 202 | this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
|
---|
[77d2cd8d] | 203 | time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
|
---|
[efcb393] | 204 | does not exist, so the internal header that has just been installed is a
|
---|
| 205 | partial, self-contained file and does not include the extended features of
|
---|
[f6820bb6] | 206 | the system header. This is adequate for building Glibc, but the full
|
---|
[efcb393] | 207 | internal header will be needed later. Create a full version of the internal
|
---|
| 208 | header using a command that is identical to what the GCC build system does
|
---|
| 209 | in normal circumstances:</para>
|
---|
| 210 |
|
---|
[adba2da] | 211 | <note>
|
---|
| 212 | <para>The command below shows an example of nested command substitution
|
---|
[139b77e] | 213 | using two methods: backquotes and a <literal>$()</literal> construct.
|
---|
| 214 | It could be rewritten using the same method for both substitutions,
|
---|
| 215 | but is shown this way to demonstrate how they can be mixed. Generally
|
---|
| 216 | the <literal>$()</literal> method is preferred.</para>
|
---|
[adba2da] | 217 | </note>
|
---|
| 218 |
|
---|
[efcb393] | 219 | <screen><userinput remap="install">cd ..
|
---|
| 220 | cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
|
---|
[bd5b888] | 221 | `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include/limits.h</userinput></screen>
|
---|
[1f7ca93] | 222 | </sect2>
|
---|
[bc82645e] | 223 |
|
---|
[1f7ca93] | 224 | <sect2 role="content">
|
---|
| 225 | <title/>
|
---|
[81fd230] | 226 |
|
---|
[1f7ca93] | 227 | <para>Details on this package are located in
|
---|
| 228 | <xref linkend="contents-gcc" role="."/></para>
|
---|
[81fd230] | 229 |
|
---|
[1f7ca93] | 230 | </sect2>
|
---|
| 231 |
|
---|
| 232 | </sect1>
|
---|