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,
|
---|
30 | Expect and DejaGNU. Therefore we can now rebuild GCC and Binutils, linking
|
---|
31 | them against the new Glibc, and test them properly (if running the test suites
|
---|
32 | in this chapter). One thing to note, however, is that these test suites are
|
---|
33 | highly dependent on properly functioning pseudo terminals (PTYs) which are
|
---|
34 | provided 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
|
---|
36 | system 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
|
---|
45 | properly. In this case there is no point in running the test suites for GCC
|
---|
46 | and Binutils until you are able to resolve the issue. You can consult the LFS
|
---|
47 | Wiki at <uri xlink:href="&wiki-root;"/> for more information on how to get PTYs
|
---|
48 | working.</para>
|
---|
49 |
|
---|
50 | <para>This time we will build both the C and the C++ compilers, so you'll have
|
---|
51 | to unpack both the core and the g++ tarballs (and testsuite too, if you want to
|
---|
52 | run the tests). Unpacking them in your working directory, they will all unfold
|
---|
53 | into 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
|
---|
58 | patch -Np1 -i ../gcc-&gcc-version;-specs-2.patch</userinput></screen>
|
---|
59 |
|
---|
60 | <para>The first patch disables the GCC <command>fixincludes</command> script. We
|
---|
61 | mentioned this briefly earlier, but a slightly more in-depth explanation of
|
---|
62 | the 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
|
---|
64 | might find that some Glibc header files on your host system need to be fixed,
|
---|
65 | fix 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
|
---|
67 | Glibc, this private include directory would be searched before the system
|
---|
68 | include directory, resulting in GCC finding the fixed headers from the host
|
---|
69 | system, which would most likely not match the Glibc version actually used for
|
---|
70 | the 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
|
---|
75 | path. Patching now rather than adjusting the specs file after installation
|
---|
76 | ensures that our new dynamic linker gets used during the actual build of GCC.
|
---|
77 | That is, all the final (and temporary) binaries created during the build will
|
---|
78 | link against the new Glibc.</para>
|
---|
79 |
|
---|
80 | <important><para>The above patches are <emphasis>critical</emphasis> in ensuring
|
---|
81 | a 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
|
---|
86 | cd ../gcc-build</userinput></screen>
|
---|
87 |
|
---|
88 | <para>Before starting to build GCC, remember to unset any environment
|
---|
89 | variables 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
|
---|
105 | ensures the correct locale model is selected for the C++ libraries under all
|
---|
106 | circumstances. If the configure script finds the <emphasis>de_DE</emphasis>
|
---|
107 | locale installed, it will select the correct <emphasis>gnu</emphasis> locale
|
---|
108 | model. However, people who don't install the <emphasis>de_DE</emphasis> locale
|
---|
109 | would 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
|
---|
116 | C++ 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
|
---|
122 | allows use of __cxa_atexit, rather than atexit, to register C++ destructors for
|
---|
123 | local statics and global objects and is essential for fully standards-compliant
|
---|
124 | handling of destructors. It also affects the C++ ABI and therefore results in
|
---|
125 | C++ shared libraries and C++ programs that are interoperable with other Linux
|
---|
126 | distributions.</para></listitem>
|
---|
127 | </varlistentry>
|
---|
128 |
|
---|
129 | <varlistentry>
|
---|
130 | <term><parameter>--enable-languages=c,c++</parameter></term>
|
---|
131 | <listitem><para>This option
|
---|
132 | ensures 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
|
---|
138 | PCH (pre-compiled header) for libstdc++. It takes up a ton of space, and we
|
---|
139 | have 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,
|
---|
148 | as the compiler we're using to compile this GCC was built from the exact same
|
---|
149 | version of the GCC sources we used earlier.</para>
|
---|
150 |
|
---|
151 | <para>Compilation is now complete. As mentioned earlier, running the test suites
|
---|
152 | for 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
|
---|
157 | through to completion and not stop at the first failure. The GCC test suite is
|
---|
158 | very comprehensive and is almost guaranteed to generate a few failures. To get
|
---|
159 | a 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
|
---|
167 | mailing list for similar configurations to your own. For an example of how
|
---|
168 | current 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
|
---|
172 | developers are usually aware of these, but haven't yet gotten around to fixing
|
---|
173 | them. In short, unless your results are vastly different from those at the above
|
---|
174 | URL, 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
|
---|
181 | we performed earlier in this chapter. Refer back to
|
---|
182 | <xref linkend="ch-tools-adjusting"/> and repeat the little test compilation. If
|
---|
183 | the result is wrong, then most likely you forgot to apply the above mentioned
|
---|
184 | GCC 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>
|
---|