source: chapter05/gcc-pass2.xml@ 1375d26

Last change on this file since 1375d26 was 1375d26, checked in by Matthew Burgess <matthew@…>, 19 years ago
  • (chapter05/*.xml) RELAX NG validation fixes

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/LFS-RNG/BOOK@4385 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 8.4 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE section [
3 <!ENTITY % general-entities SYSTEM "../general.ent">
4 %general-entities;
5]>
6<section xmlns="http://docbook.org/docbook-ng"
7 xmlns:xlink="http://www.w3.org/1999/xlink"
8 xml: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<section 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</section>
25
26<section role="installation">
27<title>Re-installation of GCC</title>
28
29<para>The tools required to test GCC and Binutils are installed now: Tcl,
30Expect and DejaGNU. Therefore we can now rebuild GCC and Binutils, linking
31them against the new Glibc, and test them properly (if running the test suites
32in this chapter). One thing to note, however, is that these test suites are
33highly dependent on properly functioning pseudo terminals (PTYs) which are
34provided by your host. These days, PTYs are most commonly implemented via the
35<systemitem class="filesystem">devpts</systemitem> file system. You can quickly check if your host
36system is set up correctly in this regard by performing a simple test:</para>
37
38<screen><userinput>expect -c "spawn ls"</userinput></screen>
39
40<para>The response might be:</para>
41
42<blockquote><screen><computeroutput>The system has no more ptys. Ask your system administrator to create more.</computeroutput></screen></blockquote>
43
44<para>If you receive the above message, your host doesn't have its PTYs set up
45properly. In this case there is no point in running the test suites for GCC
46and Binutils until you are able to resolve the issue. You can consult the LFS
47Wiki at <uri xlink:href="&wiki-root;"/> for more information on how to get PTYs
48working.</para>
49
50<para>This time we will build both the C and the C++ compilers, so you'll have
51to unpack both the core and the g++ tarballs (and testsuite too, if you want to
52run the tests). Unpacking them in your working directory, they will all unfold
53into a single <filename class="directory">gcc-&gcc-version;/</filename> subdirectory.</para>
54
55<para>First correct a problem and make an essential adjustment:</para>
56
57<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-no_fixincludes-1.patch
58patch -Np1 -i ../gcc-&gcc-version;-specs-2.patch</userinput></screen>
59
60<para>The first patch disables the GCC <command>fixincludes</command> script. We
61mentioned this briefly earlier, but a slightly more in-depth explanation of
62the fixincludes process is warranted here. Under normal circumstances, the GCC
63<command>fixincludes</command> script scans your system for header files that need to be fixed. It
64might find that some Glibc header files on your host system need to be fixed,
65fix them and put them in the GCC private include directory. Then, later on in
66<xref linkend="chapter-building-system"/>, after we've installed the newer
67Glibc, this private include directory would be searched before the system
68include directory, resulting in GCC finding the fixed headers from the host
69system, which would most likely not match the Glibc version actually used for
70the LFS system.</para>
71
72<para>The second patch changes GCC's default location of the dynamic linker
73(typically <filename>ld-linux.so.2</filename>). It also removes
74<filename class="directory">/usr/include</filename> from GCC's include search
75path. Patching now rather than adjusting the specs file after installation
76ensures that our new dynamic linker gets used during the actual build of GCC.
77That is, all the final (and temporary) binaries created during the build will
78link against the new Glibc.</para>
79
80<important><para>The above patches are <emphasis>critical</emphasis> in ensuring
81a successful overall build. Do not forget to apply them.</para></important>
82
83<para>Create a separate build directory again:</para>
84
85<screen><userinput>mkdir ../gcc-build
86cd ../gcc-build</userinput></screen>
87
88<para>Before starting to build GCC, remember to unset any environment
89variables that override the default optimization flags.</para>
90
91<para>Now prepare GCC for compilation:</para>
92
93<screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
94 --libexecdir=/tools/lib --with-local-prefix=/tools \
95 --enable-clocale=gnu --enable-shared --enable-threads=posix \
96 --enable-__cxa_atexit --enable-languages=c,c++ \
97 --disable-libstdcxx-pch</userinput></screen>
98
99<para>The meaning of the new configure options:</para>
100
101<variablelist>
102<varlistentry>
103<term><parameter>--enable-clocale=gnu</parameter></term>
104<listitem><para>This option
105ensures the correct locale model is selected for the C++ libraries under all
106circumstances. If the configure script finds the <emphasis>de_DE</emphasis>
107locale installed, it will select the correct <emphasis>gnu</emphasis> locale
108model. However, people who don't install the <emphasis>de_DE</emphasis> locale
109would run the risk of building ABI incompatible C++ libraries due to the wrong
110<emphasis>generic</emphasis> locale model being selected.</para></listitem>
111</varlistentry>
112
113<varlistentry>
114<term><parameter>--enable-threads=posix</parameter></term>
115<listitem><para>This enables
116C++ exception handling for multi-threaded code.</para></listitem>
117</varlistentry>
118
119<varlistentry>
120<term><parameter>--enable-__cxa_atexit</parameter></term>
121<listitem><para>This option
122allows use of __cxa_atexit, rather than atexit, to register C++ destructors for
123local statics and global objects and is essential for fully standards-compliant
124handling of destructors. It also affects the C++ ABI and therefore results in
125C++ shared libraries and C++ programs that are interoperable with other Linux
126distributions.</para></listitem>
127</varlistentry>
128
129<varlistentry>
130<term><parameter>--enable-languages=c,c++</parameter></term>
131<listitem><para>This option
132ensures that both the C and C++ compilers are built.</para></listitem>
133</varlistentry>
134
135<varlistentry>
136<term><parameter>--disable-libstdcxx-pch</parameter></term>
137<listitem><para>Don't build the
138PCH (pre-compiled header) for libstdc++. It takes up a ton of space, and we
139have no use for it.</para></listitem>
140</varlistentry>
141</variablelist>
142
143<para>Compile the package:</para>
144
145<screen><userinput>make</userinput></screen>
146
147<para>There is no need to use the <parameter>bootstrap</parameter> target now,
148as the compiler we're using to compile this GCC was built from the exact same
149version of the GCC sources we used earlier.</para>
150
151<para>Compilation is now complete. As mentioned earlier, running the test suites
152for the temporary tools compiled in this chapter is not mandatory. If you want to run the GCC test suite anyway, the following command will do so:</para>
153
154<screen><userinput>make -k check</userinput></screen>
155
156<para>The <parameter>-k</parameter> flag is used to make the test suite run
157through to completion and not stop at the first failure. The GCC test suite is
158very comprehensive and is almost guaranteed to generate a few failures. To get
159a summary of the test suite results, run this:</para>
160
161<screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
162
163<para>(For just the summaries, pipe the output through
164<userinput>grep -A7 Summ</userinput>.)</para>
165
166<para>You can compare your results to those posted to the gcc-testresults
167mailing list for similar configurations to your own. For an example of how
168current GCC-&gcc-version; should look on i686-pc-linux-gnu, see
169<uri xlink:href="http://gcc.gnu.org/ml/gcc-testresults/2004-09/msg00261.html"/>.</para>
170
171<para>Having a few unexpected failures often cannot be avoided. The GCC
172developers are usually aware of these, but haven't yet gotten around to fixing
173them. In short, unless your results are vastly different from those at the above
174URL, it is safe to continue.</para>
175
176<para>And finally install the package:</para>
177
178<screen><userinput>make install</userinput></screen>
179
180<note><para>At this point it is strongly recommended to repeat the sanity check
181we performed earlier in this chapter. Refer back to
182<xref linkend="ch-tools-adjusting"/> and repeat the little test compilation. If
183the result is wrong, then most likely you forgot to apply the above mentioned
184GCC Specs patch.</para></note>
185
186</section>
187
188<section role="content"><title/>
189<para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
190</section>
191
192</section>
Note: See TracBrowser for help on using the repository browser.