source: chapter06/gcc.xml@ 0d2c43f

Last change on this file since 0d2c43f was 0d2c43f, checked in by Jeremy Huntwork <jhuntwork@…>, 17 years ago

Use --with-arch on GCC instead of -march on Glibc

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

  • Property mode set to 100644
File size: 14.4 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-system-gcc" role="wrap">
9 <?dbhtml filename="gcc.html"?>
10
11 <title>GCC-&gcc-version;</title>
12
13 <indexterm zone="ch-system-gcc">
14 <primary sortas="a-GCC">GCC</primary>
15 </indexterm>
16
17 <sect2 role="package">
18 <title/>
19
20 <para>The GCC package contains the GNU compiler collection, which includes
21 the C and C++ compilers.</para>
22
23 <segmentedlist>
24 <segtitle>&buildtime;</segtitle>
25 <segtitle>&diskspace;</segtitle>
26
27 <seglistitem>
28 <seg>&gcc-ch6-sbu;</seg>
29 <seg>&gcc-ch6-du;</seg>
30 </seglistitem>
31 </segmentedlist>
32
33 </sect2>
34
35 <sect2 role="installation">
36 <title>Installation of GCC</title>
37
38 <para>Apply a <command>sed</command> substitution that will suppress the
39 installation of <filename class="libraryfile">libiberty.a</filename>. The
40 version of <filename class="libraryfile">libiberty.a</filename> provided by
41 Binutils will be used instead:</para>
42
43<screen><userinput>sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
44
45 <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/>
46 built GCC with the <option>-fomit-frame-pointer</option> compiler flag.
47 Non-bootstrap builds omit this flag by default, so apply the following
48 <command>sed</command> to use it in order to ensure consistent compiler
49 builds:</para>
50
51<screen><userinput>sed -i 's/^XCFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in</userinput></screen>
52
53 <para>The <command>fixincludes</command> script is known to occasionally
54 erroneously attempt to &quot;fix&quot; the system headers installed so far. As
55 the headers installed by GCC-&gcc-version; and Glibc-&glibc-version; are known
56 to not require fixing, issue the following command to prevent the
57 <command>fixincludes</command> script from running:</para>
58
59<screen><userinput>sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in</userinput></screen>
60
61 <para>GCC provides a <command>gccbug</command> script which detects at
62 compile time whether mktemp is present, and hardcodes the result in a test.
63 This will cause the script to fall back to using less random names for
64 temporary files. We will be installing mktemp later, so the following sed
65 will simulate its presence:</para>
66
67<screen><userinput>sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in</userinput></screen>
68
69 <para>The GCC documentation recommends building GCC outside of the source
70 directory in a dedicated build directory:</para>
71
72<screen><userinput>mkdir -v ../gcc-build
73cd ../gcc-build</userinput></screen>
74
75 <para>Prepare GCC for compilation:</para>
76
77<screen><userinput>../gcc-&gcc-version;/configure --prefix=/usr \
78 --libexecdir=/usr/lib --enable-shared \
79 --enable-threads=posix --enable-__cxa_atexit \
80 --enable-clocale=gnu --enable-languages=c,c++ \
81 --disable-multilib --with-arch=i486</userinput></screen>
82
83 <para>Compile the package:</para>
84
85<screen><userinput>make</userinput></screen>
86
87 <important>
88 <para>In this section, the test suite for GCC is considered
89 critical. Do not skip it under any circumstance.</para>
90 </important>
91
92 <para>Test the results, but do not stop at errors:</para>
93
94<screen><userinput>make -k check</userinput></screen>
95
96 <para>To receive a summary of the test suite results, run:</para>
97
98<screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
99
100 <para>For only the summaries, pipe the output through
101 <userinput>grep -A7 Summ</userinput>.</para>
102
103 <para>Results can be compared with those located at <ulink
104 url="&test-results;"/>.</para>
105
106 <para>A few unexpected failures cannot always be avoided. The GCC developers
107 are usually aware of these issues, but have not resolved them yet. In
108 particular, the <filename class="libraryfile">libmudflap</filename> tests
109 are known be particularly problematic as a result of a bug in GCC
110 (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
111 Unless the test results are vastly different from those at the above URL,
112 it is safe to continue.</para>
113
114 <para>Install the package:</para>
115
116<screen><userinput>make install</userinput></screen>
117
118 <para>Some packages expect the C preprocessor to be installed in the
119 <filename class="directory">/lib</filename> directory.
120 To support those packages, create this symlink:</para>
121
122<screen><userinput>ln -sv ../usr/bin/cpp /lib</userinput></screen>
123
124 <para>Many packages use the name <command>cc</command> to call the C
125 compiler. To satisfy those packages, create a symlink:</para>
126
127<screen><userinput>ln -sv gcc /usr/bin/cc</userinput></screen>
128
129 <para>Now that our final toolchain is in place, it is important to again ensure
130 that compiling and linking will work as expected. We do this by performing
131 the same sanity checks as we did earlier in the chapter:</para>
132
133 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
134 href="readjusting.xml"
135 xpointer="xpointer(//*[@os='a'])"/>
136
137 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
138 href="readjusting.xml"
139 xpointer="xpointer(//*[@os='b'])"/>
140
141 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
142 href="readjusting.xml"
143 xpointer="xpointer(//*[@os='c'])"/>
144
145 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
146 href="readjusting.xml"
147 xpointer="xpointer(//*[@os='d'])"/>
148
149 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
150 href="readjusting.xml"
151 xpointer="xpointer(//*[@os='e'])"/>
152
153 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
154 href="readjusting.xml"
155 xpointer="xpointer(//*[@os='f'])"/>
156
157<screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
158/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
159/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
160
161 <para>Depending on your machine architecture, the above may differ slightly,
162 the difference usually being the name of the directory
163 after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
164 a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
165 towards the end of the string. The important thing to
166 look for here is that gcc has found all three <filename>crt*.o</filename> files under
167 the <filename class="directory">/usr/lib</filename> directory.</para>
168
169 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
170 href="readjusting.xml"
171 xpointer="xpointer(//*[@os='g'])"/>
172
173<screen><userinput>grep -B3 '^ /usr/include' dummy.log</userinput></screen>
174
175 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
176 href="readjusting.xml"
177 xpointer="xpointer(//*[@os='h'])"/>
178
179<screen><computeroutput>#include &lt;...&gt; search starts here:
180 /usr/local/include
181 /usr/lib/gcc/x86_64-unknown-linux-gnu/&gcc-version;/include
182 /usr/include</computeroutput></screen>
183
184 <para>Again, note that the directory named after your target triplet may be
185 different than the above, depending on your architecture.</para>
186
187 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
188 href="readjusting.xml"
189 xpointer="xpointer(//*[@os='i'])"/>
190
191 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
192 href="readjusting.xml"
193 xpointer="xpointer(//*[@os='j'])"/>
194
195 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
196 href="readjusting.xml"
197 xpointer="xpointer(//*[@os='k'])"/>
198
199<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
200SEARCH_DIR("/usr/local/lib")
201SEARCH_DIR("/lib")
202SEARCH_DIR("/usr/lib");</computeroutput></screen>
203
204 <para>A 64-bit system may see a few more directories. For example, here
205 is the output from a x86_64 machine:</para>
206
207<screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
208SEARCH_DIR("/usr/local/lib64")
209SEARCH_DIR("/lib64")
210SEARCH_DIR("/usr/lib64")
211SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
212SEARCH_DIR("/usr/local/lib")
213SEARCH_DIR("/lib")
214SEARCH_DIR("/usr/lib");</computeroutput></screen>
215
216 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
217 href="readjusting.xml"
218 xpointer="xpointer(//*[@os='l'])"/>
219
220 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
221 href="readjusting.xml"
222 xpointer="xpointer(//*[@os='m'])"/>
223
224 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
225 href="readjusting.xml"
226 xpointer="xpointer(//*[@os='n'])"/>
227
228 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
229 href="readjusting.xml"
230 xpointer="xpointer(//*[@os='o'])"/>
231
232 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
233 href="readjusting.xml"
234 xpointer="xpointer(//*[@os='p'])"/>
235
236 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
237 href="readjusting.xml"
238 xpointer="xpointer(//*[@os='q'])"/>
239
240 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
241 href="readjusting.xml"
242 xpointer="xpointer(//*[@os='r'])"/>
243
244 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
245 href="readjusting.xml"
246 xpointer="xpointer(//*[@os='s'])"/>
247
248 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
249 href="readjusting.xml"
250 xpointer="xpointer(//*[@os='t'])"/>
251
252 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
253 href="readjusting.xml"
254 xpointer="xpointer(//*[@os='u'])"/>
255
256 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
257 href="readjusting.xml"
258 xpointer="xpointer(//*[@os='v'])"/>
259
260 </sect2>
261
262 <sect2 id="contents-gcc" role="content">
263 <title>Contents of GCC</title>
264
265 <segmentedlist>
266 <segtitle>Installed programs</segtitle>
267 <segtitle>Installed libraries</segtitle>
268
269 <seglistitem>
270 <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
271 <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libmudflap.{a,so},
272 libssp.{a,so}libstdc++.{a,so}, and libsupc++.a</seg>
273 </seglistitem>
274 </segmentedlist>
275
276 <variablelist>
277 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
278 <?dbfo list-presentation="list"?>
279 <?dbhtml list-presentation="table"?>
280
281 <varlistentry id="c">
282 <term><command>c++</command></term>
283 <listitem>
284 <para>The C++ compiler</para>
285 <indexterm zone="ch-system-gcc c">
286 <primary sortas="b-c++">c++</primary>
287 </indexterm>
288 </listitem>
289 </varlistentry>
290
291 <varlistentry id="cc">
292 <term><command>cc</command></term>
293 <listitem>
294 <para>The C compiler</para>
295 <indexterm zone="ch-system-gcc cc">
296 <primary sortas="b-cc">cc</primary>
297 </indexterm>
298 </listitem>
299 </varlistentry>
300
301 <varlistentry id="cpp">
302 <term><command>cpp</command></term>
303 <listitem>
304 <para>The C preprocessor; it is used by the compiler to expand the
305 #include, #define, and similar statements in the source files</para>
306 <indexterm zone="ch-system-gcc cpp">
307 <primary sortas="b-cpp">cpp</primary>
308 </indexterm>
309 </listitem>
310 </varlistentry>
311
312 <varlistentry id="g">
313 <term><command>g++</command></term>
314 <listitem>
315 <para>The C++ compiler</para>
316 <indexterm zone="ch-system-gcc g">
317 <primary sortas="b-g++">g++</primary>
318 </indexterm>
319 </listitem>
320 </varlistentry>
321
322 <varlistentry id="gcc">
323 <term><command>gcc</command></term>
324 <listitem>
325 <para>The C compiler</para>
326 <indexterm zone="ch-system-gcc gcc">
327 <primary sortas="b-gcc">gcc</primary>
328 </indexterm>
329 </listitem>
330 </varlistentry>
331
332 <varlistentry id="gccbug">
333 <term><command>gccbug</command></term>
334 <listitem>
335 <para>A shell script used to help create useful bug reports</para>
336 <indexterm zone="ch-system-gcc gccbug">
337 <primary sortas="b-gccbug">gccbug</primary>
338 </indexterm>
339 </listitem>
340 </varlistentry>
341
342 <varlistentry id="gcov">
343 <term><command>gcov</command></term>
344 <listitem>
345 <para>A coverage testing tool; it is used to analyze programs to
346 determine where optimizations will have the most effect</para>
347 <indexterm zone="ch-system-gcc gcov">
348 <primary sortas="b-gcov">gcov</primary>
349 </indexterm>
350 </listitem>
351 </varlistentry>
352
353 <varlistentry id="libgcc">
354 <term><filename class="libraryfile">libgcc</filename></term>
355 <listitem>
356 <para>Contains run-time support for <command>gcc</command></para>
357 <indexterm zone="ch-system-gcc libgcc">
358 <primary sortas="c-libgcc*">libgcc*</primary>
359 </indexterm>
360 </listitem>
361 </varlistentry>
362
363 <varlistentry id="libmudflap">
364 <term><filename class="libraryfile">libmudflap</filename></term>
365 <listitem>
366 <para>Contains routines that support GCC's bounds checking
367 functionality</para>
368 <indexterm zone="ch-system-gcc libmudflap">
369 <primary sortas="c-libmudflap*">libmudflap*</primary>
370 </indexterm>
371 </listitem>
372 </varlistentry>
373
374 <varlistentry id="libssp">
375 <term><filename class="libraryfile">libssp</filename></term>
376 <listitem>
377 <para>Contains routines supporting GCC's stack-smashing protection
378 functionality</para>
379 <indexterm zone="ch-system-gcc libssp">
380 <primary sortas="c-libssp*">libssp*</primary>
381 </indexterm>
382 </listitem>
383 </varlistentry>
384
385 <varlistentry id="libstdc">
386 <term><filename class="libraryfile">libstdc++</filename></term>
387 <listitem>
388 <para>The standard C++ library</para>
389 <indexterm zone="ch-system-gcc libstdc">
390 <primary sortas="c-libstdc++">libstdc++</primary>
391 </indexterm>
392 </listitem>
393 </varlistentry>
394
395 <varlistentry id="libsupc">
396 <term><filename class="libraryfile">libsupc++</filename></term>
397 <listitem>
398 <para>Provides supporting routines for the C++ programming
399 language</para>
400 <indexterm zone="ch-system-gcc libsupc">
401 <primary sortas="c-libsupc++">libsupc++</primary>
402 </indexterm>
403 </listitem>
404 </varlistentry>
405
406 </variablelist>
407
408 </sect2>
409
410</sect1>
Note: See TracBrowser for help on using the repository browser.