[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[1770019] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
[673b0d8] | 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
[3e36a78] | 4 | <!ENTITY % patches-entities SYSTEM "../patches.ent">
|
---|
[673b0d8] | 5 | %general-entities;
|
---|
[3e36a78] | 6 | %patches-entities;
|
---|
[673b0d8] | 7 | ]>
|
---|
[9652249] | 8 | <sect1 id="ch-tools-gcc-pass2" role="wrap">
|
---|
[673b0d8] | 9 | <title>GCC-&gcc-version; - Pass 2</title>
|
---|
| 10 | <?dbhtml filename="gcc-pass2.html"?>
|
---|
[bc82645e] | 11 |
|
---|
[81fd230] | 12 | <indexterm zone="ch-tools-gcc-pass2">
|
---|
| 13 | <primary sortas="a-GCC">GCC</primary>
|
---|
| 14 | <secondary>tools, pass 2</secondary></indexterm>
|
---|
| 15 |
|
---|
[9652249] | 16 | <sect2 role="package"><title/>
|
---|
[73aedd1d] | 17 |
|
---|
[9652249] | 18 | <segmentedlist>
|
---|
| 19 | <segtitle>&buildtime;</segtitle>
|
---|
| 20 | <segtitle>&diskspace;</segtitle>
|
---|
[fad7667] | 21 | <seglistitem><seg>11.0 SBU</seg><seg>292 MB</seg></seglistitem>
|
---|
[9652249] | 22 | </segmentedlist>
|
---|
[73aedd1d] | 23 |
|
---|
[81fd230] | 24 | <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
|
---|
| 25 |
|
---|
[9652249] | 26 | </sect2>
|
---|
| 27 |
|
---|
| 28 | <sect2 role="installation">
|
---|
[73aedd1d] | 29 | <title>Re-installation of GCC</title>
|
---|
| 30 |
|
---|
[81fd230] | 31 | <para>This package is known to have issues when its default
|
---|
| 32 | optimization flags (including the <parameter>-march</parameter> and
|
---|
| 33 | <parameter>-mcpu</parameter> options) are changed. If any environment
|
---|
| 34 | variables that override default optimizations have been defined, such
|
---|
| 35 | as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
|
---|
| 36 | unset them when building GCC.</para>
|
---|
| 37 |
|
---|
| 38 | <para>The tools required to test GCC and Binutils—Tcl, Expect
|
---|
| 39 | and DejaGNU—are installed now. GCC and Binutils can now be
|
---|
| 40 | rebuilt, linking them against the new Glibc and testing them properly
|
---|
| 41 | (if running the test suites in this chapter). Please note that these
|
---|
| 42 | test suites are highly dependent on properly functioning PTYs which
|
---|
| 43 | are provided by the host. PTYs are most commonly implemented via the
|
---|
| 44 | <systemitem class="filesystem">devpts</systemitem> file system. Check
|
---|
| 45 | to see if the host system is set up correctly in this regard by
|
---|
| 46 | performing a quick test:</para>
|
---|
[73aedd1d] | 47 |
|
---|
| 48 | <screen><userinput>expect -c "spawn ls"</userinput></screen>
|
---|
| 49 |
|
---|
[81fd230] | 50 | <para>The response might be:</para>
|
---|
| 51 |
|
---|
| 52 | <screen><computeroutput>The system has no more ptys.
|
---|
| 53 | Ask your system administrator to create more.</computeroutput></screen>
|
---|
| 54 |
|
---|
[9041d47] | 55 | <para>If the above message is received, the host does not have its PTYs set up
|
---|
| 56 | properly. In this case, there is no point in running the test suites for GCC and
|
---|
| 57 | Binutils until this issue is resolved. Please consult the LFS FAQ at <ulink
|
---|
| 58 | url="&lfs-root;/lfs/faq.html#no-ptys"/> for more information on how to get PTYs
|
---|
| 59 | working.</para>
|
---|
[81fd230] | 60 |
|
---|
[2e02c35] | 61 | <para>Under normal circumstances, the GCC <command>fixincludes</command> script
|
---|
| 62 | scans the system for header files that need to be fixed (they may contain syntax
|
---|
| 63 | errors, for example). The script might find that some Glibc header files on the
|
---|
| 64 | host system need to be fixed, so fixes them and puts them in the GCC private
|
---|
| 65 | include directory. In <xref linkend="chapter-building-system"/>, after the
|
---|
| 66 | newer Glibc has been installed, this private include directory will be searched
|
---|
| 67 | before the system include directory. This may result in GCC finding the fixed
|
---|
| 68 | headers from the host system, which most likely will not match the Glibc version
|
---|
| 69 | used for the LFS system.</para>
|
---|
| 70 |
|
---|
| 71 | <para>The following command adjusts where the GCC <command>fixincludes</command>
|
---|
| 72 | script searches for headers, so that it fixes only the new headers under
|
---|
| 73 | <filename class="directory">/tools</filename>, not the ones from your host
|
---|
| 74 | system.</para>
|
---|
| 75 |
|
---|
| 76 | <screen><userinput>cp gcc/Makefile.in{,.orig} &&
|
---|
| 77 | sed 's@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g' \
|
---|
| 78 | gcc/Makefile.in.orig > gcc/Makefile.in</userinput></screen>
|
---|
| 79 |
|
---|
| 80 | <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/>
|
---|
| 81 | built GCC with the <option>-fomit-frame-pointer</option> compiler flag.
|
---|
| 82 | Non-bootstrap builds omit this flag by default, so apply the following
|
---|
| 83 | <command>sed</command> to use it in order to ensure consistent compiler builds.
|
---|
| 84 | </para>
|
---|
| 85 |
|
---|
| 86 | <screen><userinput>cp gcc/Makefile.in{,.tmp} &&
|
---|
| 87 | sed 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \
|
---|
| 88 | > gcc/Makefile.in</userinput></screen>
|
---|
| 89 |
|
---|
| 90 | <para>Apply the following patch to change the location of GCC's default dynamic
|
---|
| 91 | linker (typically <filename class="libraryfile">ld-linux.so.2</filename>):</para>
|
---|
| 92 |
|
---|
| 93 | <screen><userinput>patch -Np1 -i ../&gcc-specs-patch;</userinput></screen>
|
---|
| 94 |
|
---|
| 95 | <para>The above patch also removes
|
---|
| 96 | <filename class="directory">/usr/include</filename> from GCC's include search
|
---|
| 97 | path. Patching now rather than adjusting the specs file after installation
|
---|
| 98 | ensures that the new dynamic linker is used during the actual build of GCC. That
|
---|
| 99 | is, all of the binaries created during the build will link against the new
|
---|
[81fd230] | 100 | Glibc.</para>
|
---|
| 101 |
|
---|
[2e02c35] | 102 | <important><para>The above patch is critical in ensuring a
|
---|
[81fd230] | 103 | successful overall build. Do not forget to apply
|
---|
[2e02c35] | 104 | it.</para></important>
|
---|
[81fd230] | 105 |
|
---|
[73aedd1d] | 106 | <para>Create a separate build directory again:</para>
|
---|
| 107 |
|
---|
| 108 | <screen><userinput>mkdir ../gcc-build
|
---|
| 109 | cd ../gcc-build</userinput></screen>
|
---|
| 110 |
|
---|
[81fd230] | 111 | <para>Before starting to build GCC, remember to unset any environment
|
---|
| 112 | variables that override the default optimization flags.</para>
|
---|
| 113 |
|
---|
[d27a27b] | 114 | <para>Now prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 115 |
|
---|
[673b0d8] | 116 | <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
|
---|
[9dfc02f] | 117 | --libexecdir=/tools/lib --with-local-prefix=/tools \
|
---|
[d72e04a] | 118 | --enable-clocale=gnu --enable-shared \
|
---|
| 119 | --enable-threads=posix --enable-__cxa_atexit \
|
---|
| 120 | --enable-languages=c,c++ --disable-libstdcxx-pch</userinput></screen>
|
---|
[73aedd1d] | 121 |
|
---|
[81fd230] | 122 | <para>The meaning of the new configure options:</para>
|
---|
| 123 |
|
---|
| 124 | <variablelist>
|
---|
| 125 | <varlistentry>
|
---|
| 126 | <term><parameter>--enable-clocale=gnu</parameter></term>
|
---|
| 127 | <listitem><para>This option ensures the correct locale model is
|
---|
| 128 | selected for the C++ libraries under all circumstances. If the
|
---|
| 129 | configure script finds the <emphasis>de_DE</emphasis> locale installed, it will select the
|
---|
| 130 | correct gnu locale model. However, if the <emphasis>de_DE</emphasis> locale is not
|
---|
| 131 | installed, there is the risk of building Application Binary Interface
|
---|
| 132 | (ABI)-incompatible C++ libraries because the incorrect generic locale
|
---|
| 133 | model may be selected.</para></listitem>
|
---|
| 134 | </varlistentry>
|
---|
| 135 |
|
---|
| 136 | <varlistentry>
|
---|
| 137 | <term><parameter>--enable-threads=posix</parameter></term>
|
---|
| 138 | <listitem><para>This enables C++ exception handling for multi-threaded
|
---|
| 139 | code.</para></listitem>
|
---|
| 140 | </varlistentry>
|
---|
| 141 |
|
---|
| 142 | <varlistentry>
|
---|
| 143 | <term><parameter>--enable-__cxa_atexit</parameter></term>
|
---|
| 144 | <listitem><para>This option allows use of
|
---|
| 145 | <emphasis>__cxa_atexit</emphasis>, rather than
|
---|
| 146 | <emphasis>atexit</emphasis>, to register C++ destructors for local
|
---|
| 147 | statics and global objects. This option is essential for fully
|
---|
[9310805] | 148 | standards-compliant handling of destructors. It also affects the C++
|
---|
[81fd230] | 149 | ABI, and therefore results in C++ shared libraries and C++ programs
|
---|
| 150 | that are interoperable with other Linux
|
---|
| 151 | distributions.</para></listitem>
|
---|
| 152 | </varlistentry>
|
---|
| 153 |
|
---|
| 154 | <varlistentry>
|
---|
| 155 | <term><parameter>--enable-languages=c,c++</parameter></term>
|
---|
| 156 | <listitem><para>This option
|
---|
| 157 | ensures that both the C and C++ compilers are built.</para></listitem>
|
---|
| 158 | </varlistentry>
|
---|
| 159 |
|
---|
| 160 | <varlistentry>
|
---|
| 161 | <term><parameter>--disable-libstdcxx-pch</parameter></term>
|
---|
| 162 | <listitem><para>Do not build the pre-compiled header (PCH) for
|
---|
| 163 | <filename class="libraryfile">libstdc++</filename>. It takes up a lot of space,
|
---|
| 164 | and we have no use for it.</para></listitem>
|
---|
| 165 | </varlistentry>
|
---|
| 166 | </variablelist>
|
---|
| 167 |
|
---|
[73aedd1d] | 168 | <para>Compile the package:</para>
|
---|
| 169 |
|
---|
| 170 | <screen><userinput>make</userinput></screen>
|
---|
| 171 |
|
---|
[81fd230] | 172 | <para>There is no need to use the <parameter>bootstrap</parameter>
|
---|
| 173 | target now because the compiler being used to compile this GCC was
|
---|
| 174 | built from the exact same version of the GCC sources used
|
---|
| 175 | earlier.</para>
|
---|
| 176 |
|
---|
| 177 | <para>Compilation is now complete. As previously mentioned, running
|
---|
| 178 | the test suites for the temporary tools compiled in this chapter is
|
---|
| 179 | not mandatory. To run the GCC test suite anyway, use the following
|
---|
| 180 | command:</para>
|
---|
[3d36131c] | 181 |
|
---|
[73aedd1d] | 182 | <screen><userinput>make -k check</userinput></screen>
|
---|
| 183 |
|
---|
[81fd230] | 184 | <para>The <parameter>-k</parameter> flag is used to make the test suite run
|
---|
| 185 | through to completion and not stop at the first failure. The GCC test
|
---|
| 186 | suite is very comprehensive and is almost guaranteed to generate a few
|
---|
| 187 | failures. To receive a summary of the test suite results, run:</para>
|
---|
[73aedd1d] | 188 |
|
---|
[673b0d8] | 189 | <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
|
---|
[e8692c5e] | 190 |
|
---|
[fba1478] | 191 | <para>For only the summaries, pipe the output through
|
---|
[81fd230] | 192 | <userinput>grep -A7 Summ</userinput>.</para>
|
---|
[73aedd1d] | 193 |
|
---|
[e9f146e] | 194 | <para>Results can be compared with those located at <ulink
|
---|
| 195 | url="&test-results;"/>.</para>
|
---|
[81fd230] | 196 |
|
---|
[2e02c35] | 197 | <para>A few unexpected failures cannot always be avoided. The GCC developers are
|
---|
| 198 | usually aware of these issues, but have not resolved them yet. In particular,
|
---|
| 199 | the <filename class="libraryfile">libmudflap</filename> tests are known be
|
---|
| 200 | particularly problematic as a result of a bug in GCC (<ulink
|
---|
| 201 | url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>). Unless the test
|
---|
| 202 | results are vastly different from those at the above URL, it is safe to
|
---|
| 203 | continue.</para>
|
---|
[ede9b9b] | 204 |
|
---|
[81fd230] | 205 | <para>Install the package:</para>
|
---|
[73aedd1d] | 206 |
|
---|
| 207 | <screen><userinput>make install</userinput></screen>
|
---|
| 208 |
|
---|
[81fd230] | 209 | <note><para>At this point it is strongly recommended to repeat the
|
---|
| 210 | sanity check we performed earlier in this chapter. Refer back to <xref
|
---|
| 211 | linkend="ch-tools-adjusting" role=","/> and repeat the test compilation. If
|
---|
| 212 | the result is wrong, the most likely reason is that the GCC Specs
|
---|
| 213 | patch was not properly applied.</para></note>
|
---|
[73aedd1d] | 214 |
|
---|
| 215 | </sect2>
|
---|
[bc82645e] | 216 |
|
---|
[81fd230] | 217 | <sect2 role="content"><title/>
|
---|
| 218 | <para>Details on this package are located in <xref
|
---|
| 219 | linkend="contents-gcc" role="."/></para>
|
---|
| 220 | </sect2>
|
---|
| 221 |
|
---|
[bc82645e] | 222 | </sect1>
|
---|
[81fd230] | 223 |
|
---|