[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[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"
|
---|
[1f7ca93] | 28 | href="../chapter06/gcc.xml"
|
---|
| 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>
|
---|
[e4a5635] | 36 | <seg>&gcc-ch5p1-sbu;</seg>
|
---|
| 37 | <seg>&gcc-ch5p1-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 |
|
---|
[b3f1ebb3] | 46 | <para arch="default">GCC now requires the GMP, MPFR, and MPC packages. As
|
---|
| 47 | these packages may not be included in your host distribution, they will be
|
---|
| 48 | built with GCC. Unpack each package into the GCC source directory and
|
---|
| 49 | rename the resulting directories so the GCC build procedures will
|
---|
| 50 | automatically use them:</para>
|
---|
| 51 |
|
---|
[fd48baa] | 52 | <para arch="ml_32,ml_x32,ml_all">GCC now requires the GMP, ISL, MPFR, and MPC packages.
|
---|
[b3f1ebb3] | 53 | As these packages may not be included in your host distribution, they will
|
---|
| 54 | be built with GCC. Unpack each package into the GCC source directory and
|
---|
| 55 | rename the resulting directories so the GCC build procedures will
|
---|
| 56 | automatically use them:</para>
|
---|
[6cc0516] | 57 |
|
---|
[3380af3] | 58 | <note><para>There are frequent misunderstandings about this chapter. The
|
---|
| 59 | procedures are the same as every other chapter as explained earlier (<xref
|
---|
| 60 | linkend='buildinstr'/>). First extract the gcc tarball from the sources
|
---|
| 61 | directory and then change to the directory created. Only then should you
|
---|
| 62 | proceed with the instructions below.</para></note>
|
---|
| 63 |
|
---|
[b3f1ebb3] | 64 | <screen arch="default"><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
|
---|
[e311865] | 65 | mv -v mpfr-&mpfr-version; mpfr
|
---|
[ee648fd] | 66 | tar -xf ../gmp-&gmp-version;.tar.xz
|
---|
[b2f3f15] | 67 | mv -v gmp-&gmp-version; gmp
|
---|
[ee648fd] | 68 | tar -xf ../mpc-&mpc-version;.tar.gz
|
---|
[4916842] | 69 | mv -v mpc-&mpc-version; mpc</userinput></screen>
|
---|
[fd48baa] | 70 | <screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
|
---|
[b3f1ebb3] | 71 | mv -v mpfr-&mpfr-version; mpfr
|
---|
| 72 | tar -xf ../gmp-&gmp-version;.tar.xz
|
---|
| 73 | mv -v gmp-&gmp-version; gmp
|
---|
| 74 | tar -xf ../mpc-&mpc-version;.tar.gz
|
---|
| 75 | mv -v mpc-&mpc-version; mpc
|
---|
| 76 | tar -xf ../isl-&isl-version;.tar.xz
|
---|
| 77 | mv -v isl-&isl-version; isl</userinput></screen>
|
---|
[6cc0516] | 78 |
|
---|
[1a3e6a3] | 79 | <para>The following command will change the location of GCC's default
|
---|
| 80 | dynamic linker to use the one installed in <filename
|
---|
| 81 | class="directory">/tools</filename>. It also removes <filename
|
---|
| 82 | class="directory">/usr/include</filename> from GCC's include search path.
|
---|
| 83 | Issue:</para>
|
---|
| 84 |
|
---|
[be3d9f3] | 85 | <screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
|
---|
[1a3e6a3] | 86 | do
|
---|
| 87 | cp -uv $file{,.orig}
|
---|
[b3f1ebb3] | 88 | sed -e 's@/lib\(64\)\?\(32\)\?\(x32\)\?/ld@/tools&@g' \
|
---|
[1a3e6a3] | 89 | -e 's@/usr@/tools@g' $file.orig > $file
|
---|
| 90 | echo '
|
---|
| 91 | #undef STANDARD_STARTFILE_PREFIX_1
|
---|
| 92 | #undef STANDARD_STARTFILE_PREFIX_2
|
---|
| 93 | #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
|
---|
| 94 | #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
|
---|
| 95 | touch $file.orig
|
---|
| 96 | done</userinput></screen>
|
---|
| 97 |
|
---|
| 98 | <para>In case the above seems hard to follow, let's break it down a bit.
|
---|
[a05450f] | 99 | First we copy the files <filename>gcc/config/linux.h</filename>,
|
---|
| 100 | <filename>gcc/config/i386/linux.h</filename>, and
|
---|
[0d84af1] | 101 | <filename>gcc/config/i368/linux64.h</filename> to a file of
|
---|
[1a3e6a3] | 102 | the same name but with an added suffix of <quote>.orig</quote>. Then the
|
---|
| 103 | first sed expression prepends <quote>/tools</quote> to every instance of
|
---|
| 104 | <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or
|
---|
| 105 | <quote>/lib32/ld</quote>, while the second one replaces hard-coded
|
---|
| 106 | instances of <quote>/usr</quote>. Next, we add our define statements which
|
---|
| 107 | alter the default startfile prefix to the end of the file. Note that the
|
---|
| 108 | trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required.
|
---|
| 109 | Finally, we use <command>touch</command> to update the timestamp on the
|
---|
| 110 | copied files. When used in conjunction with <command>cp -u</command>, this
|
---|
| 111 | prevents unexpected changes to the original files in case the commands are
|
---|
[be3d9f3] | 112 | inadvertently run twice.</para>
|
---|
| 113 |
|
---|
[b3f1ebb3] | 114 | <para arch="default">Finally, on x86_64 hosts, set the default directory
|
---|
| 115 | name for 64-bit libraries to <quote>lib</quote>:</para>
|
---|
[be3d9f3] | 116 |
|
---|
[b3f1ebb3] | 117 | <screen arch="default"><userinput remap="pre">case $(uname -m) in
|
---|
[be3d9f3] | 118 | x86_64)
|
---|
| 119 | sed -e '/m64=/s/lib64/lib/' \
|
---|
| 120 | -i.orig gcc/config/i386/t-linux64
|
---|
| 121 | ;;
|
---|
| 122 | esac</userinput></screen>
|
---|
| 123 |
|
---|
[9c0c3a0] | 124 | <screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
|
---|
| 125 | -e '/m32=/s/m32=.*/m32=..\/lib32$(call if_multiarch,:i386-linux-gnu)/' \
|
---|
| 126 | -i.orig gcc/config/i386/t-linux64</userinput></screen>
|
---|
[b3f1ebb3] | 127 |
|
---|
[5f28def] | 128 | <!--
|
---|
[f1c177f] | 129 | <para>GCC doesn't detect stack protection correctly, which causes problems
|
---|
| 130 | for the build of Glibc-&glibc-version;, so fix that by issuing the following
|
---|
| 131 | command:</para>
|
---|
| 132 |
|
---|
| 133 | <screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen>
|
---|
[5f28def] | 134 | -->
|
---|
| 135 |
|
---|
[238d351] | 136 | <!--
|
---|
[8a8177f9] | 137 | <para>Also fix a problem identified upstream:</para>
|
---|
| 138 |
|
---|
| 139 | <screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&\& \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>
|
---|
[238d351] | 140 | -->
|
---|
[b3f1ebb3] | 141 |
|
---|
| 142 | <!-- Following patch might be obsolete with gcc >= 8.2.1 -->
|
---|
| 143 | <!-- see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86724 -->
|
---|
| 144 | <!-- Fix applied in ch5-gcc-pass{1,2}, ch6-gcc -->
|
---|
[fd48baa] | 145 | <para arch="ml_32,ml_x32,ml_all">Fix an issue with isl-&isl-version;:</para>
|
---|
[b3f1ebb3] | 146 |
|
---|
[fd48baa] | 147 | <screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e "/#include <isl\/schedule_node.h>/ a#include <isl/id.h>\n#include <isl/space.h>" \
|
---|
[b3f1ebb3] | 148 | -i gcc/graphite.h</userinput></screen>
|
---|
| 149 |
|
---|
[f1dd547] | 150 | <para>The GCC documentation recommends building GCC
|
---|
| 151 | in a dedicated build directory:</para>
|
---|
[3d36131c] | 152 |
|
---|
[f1dd547] | 153 | <screen><userinput remap="pre">mkdir -v build
|
---|
| 154 | cd build</userinput></screen>
|
---|
[73aedd1d] | 155 |
|
---|
[1f7ca93] | 156 | <para>Prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 157 |
|
---|
[b3f1ebb3] | 158 | <screen arch="default"><userinput remap="configure">../configure \
|
---|
[d0da965a] | 159 | --target=$LFS_TGT \
|
---|
| 160 | --prefix=/tools \
|
---|
| 161 | --with-glibc-version=2.11 \
|
---|
| 162 | --with-sysroot=$LFS \
|
---|
| 163 | --with-newlib \
|
---|
| 164 | --without-headers \
|
---|
| 165 | --with-local-prefix=/tools \
|
---|
| 166 | --with-native-system-header-dir=/tools/include \
|
---|
| 167 | --disable-nls \
|
---|
| 168 | --disable-shared \
|
---|
| 169 | --disable-multilib \
|
---|
| 170 | --disable-decimal-float \
|
---|
| 171 | --disable-threads \
|
---|
| 172 | --disable-libatomic \
|
---|
| 173 | --disable-libgomp \
|
---|
[42130d6] | 174 | --disable-libmpx \
|
---|
[d0da965a] | 175 | --disable-libquadmath \
|
---|
| 176 | --disable-libssp \
|
---|
| 177 | --disable-libvtv \
|
---|
[05a0344] | 178 | --disable-libstdcxx \
|
---|
[8aa7fde] | 179 | --enable-languages=c,c++</userinput></screen>
|
---|
[b3f1ebb3] | 180 |
|
---|
[fd48baa] | 181 | <screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">mlist="m64"</userinput>
|
---|
| 182 | <userinput arch="ml_32,ml_all" remap="configure">mlist="$mlist,m32"</userinput>
|
---|
| 183 | <userinput arch="ml_x32,ml_all" remap="configure">mlist="$mlist,mx32"</userinput>
|
---|
| 184 | <userinput remap="configure">../configure \
|
---|
[b3f1ebb3] | 185 | --target=$LFS_TGT \
|
---|
| 186 | --prefix=/tools \
|
---|
| 187 | --with-glibc-version=2.11 \
|
---|
| 188 | --with-sysroot=$LFS \
|
---|
| 189 | --with-newlib \
|
---|
| 190 | --without-headers \
|
---|
| 191 | --with-local-prefix=/tools \
|
---|
| 192 | --with-native-system-header-dir=/tools/include \
|
---|
| 193 | --disable-nls \
|
---|
| 194 | --disable-shared \
|
---|
| 195 | --enable-multilib \
|
---|
[fd48baa] | 196 | --with-multilib-list=$mlist \
|
---|
[b3f1ebb3] | 197 | --disable-decimal-float \
|
---|
| 198 | --disable-threads \
|
---|
| 199 | --disable-libatomic \
|
---|
| 200 | --disable-libgomp \
|
---|
| 201 | --disable-libmpx \
|
---|
| 202 | --disable-libquadmath \
|
---|
| 203 | --disable-libssp \
|
---|
| 204 | --disable-libvtv \
|
---|
| 205 | --disable-libstdcxx \
|
---|
| 206 | --enable-languages=c,c++</userinput></screen>
|
---|
| 207 |
|
---|
[1f7ca93] | 208 | <variablelist>
|
---|
| 209 | <title>The meaning of the configure options:</title>
|
---|
| 210 |
|
---|
[1a3e6a3] | 211 | <varlistentry>
|
---|
| 212 | <term><parameter>--with-newlib</parameter></term>
|
---|
| 213 | <listitem>
|
---|
| 214 | <para>Since a working C library is not yet available, this ensures
|
---|
| 215 | that the inhibit_libc constant is defined when building libgcc. This prevents
|
---|
| 216 | the compiling of any code that requires libc support.</para>
|
---|
| 217 | </listitem>
|
---|
| 218 | </varlistentry>
|
---|
| 219 |
|
---|
| 220 | <varlistentry>
|
---|
| 221 | <term><parameter>--without-headers</parameter></term>
|
---|
| 222 | <listitem>
|
---|
| 223 | <para>When creating a complete cross-compiler, GCC requires
|
---|
| 224 | standard headers compatible with the target system. For our
|
---|
| 225 | purposes these headers will not be needed. This switch prevents
|
---|
| 226 | GCC from looking for them.</para>
|
---|
| 227 | </listitem>
|
---|
| 228 | </varlistentry>
|
---|
| 229 |
|
---|
| 230 | <varlistentry>
|
---|
| 231 | <term><parameter>--with-local-prefix=/tools</parameter></term>
|
---|
| 232 | <listitem>
|
---|
| 233 | <para>The local prefix is the location in the system that GCC will search
|
---|
| 234 | for locally installed include files. The default is <filename>/usr/local</filename>.
|
---|
| 235 | Setting this to <filename>/tools</filename> helps keep the host location of
|
---|
| 236 | <filename>/usr/local</filename> out of this GCC's search path.</para>
|
---|
| 237 | </listitem>
|
---|
| 238 | </varlistentry>
|
---|
| 239 |
|
---|
| 240 | <varlistentry>
|
---|
| 241 | <term><parameter>--with-native-system-header-dir=/tools/include</parameter></term>
|
---|
| 242 | <listitem>
|
---|
[0d84af1] | 243 | <para>By default GCC searches <filename>/usr/include</filename> for
|
---|
| 244 | system headers. In conjunction with the sysroot switch, this would
|
---|
| 245 | normally translate to <filename>$LFS/usr/include</filename>. However
|
---|
| 246 | the headers that will be installed in the next two sections will go
|
---|
| 247 | to <filename>$LFS/tools/include</filename>. This switch ensures that
|
---|
| 248 | gcc will find them correctly. In the second pass of GCC, this same
|
---|
| 249 | switch will ensure that no headers from the host system are
|
---|
| 250 | found.</para>
|
---|
[1a3e6a3] | 251 | </listitem>
|
---|
| 252 | </varlistentry>
|
---|
| 253 |
|
---|
[1f7ca93] | 254 | <varlistentry>
|
---|
[0eb90658] | 255 | <term><parameter>--disable-shared</parameter></term>
|
---|
[1f7ca93] | 256 | <listitem>
|
---|
[c49647b1] | 257 | <para>This switch forces GCC to link its internal libraries
|
---|
[0eb90658] | 258 | statically. We do this to avoid possible issues with the host
|
---|
| 259 | system.</para>
|
---|
[1f7ca93] | 260 | </listitem>
|
---|
| 261 | </varlistentry>
|
---|
| 262 |
|
---|
[182d5d3] | 263 | <varlistentry>
|
---|
[908077d] | 264 | <term><parameter>--disable-decimal-float, --disable-threads,
|
---|
[1118b17] | 265 | --disable-libatomic, --disable-libgomp, --disable-libmpx,
|
---|
[42130d6] | 266 | --disable-libquadmath, --disable-libssp, --disable-libvtv,
|
---|
| 267 | --disable-libstdcxx</parameter></term>
|
---|
[182d5d3] | 268 | <listitem>
|
---|
[8aad4385] | 269 | <para>These switches disable support for the decimal floating point
|
---|
[42130d6] | 270 | extension, threading, libatomic, libgomp, libmpx, libquadmath, libssp,
|
---|
[05a0344] | 271 | libvtv, and the C++ standard library respectively. These features
|
---|
| 272 | will fail to compile when building a cross-compiler and are not
|
---|
| 273 | necessary for the task of cross-compiling the temporary libc.</para>
|
---|
[182d5d3] | 274 | </listitem>
|
---|
| 275 | </varlistentry>
|
---|
| 276 |
|
---|
[b3f1ebb3] | 277 | <varlistentry arch="default">
|
---|
[4e82d47] | 278 | <term><parameter>--disable-multilib</parameter></term>
|
---|
[1f7ca93] | 279 | <listitem>
|
---|
[4e82d47] | 280 | <para>On x86_64, LFS does not yet support a multilib configuration.
|
---|
| 281 | This switch is harmless for x86.</para>
|
---|
[1f7ca93] | 282 | </listitem>
|
---|
| 283 | </varlistentry>
|
---|
| 284 |
|
---|
[fd48baa] | 285 | <varlistentry arch="ml_32,ml_x32,ml_all">
|
---|
[b3f1ebb3] | 286 | <term><parameter>--enable-multilib,
|
---|
| 287 | --with-multilib-list=m32,m64,mx32</parameter></term>
|
---|
| 288 | <listitem>
|
---|
| 289 | <para>LFS now supports a multilib configuration. Enable it for the
|
---|
| 290 | 32bit, the 64-bit, and the mixed mode.</para>
|
---|
| 291 | </listitem>
|
---|
| 292 | </varlistentry>
|
---|
| 293 |
|
---|
[6e88633] | 294 | <varlistentry>
|
---|
[908077d] | 295 | <term><parameter>--enable-languages=c,c++</parameter></term>
|
---|
[6e88633] | 296 | <listitem>
|
---|
[908077d] | 297 | <para>This option ensures that only the C and C++ compilers are built.
|
---|
| 298 | These are the only languages needed now.</para>
|
---|
[6e88633] | 299 | </listitem>
|
---|
| 300 | </varlistentry>
|
---|
| 301 |
|
---|
[1f7ca93] | 302 | </variablelist>
|
---|
| 303 |
|
---|
[4e82d47] | 304 | <para>Compile GCC by running:</para>
|
---|
[b0a4c9a] | 305 |
|
---|
[0445a3d] | 306 | <screen><userinput remap="make">make</userinput></screen>
|
---|
[81fd230] | 307 |
|
---|
[1f7ca93] | 308 | <para>Compilation is now complete. At this point, the test suite would
|
---|
| 309 | normally be run, but, as mentioned before, the test suite framework is
|
---|
| 310 | not in place yet. The benefits of running the tests at this point
|
---|
| 311 | are minimal since the programs from this first pass will soon be
|
---|
| 312 | replaced.</para>
|
---|
| 313 |
|
---|
| 314 | <para>Install the package:</para>
|
---|
[73aedd1d] | 315 |
|
---|
[0445a3d] | 316 | <screen><userinput remap="install">make install</userinput></screen>
|
---|
[e079f16] | 317 | <!--
|
---|
| 318 | <para>Using <parameter>- -disable-shared</parameter> means that the
|
---|
[0eb90658] | 319 | <filename>libgcc_eh.a</filename> file isn't created and installed. The
|
---|
| 320 | Glibc package depends on this library as it uses
|
---|
[4e82d47] | 321 | <parameter>-lgcc_eh</parameter> within its build system. This dependency
|
---|
| 322 | can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
|
---|
[0eb90658] | 323 | since that file will end up containing the objects normally contained in
|
---|
[5f7456b] | 324 | <filename>libgcc_eh.a</filename>:</para>
|
---|
[0eb90658] | 325 |
|
---|
[5cef314] | 326 | <screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`</userinput></screen>
|
---|
[e079f16] | 327 | -->
|
---|
[1f7ca93] | 328 | </sect2>
|
---|
[bc82645e] | 329 |
|
---|
[1f7ca93] | 330 | <sect2 role="content">
|
---|
| 331 | <title/>
|
---|
[81fd230] | 332 |
|
---|
[1f7ca93] | 333 | <para>Details on this package are located in
|
---|
| 334 | <xref linkend="contents-gcc" role="."/></para>
|
---|
[81fd230] | 335 |
|
---|
[1f7ca93] | 336 | </sect2>
|
---|
| 337 |
|
---|
| 338 | </sect1>
|
---|