1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
4 | <!ENTITY % patches-entities SYSTEM "../patches.ent">
|
---|
5 | %general-entities;
|
---|
6 | %patches-entities;
|
---|
7 | ]>
|
---|
8 | <sect1 id="ch-tools-gcc-pass2" role="wrap">
|
---|
9 | <title>GCC-&gcc-version; - Pass 2</title>
|
---|
10 | <?dbhtml filename="gcc-pass2.html"?>
|
---|
11 |
|
---|
12 | <indexterm zone="ch-tools-gcc-pass2">
|
---|
13 | <primary sortas="a-GCC">GCC</primary>
|
---|
14 | <secondary>tools, pass 2</secondary></indexterm>
|
---|
15 |
|
---|
16 | <sect2 role="package"><title/>
|
---|
17 |
|
---|
18 | <segmentedlist>
|
---|
19 | <segtitle>&buildtime;</segtitle>
|
---|
20 | <segtitle>&diskspace;</segtitle>
|
---|
21 | <seglistitem><seg>11.0 SBU</seg><seg>274 MB</seg></seglistitem>
|
---|
22 | </segmentedlist>
|
---|
23 |
|
---|
24 | <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
|
---|
25 |
|
---|
26 | </sect2>
|
---|
27 |
|
---|
28 | <sect2 role="installation">
|
---|
29 | <title>Re-installation of GCC</title>
|
---|
30 |
|
---|
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>
|
---|
47 |
|
---|
48 | <screen><userinput>expect -c "spawn ls"</userinput></screen>
|
---|
49 |
|
---|
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 |
|
---|
55 | <para>If the above message is received, the host does not have its
|
---|
56 | PTYs set up properly. In this case, there is no point in running the
|
---|
57 | test suites for GCC and Binutils until this issue is resolved. Please
|
---|
58 | consult the LFS Wiki at <ulink url="&wiki-root;"/> for more
|
---|
59 | information on how to get PTYs working.</para>
|
---|
60 |
|
---|
61 | <para>Because the C and the C++ compilers will be built, unpack both
|
---|
62 | the core and the g++ tarballs (as well as test suite, if you want to
|
---|
63 | run the tests). By unpacking them in the working directory, they will
|
---|
64 | all unfold into a single <filename
|
---|
65 | class="directory">gcc-&gcc-version;/</filename> subdirectory.</para>
|
---|
66 |
|
---|
67 | <para>First correct a known problem and make an essential adjustment:</para>
|
---|
68 |
|
---|
69 | <screen><userinput>patch -Np1 -i ../&gcc-no_fixincludes-patch;
|
---|
70 | patch -Np1 -i ../&gcc-specs-patch;</userinput></screen>
|
---|
71 |
|
---|
72 | <para>The first patch disables the GCC <command>fixincludes</command>
|
---|
73 | script. This was briefly mentioned earlier, but a more in-depth
|
---|
74 | explanation of the fixincludes process is warranted here. Under normal
|
---|
75 | circumstances, the GCC <command>fixincludes</command> script scans the
|
---|
76 | system for header files that need to be fixed. It might find that some
|
---|
77 | Glibc header files on the host system need to be fixed, and will fix
|
---|
78 | them and put them in the GCC private include directory. In <xref
|
---|
79 | linkend="chapter-building-system"/>, after the newer Glibc has been
|
---|
80 | installed, this private include directory will be searched before the
|
---|
81 | system include directory. This may result in GCC finding the fixed
|
---|
82 | headers from the host system, which most likely will not match the
|
---|
83 | Glibc version used for the LFS system.</para>
|
---|
84 |
|
---|
85 | <para>The second patch changes GCC's default location of the dynamic
|
---|
86 | linker (typically <filename class="libraryfile">ld-linux.so.2</filename>). It also removes
|
---|
87 | <filename class="directory">/usr/include</filename> from GCC's include
|
---|
88 | search path. Patching now rather than adjusting the specs file after
|
---|
89 | installation ensures that the new dynamic linker is used during the
|
---|
90 | actual build of GCC. That is, all of the final (and temporary)
|
---|
91 | binaries created during the build will link against the new
|
---|
92 | Glibc.</para>
|
---|
93 |
|
---|
94 | <important><para>The above patches are critical in ensuring a
|
---|
95 | successful overall build. Do not forget to apply
|
---|
96 | them.</para></important>
|
---|
97 |
|
---|
98 | <para>Create a separate build directory again:</para>
|
---|
99 |
|
---|
100 | <screen><userinput>mkdir ../gcc-build
|
---|
101 | cd ../gcc-build</userinput></screen>
|
---|
102 |
|
---|
103 | <para>Before starting to build GCC, remember to unset any environment
|
---|
104 | variables that override the default optimization flags.</para>
|
---|
105 |
|
---|
106 | <para>Now prepare GCC for compilation:</para>
|
---|
107 |
|
---|
108 | <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
|
---|
109 | --libexecdir=/tools/lib --with-local-prefix=/tools \
|
---|
110 | --enable-clocale=gnu --enable-shared \
|
---|
111 | --enable-threads=posix --enable-__cxa_atexit \
|
---|
112 | --enable-languages=c,c++ --disable-libstdcxx-pch</userinput></screen>
|
---|
113 |
|
---|
114 | <para>The meaning of the new configure options:</para>
|
---|
115 |
|
---|
116 | <variablelist>
|
---|
117 | <varlistentry>
|
---|
118 | <term><parameter>--enable-clocale=gnu</parameter></term>
|
---|
119 | <listitem><para>This option ensures the correct locale model is
|
---|
120 | selected for the C++ libraries under all circumstances. If the
|
---|
121 | configure script finds the <emphasis>de_DE</emphasis> locale installed, it will select the
|
---|
122 | correct gnu locale model. However, if the <emphasis>de_DE</emphasis> locale is not
|
---|
123 | installed, there is the risk of building Application Binary Interface
|
---|
124 | (ABI)-incompatible C++ libraries because the incorrect generic locale
|
---|
125 | model may be selected.</para></listitem>
|
---|
126 | </varlistentry>
|
---|
127 |
|
---|
128 | <varlistentry>
|
---|
129 | <term><parameter>--enable-threads=posix</parameter></term>
|
---|
130 | <listitem><para>This enables C++ exception handling for multi-threaded
|
---|
131 | code.</para></listitem>
|
---|
132 | </varlistentry>
|
---|
133 |
|
---|
134 | <varlistentry>
|
---|
135 | <term><parameter>--enable-__cxa_atexit</parameter></term>
|
---|
136 | <listitem><para>This option allows use of
|
---|
137 | <emphasis>__cxa_atexit</emphasis>, rather than
|
---|
138 | <emphasis>atexit</emphasis>, to register C++ destructors for local
|
---|
139 | statics and global objects. This option is essential for fully
|
---|
140 | standards-compliant handling of destructors. It also effects the C++
|
---|
141 | ABI, and therefore results in C++ shared libraries and C++ programs
|
---|
142 | that are interoperable with other Linux
|
---|
143 | distributions.</para></listitem>
|
---|
144 | </varlistentry>
|
---|
145 |
|
---|
146 | <varlistentry>
|
---|
147 | <term><parameter>--enable-languages=c,c++</parameter></term>
|
---|
148 | <listitem><para>This option
|
---|
149 | ensures that both the C and C++ compilers are built.</para></listitem>
|
---|
150 | </varlistentry>
|
---|
151 |
|
---|
152 | <varlistentry>
|
---|
153 | <term><parameter>--disable-libstdcxx-pch</parameter></term>
|
---|
154 | <listitem><para>Do not build the pre-compiled header (PCH) for
|
---|
155 | <filename class="libraryfile">libstdc++</filename>. It takes up a lot of space,
|
---|
156 | and we have no use for it.</para></listitem>
|
---|
157 | </varlistentry>
|
---|
158 | </variablelist>
|
---|
159 |
|
---|
160 | <para>Compile the package:</para>
|
---|
161 |
|
---|
162 | <screen><userinput>make</userinput></screen>
|
---|
163 |
|
---|
164 | <para>There is no need to use the <parameter>bootstrap</parameter>
|
---|
165 | target now because the compiler being used to compile this GCC was
|
---|
166 | built from the exact same version of the GCC sources used
|
---|
167 | earlier.</para>
|
---|
168 |
|
---|
169 | <para>Compilation is now complete. As previously mentioned, running
|
---|
170 | the test suites for the temporary tools compiled in this chapter is
|
---|
171 | not mandatory. To run the GCC test suite anyway, use the following
|
---|
172 | command:</para>
|
---|
173 |
|
---|
174 | <screen><userinput>make -k check</userinput></screen>
|
---|
175 |
|
---|
176 | <para>The <parameter>-k</parameter> flag is used to make the test suite run
|
---|
177 | through to completion and not stop at the first failure. The GCC test
|
---|
178 | suite is very comprehensive and is almost guaranteed to generate a few
|
---|
179 | failures. To receive a summary of the test suite results, run:</para>
|
---|
180 |
|
---|
181 | <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
|
---|
182 |
|
---|
183 | <para>For only the summaries, pipe the output through
|
---|
184 | <userinput>grep -A7 Summ</userinput>.</para>
|
---|
185 |
|
---|
186 | <para>Results can be compared to those posted to the gcc-testresults
|
---|
187 | mailing list to see similar configurations to the one being built. For
|
---|
188 | an example of how current GCC-&gcc-version; should look on
|
---|
189 | i686-pc-linux-gnu, see <ulink
|
---|
190 | url="http://gcc.gnu.org/ml/gcc-testresults/2004-07/msg00179.html"/>.</para>
|
---|
191 |
|
---|
192 | <para>A few unexpected failures cannot always be avoided. The
|
---|
193 | GCC developers are usually aware of these issues, but have not
|
---|
194 | resolved them yet. Unless the test results are vastly different from
|
---|
195 | those at the above URL, it is safe to continue.</para>
|
---|
196 |
|
---|
197 | <para>Install the package:</para>
|
---|
198 |
|
---|
199 | <screen><userinput>make install</userinput></screen>
|
---|
200 |
|
---|
201 | <note><para>At this point it is strongly recommended to repeat the
|
---|
202 | sanity check we performed earlier in this chapter. Refer back to <xref
|
---|
203 | linkend="ch-tools-adjusting" role=","/> and repeat the test compilation. If
|
---|
204 | the result is wrong, the most likely reason is that the GCC Specs
|
---|
205 | patch was not properly applied.</para></note>
|
---|
206 |
|
---|
207 | </sect2>
|
---|
208 |
|
---|
209 | <sect2 role="content"><title/>
|
---|
210 | <para>Details on this package are located in <xref
|
---|
211 | linkend="contents-gcc" role="."/></para>
|
---|
212 | </sect2>
|
---|
213 |
|
---|
214 | </sect1>
|
---|
215 |
|
---|