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