[7152faa] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[6dfcfecc] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ch-tools-gcc-pass2" role="wrap" xreflabel="gcc-pass2">
|
---|
| 9 | <?dbhtml filename="gcc-pass2.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info condition="script">
|
---|
| 12 | <productname>gcc-pass2</productname>
|
---|
| 13 | <productnumber>&gcc-version;</productnumber>
|
---|
| 14 | <address>&gcc-url;</address>
|
---|
| 15 | </sect1info>
|
---|
| 16 |
|
---|
| 17 | <title>GCC-&gcc-version; - Pass 2</title>
|
---|
| 18 |
|
---|
| 19 | <indexterm zone="ch-tools-gcc-pass2">
|
---|
| 20 | <primary sortas="a-GCC">GCC</primary>
|
---|
| 21 | <secondary>tools, pass 2</secondary>
|
---|
| 22 | </indexterm>
|
---|
| 23 |
|
---|
| 24 | <sect2 role="package">
|
---|
| 25 | <title/>
|
---|
| 26 |
|
---|
| 27 | <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
---|
| 28 | href="../chapter08/gcc.xml"
|
---|
| 29 | xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
|
---|
| 30 |
|
---|
| 31 | <segmentedlist>
|
---|
| 32 | <segtitle>&buildtime;</segtitle>
|
---|
| 33 | <segtitle>&diskspace;</segtitle>
|
---|
| 34 |
|
---|
| 35 | <seglistitem>
|
---|
| 36 | <seg>&gcc-tmpp2-sbu;</seg>
|
---|
| 37 | <seg>&gcc-tmpp2-du;</seg>
|
---|
| 38 | </seglistitem>
|
---|
| 39 | </segmentedlist>
|
---|
| 40 |
|
---|
| 41 | </sect2>
|
---|
| 42 |
|
---|
| 43 | <sect2 role="installation">
|
---|
| 44 | <title>Installation of GCC</title>
|
---|
[f2af13d] | 45 | <!--
|
---|
[1b11115] | 46 | <para>First fix a problem with the latest version of glibc:</para>
|
---|
| 47 |
|
---|
| 48 | <screen><userinput remap="pre">patch -Np1 -i ../&gcc-upstream-fixes-patch;</userinput></screen>
|
---|
[f2af13d] | 49 | -->
|
---|
[6dfcfecc] | 50 | <para>As in the first build of GCC, the GMP, MPFR, and MPC packages are
|
---|
[6dff9ef] | 51 | required. Unpack the tarballs and move them into the required directories:</para>
|
---|
[6dfcfecc] | 52 |
|
---|
| 53 | <screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
|
---|
| 54 | mv -v mpfr-&mpfr-version; mpfr
|
---|
| 55 | tar -xf ../gmp-&gmp-version;.tar.xz
|
---|
| 56 | mv -v gmp-&gmp-version; gmp
|
---|
| 57 | tar -xf ../mpc-&mpc-version;.tar.gz
|
---|
[c4595c3] | 58 | mv -v mpc-&mpc-version; mpc</userinput></screen>
|
---|
[6dfcfecc] | 59 |
|
---|
| 60 |
|
---|
| 61 | <para arch="default">If building on x86_64, change the default directory name for 64-bit
|
---|
| 62 | libraries to <quote>lib</quote>:</para>
|
---|
| 63 |
|
---|
| 64 | <screen arch="default"><userinput remap="pre">case $(uname -m) in
|
---|
| 65 | x86_64)
|
---|
[642f779] | 66 | sed -e '/m64=/s/lib64/lib/' \
|
---|
| 67 | -i.orig gcc/config/i386/t-linux64
|
---|
[6dfcfecc] | 68 | ;;
|
---|
| 69 | esac</userinput></screen>
|
---|
[d7e0db5] | 70 |
|
---|
[d9bec1e] | 71 | <para arch="ml_32,ml_x32,ml_all">Change the default directory name for the
|
---|
[6dfcfecc] | 72 | libraries:</para>
|
---|
| 73 |
|
---|
| 74 | <screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
|
---|
[0ebda11] | 75 | -e '/m32=/s/m32=.*/m32=..\/lib32$(call if_multiarch,:i386-linux-gnu)/' \
|
---|
[6dfcfecc] | 76 | -i.orig gcc/config/i386/t-linux64</userinput></screen>
|
---|
[d9bec1e] | 77 |
|
---|
[459d493] | 78 | <para>Override the building rule of libgcc and libstdc++ headers, to
|
---|
| 79 | allow building these libraries with POSIX threads support:</para>
|
---|
| 80 |
|
---|
| 81 | <screen><userinput remap="pre">sed '/thread_header =/s/@.*@/gthr-posix.h/' \
|
---|
| 82 | -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in</userinput></screen>
|
---|
| 83 |
|
---|
[6dfcfecc] | 84 | <para>Create a separate build directory again:</para>
|
---|
| 85 |
|
---|
| 86 | <screen><userinput remap="pre">mkdir -v build
|
---|
| 87 | cd build</userinput></screen>
|
---|
| 88 |
|
---|
| 89 | <para>Before starting to build GCC, remember to unset any environment
|
---|
| 90 | variables that override the default optimization flags.</para>
|
---|
| 91 |
|
---|
| 92 | <para>Now prepare GCC for compilation:</para>
|
---|
| 93 |
|
---|
| 94 | <screen arch="default"><userinput remap="configure">../configure \
|
---|
| 95 | --build=$(../config.guess) \
|
---|
| 96 | --host=$LFS_TGT \
|
---|
[8e0f8a9] | 97 | --target=$LFS_TGT \
|
---|
[459d493] | 98 | LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
|
---|
[6dfcfecc] | 99 | --prefix=/usr \
|
---|
| 100 | --with-build-sysroot=$LFS \
|
---|
[0611f706] | 101 | --enable-default-pie \
|
---|
| 102 | --enable-default-ssp \
|
---|
[6dfcfecc] | 103 | --disable-nls \
|
---|
| 104 | --disable-multilib \
|
---|
| 105 | --disable-libatomic \
|
---|
| 106 | --disable-libgomp \
|
---|
| 107 | --disable-libquadmath \
|
---|
[f652d5bb] | 108 | --disable-libsanitizer \
|
---|
[6dfcfecc] | 109 | --disable-libssp \
|
---|
| 110 | --disable-libvtv \
|
---|
| 111 | --enable-languages=c,c++</userinput></screen>
|
---|
| 112 | <screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure"
|
---|
| 113 | arch="ml_32">mlist=m64,m32</userinput><userinput remap="configure"
|
---|
| 114 | arch="ml_x32">mlist=m64,mx32</userinput><userinput remap="configure"
|
---|
| 115 | arch="ml_all">mlist=m64,m32,mx32</userinput>
|
---|
| 116 | <userinput remap="configure">../configure \
|
---|
| 117 | --build=$(../config.guess) \
|
---|
| 118 | --host=$LFS_TGT \
|
---|
[85acfcb0] | 119 | --target=$LFS_TGT \
|
---|
| 120 | LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
|
---|
[6dfcfecc] | 121 | --prefix=/usr \
|
---|
| 122 | --with-build-sysroot=$LFS \
|
---|
[1835fca] | 123 | --enable-default-pie \
|
---|
| 124 | --enable-default-ssp \
|
---|
[6dfcfecc] | 125 | --disable-nls \
|
---|
| 126 | --enable-multilib --with-multilib-list=$mlist \
|
---|
| 127 | --disable-libatomic \
|
---|
| 128 | --disable-libgomp \
|
---|
| 129 | --disable-libquadmath \
|
---|
[03d4306] | 130 | --disable-libsanitizer \
|
---|
[6dfcfecc] | 131 | --disable-libssp \
|
---|
| 132 | --disable-libvtv \
|
---|
[8acfbf67] | 133 | --enable-languages=c,c++</userinput></screen>
|
---|
[03d4306] | 134 |
|
---|
[6dfcfecc] | 135 | <variablelist>
|
---|
| 136 | <title>The meaning of the new configure options:</title><!-- WIP -->
|
---|
| 137 |
|
---|
| 138 | <varlistentry>
|
---|
[3bb463d] | 139 | <term><parameter>--with-build-sysroot=$LFS</parameter></term>
|
---|
[6dfcfecc] | 140 | <listitem>
|
---|
| 141 | <para>Normally, using <parameter>--host</parameter> ensures that
|
---|
| 142 | a cross-compiler is used for building GCC, and that compiler knows
|
---|
| 143 | that it has to look for headers and libraries in <filename
|
---|
[6dff9ef] | 144 | class="directory">$LFS</filename>. But the build system for GCC uses
|
---|
[6dfcfecc] | 145 | other tools, which are not aware of this location. This switch is
|
---|
[6dff9ef] | 146 | needed so those tools will find the needed files in <filename
|
---|
[6dfcfecc] | 147 | class="directory">$LFS</filename>, and not on the host.</para>
|
---|
| 148 | </listitem>
|
---|
| 149 | </varlistentry>
|
---|
| 150 |
|
---|
[3bb463d] | 151 | <varlistentry>
|
---|
| 152 | <term><parameter>--target=$LFS_TGT</parameter></term>
|
---|
| 153 | <listitem>
|
---|
[6dff9ef] | 154 | <para>We are cross-compiling GCC, so it's impossible to build
|
---|
[3bb463d] | 155 | target libraries (<filename class="libraryfile">libgcc</filename>
|
---|
| 156 | and <filename class="libraryfile">libstdc++</filename>) with the
|
---|
[32c050cb] | 157 | GCC binaries compiled in this pass—those binaries won't run
|
---|
| 158 | on the host. The GCC build system will attempt to use the host's
|
---|
[6dff9ef] | 159 | C and C++ compilers as a workaround by default.
|
---|
| 160 | Building the GCC target libraries with a different
|
---|
| 161 | version of GCC is not supported, so using the host's compilers may cause
|
---|
| 162 | the build to fail. This parameter ensures the libraries are built by GCC
|
---|
| 163 | pass 1.</para>
|
---|
[3bb463d] | 164 | </listitem>
|
---|
| 165 | </varlistentry>
|
---|
| 166 |
|
---|
| 167 | <varlistentry>
|
---|
| 168 | <term><parameter>LDFLAGS_FOR_TARGET=...</parameter></term>
|
---|
| 169 | <listitem>
|
---|
| 170 | <para>Allow <filename class="libraryfile">libstdc++</filename> to
|
---|
[217802b] | 171 | use the <filename class="libraryfile">libgcc</filename> being
|
---|
| 172 | built in this pass, instead of the previous version built in
|
---|
| 173 | <xref linkend='ch-tools-gcc-pass1'/>. The previous version cannot
|
---|
| 174 | properly support C++ exception handling because it was built
|
---|
| 175 | without libc support.</para>
|
---|
[3bb463d] | 176 | </listitem>
|
---|
| 177 | </varlistentry>
|
---|
| 178 |
|
---|
[f652d5bb] | 179 | <varlistentry>
|
---|
| 180 | <term><parameter>--disable-libsanitizer</parameter></term>
|
---|
| 181 | <listitem>
|
---|
| 182 | <para>Disable GCC sanitizer runtime libraries. They are not
|
---|
[87e5e08] | 183 | needed for the temporary installation. In
|
---|
| 184 | <xref linkend='ch-tools-gcc-pass1'/> it was implied by
|
---|
| 185 | <parameter>--disable-libstdcxx</parameter>, and now we can
|
---|
| 186 | explicitly pass it.</para>
|
---|
[f652d5bb] | 187 | </listitem>
|
---|
| 188 | </varlistentry>
|
---|
| 189 |
|
---|
[6dfcfecc] | 190 | </variablelist>
|
---|
| 191 |
|
---|
| 192 | <para>Compile the package:</para>
|
---|
| 193 |
|
---|
| 194 | <screen><userinput remap="make">make</userinput></screen>
|
---|
| 195 |
|
---|
| 196 | <para>Install the package:</para>
|
---|
| 197 |
|
---|
| 198 | <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
|
---|
| 199 |
|
---|
| 200 | <para>As a finishing touch, create a utility symlink. Many programs and scripts
|
---|
| 201 | run <command>cc</command> instead of <command>gcc</command>, which is
|
---|
| 202 | used to keep programs generic and therefore usable on all kinds of UNIX
|
---|
| 203 | systems where the GNU C compiler is not always installed. Running
|
---|
| 204 | <command>cc</command> leaves the system administrator free to decide
|
---|
| 205 | which C compiler to install:</para>
|
---|
| 206 |
|
---|
| 207 | <screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
|
---|
| 208 |
|
---|
| 209 | </sect2>
|
---|
| 210 |
|
---|
| 211 | <sect2 role="content">
|
---|
| 212 | <title/>
|
---|
| 213 |
|
---|
| 214 | <para>Details on this package are located in
|
---|
| 215 | <xref linkend="contents-gcc" role="."/></para>
|
---|
| 216 |
|
---|
| 217 | </sect2>
|
---|
| 218 |
|
---|
| 219 | </sect1>
|
---|