[fcc02767] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 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 |
|
---|
[9d06e69] | 8 | <sect1 id="ch-tools-gcc-pass2" role="wrap" xreflabel="gcc-pass2">
|
---|
[fcc02767] | 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>
|
---|
[fb386e0] | 36 | <seg>&gcc-tmpp2-sbu;</seg>
|
---|
| 37 | <seg>&gcc-tmpp2-du;</seg>
|
---|
[fcc02767] | 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 | -->
|
---|
[fcc02767] | 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>
|
---|
[fcc02767] | 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
|
---|
| 58 | mv -v mpc-&mpc-version; mpc</userinput></screen>
|
---|
| 59 |
|
---|
| 60 | <para>If building on x86_64, change the default directory name for 64-bit
|
---|
| 61 | libraries to <quote>lib</quote>:</para>
|
---|
| 62 |
|
---|
| 63 | <screen><userinput remap="pre">case $(uname -m) in
|
---|
| 64 | x86_64)
|
---|
[bc8cca5] | 65 | sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
|
---|
[fcc02767] | 66 | ;;
|
---|
| 67 | esac</userinput></screen>
|
---|
| 68 |
|
---|
[459d493] | 69 | <para>Override the building rule of libgcc and libstdc++ headers, to
|
---|
| 70 | allow building these libraries with POSIX threads support:</para>
|
---|
| 71 |
|
---|
| 72 | <screen><userinput remap="pre">sed '/thread_header =/s/@.*@/gthr-posix.h/' \
|
---|
| 73 | -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in</userinput></screen>
|
---|
| 74 |
|
---|
[fcc02767] | 75 | <para>Create a separate build directory again:</para>
|
---|
| 76 |
|
---|
| 77 | <screen><userinput remap="pre">mkdir -v build
|
---|
| 78 | cd build</userinput></screen>
|
---|
| 79 |
|
---|
| 80 | <para>Before starting to build GCC, remember to unset any environment
|
---|
| 81 | variables that override the default optimization flags.</para>
|
---|
| 82 |
|
---|
| 83 | <para>Now prepare GCC for compilation:</para>
|
---|
| 84 |
|
---|
| 85 | <screen><userinput remap="configure">../configure \
|
---|
| 86 | --build=$(../config.guess) \
|
---|
| 87 | --host=$LFS_TGT \
|
---|
[8e0f8a9] | 88 | --target=$LFS_TGT \
|
---|
[459d493] | 89 | LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
|
---|
[8e0f8a9] | 90 | --prefix=/usr \
|
---|
[fcc02767] | 91 | --with-build-sysroot=$LFS \
|
---|
[0611f706] | 92 | --enable-default-pie \
|
---|
| 93 | --enable-default-ssp \
|
---|
[fcc02767] | 94 | --disable-nls \
|
---|
| 95 | --disable-multilib \
|
---|
| 96 | --disable-libatomic \
|
---|
| 97 | --disable-libgomp \
|
---|
| 98 | --disable-libquadmath \
|
---|
| 99 | --disable-libssp \
|
---|
| 100 | --disable-libvtv \
|
---|
| 101 | --enable-languages=c,c++</userinput></screen>
|
---|
| 102 |
|
---|
| 103 | <variablelist>
|
---|
| 104 | <title>The meaning of the new configure options:</title><!-- WIP -->
|
---|
| 105 |
|
---|
| 106 | <varlistentry>
|
---|
[3bb463d] | 107 | <term><parameter>--with-build-sysroot=$LFS</parameter></term>
|
---|
[fcc02767] | 108 | <listitem>
|
---|
[bc8cca5] | 109 | <para>Normally, using <parameter>--host</parameter> ensures that
|
---|
[77d2cd8d] | 110 | a cross-compiler is used for building GCC, and that compiler knows
|
---|
[fcc02767] | 111 | that it has to look for headers and libraries in <filename
|
---|
[6dff9ef] | 112 | class="directory">$LFS</filename>. But the build system for GCC uses
|
---|
[fcc02767] | 113 | other tools, which are not aware of this location. This switch is
|
---|
[6dff9ef] | 114 | needed so those tools will find the needed files in <filename
|
---|
[fcc02767] | 115 | class="directory">$LFS</filename>, and not on the host.</para>
|
---|
| 116 | </listitem>
|
---|
| 117 | </varlistentry>
|
---|
| 118 |
|
---|
[3bb463d] | 119 | <varlistentry>
|
---|
| 120 | <term><parameter>--target=$LFS_TGT</parameter></term>
|
---|
| 121 | <listitem>
|
---|
[6dff9ef] | 122 | <para>We are cross-compiling GCC, so it's impossible to build
|
---|
[3bb463d] | 123 | target libraries (<filename class="libraryfile">libgcc</filename>
|
---|
| 124 | and <filename class="libraryfile">libstdc++</filename>) with the
|
---|
[6dff9ef] | 125 | previously compiled GCC binaries—those binaries won't run on the
|
---|
| 126 | host. The GCC build system will attempt to use the host's
|
---|
| 127 | C and C++ compilers as a workaround by default.
|
---|
| 128 | Building the GCC target libraries with a different
|
---|
| 129 | version of GCC is not supported, so using the host's compilers may cause
|
---|
| 130 | the build to fail. This parameter ensures the libraries are built by GCC
|
---|
| 131 | pass 1.</para>
|
---|
[3bb463d] | 132 | </listitem>
|
---|
| 133 | </varlistentry>
|
---|
| 134 |
|
---|
| 135 | <varlistentry>
|
---|
| 136 | <term><parameter>LDFLAGS_FOR_TARGET=...</parameter></term>
|
---|
| 137 | <listitem>
|
---|
| 138 | <para>Allow <filename class="libraryfile">libstdc++</filename> to
|
---|
[6dff9ef] | 139 | use the shared <filename class="libraryfile">libgcc</filename> being
|
---|
| 140 | built in this pass, instead of the static version that was built in GCC
|
---|
| 141 | pass 1. This is necessary to support C++ exception
|
---|
[3bb463d] | 142 | handling.</para>
|
---|
| 143 | </listitem>
|
---|
| 144 | </varlistentry>
|
---|
| 145 |
|
---|
[fcc02767] | 146 | </variablelist>
|
---|
| 147 |
|
---|
| 148 | <para>Compile the package:</para>
|
---|
| 149 |
|
---|
| 150 | <screen><userinput remap="make">make</userinput></screen>
|
---|
| 151 |
|
---|
| 152 | <para>Install the package:</para>
|
---|
| 153 |
|
---|
| 154 | <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
|
---|
| 155 |
|
---|
[bc8cca5] | 156 | <para>As a finishing touch, create a utility symlink. Many programs and scripts
|
---|
[fcc02767] | 157 | run <command>cc</command> instead of <command>gcc</command>, which is
|
---|
| 158 | used to keep programs generic and therefore usable on all kinds of UNIX
|
---|
| 159 | systems where the GNU C compiler is not always installed. Running
|
---|
| 160 | <command>cc</command> leaves the system administrator free to decide
|
---|
| 161 | which C compiler to install:</para>
|
---|
| 162 |
|
---|
| 163 | <screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
|
---|
| 164 |
|
---|
| 165 | </sect2>
|
---|
| 166 |
|
---|
| 167 | <sect2 role="content">
|
---|
| 168 | <title/>
|
---|
| 169 |
|
---|
| 170 | <para>Details on this package are located in
|
---|
| 171 | <xref linkend="contents-gcc" role="."/></para>
|
---|
| 172 |
|
---|
| 173 | </sect2>
|
---|
| 174 |
|
---|
| 175 | </sect1>
|
---|