source: chapter05/gcc-pass2.xml@ 93a5a04

Last change on this file since 93a5a04 was 4356d95, checked in by Matthew Burgess <matthew@…>, 19 years ago

Explain the fixincludes process, and other nearby rewording

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/gcc4/BOOK@6552 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 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>292 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
32optimization flags (including the <parameter>-march</parameter> and
33<parameter>-mcpu</parameter> options) are changed. If any environment
34variables that override default optimizations have been defined, such
35as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
36unset them when building GCC.</para>
37
38<para>The tools required to test GCC and Binutils&mdash;Tcl, Expect
39and DejaGNU&mdash;are installed now. GCC and Binutils can now be
40rebuilt, linking them against the new Glibc and testing them properly
41(if running the test suites in this chapter). Please note that these
42test suites are highly dependent on properly functioning PTYs which
43are provided by the host. PTYs are most commonly implemented via the
44<systemitem class="filesystem">devpts</systemitem> file system. Check
45to see if the host system is set up correctly in this regard by
46performing 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.
53Ask your system administrator to create more.</computeroutput></screen>
54
55<para>If the above message is received, the host does not have its PTYs set up
56properly. In this case, there is no point in running the test suites for GCC and
57Binutils until this issue is resolved. Please consult the LFS FAQ at <ulink
58url="&lfs-root;/lfs/faq.html#no-ptys"/> for more information on how to get PTYs
59working.</para>
60
61<para>Under normal circumstances, the GCC <command>fixincludes</command> script
62scans the system for header files that need to be fixed (they may contain syntax
63errors, for example). The script might find that some Glibc header files on the
64host system need to be fixed, so fixes them and puts them in the GCC private
65include directory. In <xref linkend="chapter-building-system"/>, after the
66newer Glibc has been installed, this private include directory will be searched
67before the system include directory. This may result in GCC finding the fixed
68headers from the host system, which most likely will not match the Glibc version
69used for the LFS system.</para>
70
71<para>The following command adjusts where the GCC <command>fixincludes</command>
72script searches for headers, so that it fixes only the new headers under
73<filename class="directory">/tools</filename>, not the ones from your host
74system.</para>
75
76<screen><userinput>sed -i 's@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g' \
77 gcc/Makefile.in</userinput></screen>
78
79<para>Apply the following patch to change the location of GCC's default dynamic
80linker (typically <filename class="libraryfile">ld-linux.so.2</filename>):</para>
81
82<screen><userinput>patch -Np1 -i ../&gcc-specs-patch;</userinput></screen>
83
84<para>The above patch also removes
85<filename class="directory">/usr/include</filename> from GCC's include search
86path. Patching now rather than adjusting the specs file after installation
87ensures that the new dynamic linker is used during the actual build of GCC. That
88is, all of the binaries created during the build will link against the new
89Glibc.</para>
90
91<important><para>The above patch is critical in ensuring a
92successful overall build. Do not forget to apply
93it.</para></important>
94
95<para>Create a separate build directory again:</para>
96
97<screen><userinput>mkdir ../gcc-build
98cd ../gcc-build</userinput></screen>
99
100<para>Before starting to build GCC, remember to unset any environment
101variables that override the default optimization flags.</para>
102
103<para>Now prepare GCC for compilation:</para>
104
105<screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
106 --libexecdir=/tools/lib --with-local-prefix=/tools \
107 --enable-clocale=gnu --enable-shared \
108 --enable-threads=posix --enable-__cxa_atexit \
109 --enable-languages=c,c++ --disable-libstdcxx-pch</userinput></screen>
110
111<para>The meaning of the new configure options:</para>
112
113<variablelist>
114<varlistentry>
115<term><parameter>--enable-clocale=gnu</parameter></term>
116<listitem><para>This option ensures the correct locale model is
117selected for the C++ libraries under all circumstances. If the
118configure script finds the <emphasis>de_DE</emphasis> locale installed, it will select the
119correct gnu locale model. However, if the <emphasis>de_DE</emphasis> locale is not
120installed, there is the risk of building Application Binary Interface
121(ABI)-incompatible C++ libraries because the incorrect generic locale
122model may be selected.</para></listitem>
123</varlistentry>
124
125<varlistentry>
126<term><parameter>--enable-threads=posix</parameter></term>
127<listitem><para>This enables C++ exception handling for multi-threaded
128code.</para></listitem>
129</varlistentry>
130
131<varlistentry>
132<term><parameter>--enable-__cxa_atexit</parameter></term>
133<listitem><para>This option allows use of
134<emphasis>__cxa_atexit</emphasis>, rather than
135<emphasis>atexit</emphasis>, to register C++ destructors for local
136statics and global objects. This option is essential for fully
137standards-compliant handling of destructors. It also affects the C++
138ABI, and therefore results in C++ shared libraries and C++ programs
139that are interoperable with other Linux
140distributions.</para></listitem>
141</varlistentry>
142
143<varlistentry>
144<term><parameter>--enable-languages=c,c++</parameter></term>
145<listitem><para>This option
146ensures that both the C and C++ compilers are built.</para></listitem>
147</varlistentry>
148
149<varlistentry>
150<term><parameter>--disable-libstdcxx-pch</parameter></term>
151<listitem><para>Do not build the pre-compiled header (PCH) for
152<filename class="libraryfile">libstdc++</filename>. It takes up a lot of space,
153and we have no use for it.</para></listitem>
154</varlistentry>
155</variablelist>
156
157<para>Compile the package:</para>
158
159<screen><userinput>make</userinput></screen>
160
161<para>There is no need to use the <parameter>bootstrap</parameter>
162target now because the compiler being used to compile this GCC was
163built from the exact same version of the GCC sources used
164earlier.</para>
165
166<para>Compilation is now complete. As previously mentioned, running
167the test suites for the temporary tools compiled in this chapter is
168not mandatory. To run the GCC test suite anyway, use the following
169command:</para>
170
171<screen><userinput>make -k check</userinput></screen>
172
173<para>The <parameter>-k</parameter> flag is used to make the test suite run
174through to completion and not stop at the first failure. The GCC test
175suite is very comprehensive and is almost guaranteed to generate a few
176failures. To receive a summary of the test suite results, run:</para>
177
178<screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
179
180<para>For only the summaries, pipe the output through
181<userinput>grep -A7 Summ</userinput>.</para>
182
183<para>Results can be compared with those located at <ulink
184url="&test-results;"/>.</para>
185
186<para>A few unexpected failures cannot always be avoided. The
187GCC developers are usually aware of these issues, but have not
188resolved them yet. Unless the test results are vastly different from
189those at the above URL, it is safe to continue.</para>
190
191<para>Install the package:</para>
192
193<screen><userinput>make install</userinput></screen>
194
195<note><para>At this point it is strongly recommended to repeat the
196sanity check we performed earlier in this chapter. Refer back to <xref
197linkend="ch-tools-adjusting" role=","/> and repeat the test compilation. If
198the result is wrong, the most likely reason is that the GCC Specs
199patch was not properly applied.</para></note>
200
201</sect2>
202
203<sect2 role="content"><title/>
204<para>Details on this package are located in <xref
205linkend="contents-gcc" role="."/></para>
206</sect2>
207
208</sect1>
209
Note: See TracBrowser for help on using the repository browser.