[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">
|
---|
[714599f] | 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"
|
---|
[6dfcfecc] | 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>
|
---|
[6dfcfecc] | 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 |
|
---|
[6dfcfecc] | 46 | <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
|
---|
| 47 | not be included in your host distribution, they will be built with
|
---|
| 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 |
|
---|
[6dfcfecc] | 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
|
---|
[c4595c3] | 63 | mv -v mpc-&mpc-version; mpc</userinput></screen>
|
---|
[6cc0516] | 64 |
|
---|
[6dfcfecc] | 65 | <para arch="default">On x86_64 hosts, set the default directory name for
|
---|
| 66 | 64-bit libraries to <quote>lib</quote>:</para>
|
---|
[be3d9f3] | 67 |
|
---|
[b3f1ebb3] | 68 | <screen arch="default"><userinput remap="pre">case $(uname -m) in
|
---|
[be3d9f3] | 69 | x86_64)
|
---|
| 70 | sed -e '/m64=/s/lib64/lib/' \
|
---|
| 71 | -i.orig gcc/config/i386/t-linux64
|
---|
| 72 | ;;
|
---|
| 73 | esac</userinput></screen>
|
---|
| 74 |
|
---|
[6dfcfecc] | 75 | <para arch="ml_32,ml_x32,ml_all">Change the default directory name for
|
---|
| 76 | libraries:</para>
|
---|
[5f28def] | 77 |
|
---|
[6dfcfecc] | 78 | <screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
|
---|
[0ebda11] | 79 | -e '/m32=/s/m32=.*/m32=..\/lib32$(call if_multiarch,:i386-linux-gnu)/' \
|
---|
[6dfcfecc] | 80 | -i.orig gcc/config/i386/t-linux64
|
---|
| 81 | </userinput></screen>
|
---|
[b3f1ebb3] | 82 |
|
---|
[a26f29f] | 83 | <para>The GCC documentation recommends building GCC
|
---|
[f1dd547] | 84 | in a dedicated build directory:</para>
|
---|
[3d36131c] | 85 |
|
---|
[f1dd547] | 86 | <screen><userinput remap="pre">mkdir -v build
|
---|
| 87 | cd build</userinput></screen>
|
---|
[73aedd1d] | 88 |
|
---|
[1f7ca93] | 89 | <para>Prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 90 |
|
---|
[716db1f] | 91 | <screen arch="default"><userinput remap="configure">../configure \
|
---|
[43b6ecd] | 92 | --target=$LFS_TGT \
|
---|
| 93 | --prefix=$LFS/tools \
|
---|
[0fc98a0] | 94 | --with-glibc-version=&glibc-version; \
|
---|
[43b6ecd] | 95 | --with-sysroot=$LFS \
|
---|
| 96 | --with-newlib \
|
---|
| 97 | --without-headers \
|
---|
[0611f706] | 98 | --enable-default-pie \
|
---|
| 99 | --enable-default-ssp \
|
---|
[43b6ecd] | 100 | --disable-nls \
|
---|
| 101 | --disable-shared \
|
---|
| 102 | --disable-multilib \
|
---|
| 103 | --disable-threads \
|
---|
| 104 | --disable-libatomic \
|
---|
| 105 | --disable-libgomp \
|
---|
| 106 | --disable-libquadmath \
|
---|
| 107 | --disable-libssp \
|
---|
| 108 | --disable-libvtv \
|
---|
| 109 | --disable-libstdcxx \
|
---|
[6dfcfecc] | 110 | --enable-languages=c,c++</userinput></screen>
|
---|
| 111 | <screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure"
|
---|
| 112 | arch="ml_32">mlist=m64,m32</userinput><userinput remap="configure"
|
---|
| 113 | arch="ml_x32">mlist=m64,mx32</userinput><userinput remap="configure"
|
---|
| 114 | arch="ml_all">mlist=m64,m32,mx32</userinput>
|
---|
[716db1f] | 115 | <userinput remap="configure">../configure \
|
---|
[b3f1ebb3] | 116 | --target=$LFS_TGT \
|
---|
[6dfcfecc] | 117 | --prefix=$LFS/tools \
|
---|
[caf32c8] | 118 | --with-glibc-version=&glibc-version; \
|
---|
[b3f1ebb3] | 119 | --with-sysroot=$LFS \
|
---|
| 120 | --with-newlib \
|
---|
| 121 | --without-headers \
|
---|
[1835fca] | 122 | --enable-default-pie \
|
---|
| 123 | --enable-default-ssp \
|
---|
[6dfcfecc] | 124 | --enable-initfini-array \
|
---|
[b3f1ebb3] | 125 | --disable-nls \
|
---|
| 126 | --disable-shared \
|
---|
[6dfcfecc] | 127 | --enable-multilib --with-multilib-list=$mlist \
|
---|
[b3f1ebb3] | 128 | --disable-decimal-float \
|
---|
| 129 | --disable-threads \
|
---|
| 130 | --disable-libatomic \
|
---|
| 131 | --disable-libgomp \
|
---|
| 132 | --disable-libquadmath \
|
---|
| 133 | --disable-libssp \
|
---|
| 134 | --disable-libvtv \
|
---|
| 135 | --disable-libstdcxx \
|
---|
[6dfcfecc] | 136 | --enable-languages=c,c++</userinput></screen>
|
---|
[b3f1ebb3] | 137 |
|
---|
[1f7ca93] | 138 | <variablelist>
|
---|
| 139 | <title>The meaning of the configure options:</title>
|
---|
| 140 |
|
---|
[43822cc] | 141 | <varlistentry>
|
---|
[0fc98a0] | 142 | <term><parameter>--with-glibc-version=&glibc-version;</parameter></term>
|
---|
[43822cc] | 143 | <listitem>
|
---|
[f6820bb6] | 144 | <para>This option specifies the version of Glibc which will be
|
---|
[d6006ef] | 145 | used on the target. It is not relevant to the libc of the host
|
---|
[f6820bb6] | 146 | distro because everything compiled by pass1 GCC will run in the
|
---|
[d6006ef] | 147 | chroot environment, which is isolated from libc of the host
|
---|
| 148 | distro.</para>
|
---|
[43822cc] | 149 | </listitem>
|
---|
| 150 | </varlistentry>
|
---|
| 151 |
|
---|
[1a3e6a3] | 152 | <varlistentry>
|
---|
| 153 | <term><parameter>--with-newlib</parameter></term>
|
---|
| 154 | <listitem>
|
---|
| 155 | <para>Since a working C library is not yet available, this ensures
|
---|
| 156 | that the inhibit_libc constant is defined when building libgcc. This prevents
|
---|
| 157 | the compiling of any code that requires libc support.</para>
|
---|
| 158 | </listitem>
|
---|
| 159 | </varlistentry>
|
---|
| 160 |
|
---|
| 161 | <varlistentry>
|
---|
| 162 | <term><parameter>--without-headers</parameter></term>
|
---|
| 163 | <listitem>
|
---|
| 164 | <para>When creating a complete cross-compiler, GCC requires
|
---|
| 165 | standard headers compatible with the target system. For our
|
---|
| 166 | purposes these headers will not be needed. This switch prevents
|
---|
| 167 | GCC from looking for them.</para>
|
---|
| 168 | </listitem>
|
---|
| 169 | </varlistentry>
|
---|
| 170 |
|
---|
[1bade3f] | 171 | <varlistentry>
|
---|
[8d3b254] | 172 | <term><parameter>--enable-default-pie and
|
---|
| 173 | --enable-default-ssp</parameter></term>
|
---|
[1bade3f] | 174 | <listitem>
|
---|
| 175 | <para>Those switches allow GCC to compile programs with
|
---|
[e502de1] | 176 | some hardening security features (more information on those in
|
---|
[a189579] | 177 | the <xref linkend="pie-ssp-info"/> in chapter 8) by default. They
|
---|
[e502de1] | 178 | are not strictly needed at this stage, since the compiler will
|
---|
| 179 | only produce temporary executables. But it is cleaner to have the
|
---|
| 180 | temporary packages be as close as possible to the final ones.
|
---|
[1bade3f] | 181 | </para>
|
---|
| 182 | </listitem>
|
---|
[79524a0] | 183 | </varlistentry>
|
---|
| 184 |
|
---|
[1a3e6a3] | 185 | <varlistentry>
|
---|
[6dfcfecc] | 186 | <term><parameter>--disable-shared</parameter></term>
|
---|
[1a3e6a3] | 187 | <listitem>
|
---|
[6dfcfecc] | 188 | <para>This switch forces GCC to link its internal libraries
|
---|
[f6820bb6] | 189 | statically. We need this because the shared libraries require Glibc,
|
---|
[6dfcfecc] | 190 | which is not yet installed on the target system.</para>
|
---|
[1a3e6a3] | 191 | </listitem>
|
---|
| 192 | </varlistentry>
|
---|
| 193 |
|
---|
[6dfcfecc] | 194 | <varlistentry arch="default">
|
---|
| 195 | <term><parameter>--disable-multilib</parameter></term>
|
---|
[1f7ca93] | 196 | <listitem>
|
---|
[6dfcfecc] | 197 | <para>On x86_64, LFS does not support a multilib configuration.
|
---|
| 198 | This switch is harmless for x86.</para>
|
---|
| 199 | </listitem>
|
---|
| 200 | </varlistentry>
|
---|
| 201 | <varlistentry arch="ml_32,ml_x32,ml_all">
|
---|
| 202 | <term><parameter>--enable-multilib --with-multilib-list=...</parameter></term>
|
---|
| 203 | <listitem>
|
---|
| 204 | <para>LFS canbe used to support multilib. Which they are is
|
---|
| 205 | specified in the multilib list.</para>
|
---|
[1f7ca93] | 206 | </listitem>
|
---|
| 207 | </varlistentry>
|
---|
| 208 |
|
---|
[182d5d3] | 209 | <varlistentry>
|
---|
[31e9ff9] | 210 | <term><parameter>--disable-threads,
|
---|
| 211 | --disable-libatomic, --disable-libgomp,
|
---|
[42130d6] | 212 | --disable-libquadmath, --disable-libssp, --disable-libvtv,
|
---|
| 213 | --disable-libstdcxx</parameter></term>
|
---|
[182d5d3] | 214 | <listitem>
|
---|
[31e9ff9] | 215 | <para>These switches disable support for
|
---|
| 216 | threading, libatomic, libgomp, libquadmath, libssp,
|
---|
[05a0344] | 217 | libvtv, and the C++ standard library respectively. These features
|
---|
[31e9ff9] | 218 | may fail to compile when building a cross-compiler and are not
|
---|
[05a0344] | 219 | necessary for the task of cross-compiling the temporary libc.</para>
|
---|
[182d5d3] | 220 | </listitem>
|
---|
| 221 | </varlistentry>
|
---|
| 222 |
|
---|
[6e88633] | 223 | <varlistentry>
|
---|
[908077d] | 224 | <term><parameter>--enable-languages=c,c++</parameter></term>
|
---|
[6e88633] | 225 | <listitem>
|
---|
[908077d] | 226 | <para>This option ensures that only the C and C++ compilers are built.
|
---|
| 227 | These are the only languages needed now.</para>
|
---|
[6e88633] | 228 | </listitem>
|
---|
| 229 | </varlistentry>
|
---|
| 230 |
|
---|
[1f7ca93] | 231 | </variablelist>
|
---|
| 232 |
|
---|
[4e82d47] | 233 | <para>Compile GCC by running:</para>
|
---|
[b0a4c9a] | 234 |
|
---|
[0445a3d] | 235 | <screen><userinput remap="make">make</userinput></screen>
|
---|
[81fd230] | 236 |
|
---|
[1f7ca93] | 237 | <para>Install the package:</para>
|
---|
[73aedd1d] | 238 |
|
---|
[6dfcfecc] | 239 | <screen><userinput remap="install">make install</userinput></screen>
|
---|
| 240 |
|
---|
| 241 | <para>This build of GCC has installed a couple of internal system
|
---|
| 242 | headers. Normally one of them, <filename>limits.h</filename>, would in turn
|
---|
| 243 | include the corresponding system <filename>limits.h</filename> header, in
|
---|
| 244 | this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
|
---|
| 245 | time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
|
---|
| 246 | does not exist, so the internal header that has just been installed is a
|
---|
| 247 | partial, self-contained file and does not include the extended features of
|
---|
[f6820bb6] | 248 | the system header. This is adequate for building Glibc, but the full
|
---|
[6dfcfecc] | 249 | internal header will be needed later. Create a full version of the internal
|
---|
| 250 | header using a command that is identical to what the GCC build system does
|
---|
| 251 | in normal circumstances:</para>
|
---|
| 252 |
|
---|
[adba2da] | 253 | <note>
|
---|
| 254 | <para>The command below shows an example of nested command substitution
|
---|
[139b77e] | 255 | using two methods: backquotes and a <literal>$()</literal> construct.
|
---|
| 256 | It could be rewritten using the same method for both substitutions,
|
---|
| 257 | but is shown this way to demonstrate how they can be mixed. Generally
|
---|
| 258 | the <literal>$()</literal> method is preferred.</para>
|
---|
[adba2da] | 259 | </note>
|
---|
| 260 |
|
---|
[6dfcfecc] | 261 | <screen><userinput remap="install">cd ..
|
---|
| 262 | cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
|
---|
[bd5b888] | 263 | `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include/limits.h</userinput></screen>
|
---|
[1f7ca93] | 264 | </sect2>
|
---|
[bc82645e] | 265 |
|
---|
[1f7ca93] | 266 | <sect2 role="content">
|
---|
| 267 | <title/>
|
---|
[81fd230] | 268 |
|
---|
[1f7ca93] | 269 | <para>Details on this package are located in
|
---|
| 270 | <xref linkend="contents-gcc" role="."/></para>
|
---|
[81fd230] | 271 |
|
---|
[1f7ca93] | 272 | </sect2>
|
---|
| 273 |
|
---|
| 274 | </sect1>
|
---|