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