source: chapter06/gcc.xml@ 9fb74db

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 9fb74db was ee321a46, checked in by Bruce Dubbs <bdubbs@…>, 13 years ago

Added Check-1.2.0 library to Chapter 5.
Updated errordiscussion in glibc.
Added a fix for locale issues in gcc.
Incorporated Check library into libpipeline test.

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

  • Property mode set to 100644
File size: 16.6 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 <sect1info condition="script">
12 <productname>gcc</productname>
13 <productnumber>&gcc-version;</productnumber>
14 <address>&gcc-url;</address>
15 </sect1info>
16
17 <title>GCC-&gcc-version;</title>
18
19 <indexterm zone="ch-system-gcc">
20 <primary sortas="a-GCC">GCC</primary>
21 </indexterm>
22
23 <sect2 role="package">
24 <title/>
25
26 <para>The GCC package contains the GNU compiler collection, which includes
27 the C and C++ compilers.</para>
28
29 <segmentedlist>
30 <segtitle>&buildtime;</segtitle>
31 <segtitle>&diskspace;</segtitle>
32
33 <seglistitem>
34 <seg>&gcc-ch6-sbu;</seg>
35 <seg>&gcc-ch6-du;</seg>
36 </seglistitem>
37 </segmentedlist>
38
39 </sect2>
40
41 <sect2 role="installation">
42 <title>Installation of GCC</title>
43
44 <para>Apply a <command>sed</command> substitution that will suppress the
45 installation of <filename class="libraryfile">libiberty.a</filename>. The
46 version of <filename class="libraryfile">libiberty.a</filename> provided by
47 Binutils will be used instead:</para>
48
49<screen><userinput remap="pre">sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
50
51 <para>As in <xref linkend="ch-tools-gcc-pass2"/>, apply the following
52 <command>sed</command> to force the build to use the
53 <option>-fomit-frame-pointer</option> compiler flag in order to ensure
54 consistent compiler builds:</para>
55
56<screen><userinput remap="pre">case `uname -m` in
57 i?86) sed -i 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' \
58 gcc/Makefile.in ;;
59esac</userinput></screen>
60
61 <para>The <command>fixincludes</command> script is known to occasionally
62 erroneously attempt to &quot;fix&quot; the system headers installed so far.
63 As the headers up to this point are known to not require fixing,
64 issue the following command to prevent the <command>fixincludes</command>
65 script from running:</para>
66
67<screen><userinput remap="pre">sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in</userinput></screen>
68
69 <para>Finally, apply a patch that corrects the test code for locale changes
70 that were made in glibc-2.14 and later.</para>
71
72<screen><userinput remap="pre">patch -Np1 -i ../gcc-4.6.1-locale-1.patch</userinput></screen>
73
74 <para>The GCC documentation recommends building GCC outside of the source
75 directory in a dedicated build directory:</para>
76
77<screen><userinput remap="pre">mkdir -v ../gcc-build
78cd ../gcc-build</userinput></screen>
79
80 <para>Prepare GCC for compilation:</para>
81
82<screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/usr \
83 --libexecdir=/usr/lib --enable-shared \
84 --enable-threads=posix --enable-__cxa_atexit \
85 --enable-clocale=gnu --enable-languages=c,c++ \
86 --disable-multilib --disable-bootstrap --with-system-zlib</userinput></screen>
87
88 <para>Note that for other languages, there are some prerequisites that
89 are not available. See the BLFS Book for instructions on how to
90 build all the GCC supported languages.</para>
91
92 <variablelist>
93 <title>The meaning of the new configure option:</title>
94
95 <varlistentry>
96 <term><parameter>--with-system-zlib</parameter></term>
97 <listitem>
98 <para>This switch tells GCC to link to the system installed copy of
99 the Zlib library, rather than its own internal copy.</para>
100 </listitem>
101 </varlistentry>
102 </variablelist>
103
104 <para>Compile the package:</para>
105
106<screen><userinput remap="make">make</userinput></screen>
107
108 <important>
109 <para>In this section, the test suite for GCC is considered
110 critical. Do not skip it under any circumstance.</para>
111 </important>
112
113 <para>One set of tests in the GCC test suite is known to exhaust the stack,
114 so increase the stack size prior to running the tests:</para>
115
116<screen><userinput remap="test">ulimit -s 16384</userinput></screen>
117
118 <para>Test the results, but do not stop at errors:</para>
119
120<screen><userinput remap="test">make -k check</userinput></screen>
121
122 <para>To receive a summary of the test suite results, run:</para>
123
124<screen><userinput remap="test">../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
125
126 <para>For only the summaries, pipe the output through
127 <userinput>grep -A7 Summ</userinput>.</para>
128
129 <para>Results can be compared with those located at <ulink
130 url="&test-results;"/> and <ulink url="http://gcc.gnu.org/ml/gcc-testresults/"/>.</para>
131
132 <para>A few unexpected failures cannot always be avoided. The GCC developers
133 are usually aware of these issues, but have not resolved them yet. In
134 particular, the <filename class="libraryfile">libmudflap</filename> tests
135 are known be particularly problematic as a result of a bug in GCC
136 (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
137 Unless the test results are vastly different from those at the above URL,
138 it is safe to continue.</para>
139
140 <para>Install the package:</para>
141
142<screen><userinput remap="install">make install</userinput></screen>
143
144 <para>Some packages expect the C preprocessor to be installed in the
145 <filename class="directory">/lib</filename> directory.
146 To support those packages, create this symlink:</para>
147
148<screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
149
150 <para>Many packages use the name <command>cc</command> to call the C
151 compiler. To satisfy those packages, create a symlink:</para>
152
153<screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen>
154
155 <para>Now that our final toolchain is in place, it is important to again ensure
156 that compiling and linking will work as expected. We do this by performing
157 the same sanity checks as we did earlier in the chapter:</para>
158
159 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
160 href="readjusting.xml"
161 xpointer="xpointer(//*[@os='a'])"/>
162
163 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
164 href="readjusting.xml"
165 xpointer="xpointer(//*[@os='b'])"/>
166
167 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
168 href="readjusting.xml"
169 xpointer="xpointer(//*[@os='c'])"/>
170
171 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
172 href="readjusting.xml"
173 xpointer="xpointer(//*[@os='d'])"/>
174
175 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
176 href="readjusting.xml"
177 xpointer="xpointer(//*[@os='e'])"/>
178
179 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
180 href="readjusting.xml"
181 xpointer="xpointer(//*[@os='f'])"/>
182
183<screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
184/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
185/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
186
187 <para>Depending on your machine architecture, the above may differ slightly,
188 the difference usually being the name of the directory
189 after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
190 a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
191 towards the end of the string. The important thing to
192 look for here is that <command>gcc</command> has found all three
193 <filename>crt*.o</filename> files under the
194 <filename class="directory">/usr/lib</filename> directory.</para>
195
196 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
197 href="readjusting.xml"
198 xpointer="xpointer(//*[@os='g'])"/>
199
200<screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen>
201
202 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
203 href="readjusting.xml"
204 xpointer="xpointer(//*[@os='h'])"/>
205
206<screen><computeroutput>#include &lt;...&gt; search starts here:
207 /usr/local/include
208 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include
209 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include-fixed
210 /usr/include</computeroutput></screen>
211
212 <para>Again, note that the directory named after your target triplet may be
213 different than the above, depending on your architecture.</para>
214
215 <note><para>As of version 4.3.0, GCC now unconditionally installs the
216 <filename>limits.h</filename> file into the private
217 <filename class="directory">include-fixed</filename> directory, and that
218 directory is required to be in place.</para></note>
219
220 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
221 href="readjusting.xml"
222 xpointer="xpointer(//*[@os='i'])"/>
223
224 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
225 href="readjusting.xml"
226 xpointer="xpointer(//*[@os='j'])"/>
227
228 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
229 href="readjusting.xml"
230 xpointer="xpointer(//*[@os='k'])"/>
231
232<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
233SEARCH_DIR("/usr/local/lib")
234SEARCH_DIR("/lib")
235SEARCH_DIR("/usr/lib");</computeroutput></screen>
236
237 <para>A 64-bit system may see a few more directories. For example, here
238 is the output from an x86_64 machine:</para>
239
240<screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
241SEARCH_DIR("/usr/local/lib64")
242SEARCH_DIR("/lib64")
243SEARCH_DIR("/usr/lib64")
244SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
245SEARCH_DIR("/usr/local/lib")
246SEARCH_DIR("/lib")
247SEARCH_DIR("/usr/lib");</computeroutput></screen>
248
249 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
250 href="readjusting.xml"
251 xpointer="xpointer(//*[@os='l'])"/>
252
253 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
254 href="readjusting.xml"
255 xpointer="xpointer(//*[@os='m'])"/>
256
257 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
258 href="readjusting.xml"
259 xpointer="xpointer(//*[@os='n'])"/>
260
261 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
262 href="readjusting.xml"
263 xpointer="xpointer(//*[@os='o'])"/>
264
265 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
266 href="readjusting.xml"
267 xpointer="xpointer(//*[@os='p'])"/>
268
269 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
270 href="readjusting.xml"
271 xpointer="xpointer(//*[@os='q'])"/>
272
273 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
274 href="readjusting.xml"
275 xpointer="xpointer(//*[@os='r'])"/>
276
277 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
278 href="readjusting.xml"
279 xpointer="xpointer(//*[@os='s'])"/>
280
281 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
282 href="readjusting.xml"
283 xpointer="xpointer(//*[@os='t'])"/>
284
285 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
286 href="readjusting.xml"
287 xpointer="xpointer(//*[@os='u'])"/>
288
289 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
290 href="readjusting.xml"
291 xpointer="xpointer(//*[@os='v'])"/>
292
293 </sect2>
294
295 <sect2 id="contents-gcc" role="content">
296 <title>Contents of GCC</title>
297
298 <segmentedlist>
299 <segtitle>Installed programs</segtitle>
300 <segtitle>Installed libraries</segtitle>
301 <segtitle>Installed directories</segtitle>
302
303 <seglistitem>
304 <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
305 <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libgcov.a, libgomp.{a,so},
306 libmudflap.{a,so}, libmudflapth.{a,so}, libssp.{a,so},
307 libssp_nonshared.a, libstdc++.{a,so} and libsupc++.a</seg>
308 <seg>/usr/include/c++, /usr/lib/gcc, /usr/share/gcc-&gcc-version;</seg>
309 </seglistitem>
310 </segmentedlist>
311
312 <variablelist>
313 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
314 <?dbfo list-presentation="list"?>
315 <?dbhtml list-presentation="table"?>
316
317 <varlistentry id="c">
318 <term><command>c++</command></term>
319 <listitem>
320 <para>The C++ compiler</para>
321 <indexterm zone="ch-system-gcc c">
322 <primary sortas="b-c++">c++</primary>
323 </indexterm>
324 </listitem>
325 </varlistentry>
326
327 <varlistentry id="cc">
328 <term><command>cc</command></term>
329 <listitem>
330 <para>The C compiler</para>
331 <indexterm zone="ch-system-gcc cc">
332 <primary sortas="b-cc">cc</primary>
333 </indexterm>
334 </listitem>
335 </varlistentry>
336
337 <varlistentry id="cpp">
338 <term><command>cpp</command></term>
339 <listitem>
340 <para>The C preprocessor; it is used by the compiler to expand the
341 #include, #define, and similar statements in the source files</para>
342 <indexterm zone="ch-system-gcc cpp">
343 <primary sortas="b-cpp">cpp</primary>
344 </indexterm>
345 </listitem>
346 </varlistentry>
347
348 <varlistentry id="g">
349 <term><command>g++</command></term>
350 <listitem>
351 <para>The C++ compiler</para>
352 <indexterm zone="ch-system-gcc g">
353 <primary sortas="b-g++">g++</primary>
354 </indexterm>
355 </listitem>
356 </varlistentry>
357
358 <varlistentry id="gcc">
359 <term><command>gcc</command></term>
360 <listitem>
361 <para>The C compiler</para>
362 <indexterm zone="ch-system-gcc gcc">
363 <primary sortas="b-gcc">gcc</primary>
364 </indexterm>
365 </listitem>
366 </varlistentry>
367
368 <varlistentry id="gccbug">
369 <term><command>gccbug</command></term>
370 <listitem>
371 <para>A shell script used to help create useful bug reports</para>
372 <indexterm zone="ch-system-gcc gccbug">
373 <primary sortas="b-gccbug">gccbug</primary>
374 </indexterm>
375 </listitem>
376 </varlistentry>
377
378 <varlistentry id="gcov">
379 <term><command>gcov</command></term>
380 <listitem>
381 <para>A coverage testing tool; it is used to analyze programs to
382 determine where optimizations will have the most effect</para>
383 <indexterm zone="ch-system-gcc gcov">
384 <primary sortas="b-gcov">gcov</primary>
385 </indexterm>
386 </listitem>
387 </varlistentry>
388
389 <varlistentry id="libgcc">
390 <term><filename class="libraryfile">libgcc</filename></term>
391 <listitem>
392 <para>Contains run-time support for <command>gcc</command></para>
393 <indexterm zone="ch-system-gcc libgcc">
394 <primary sortas="c-libgcc*">libgcc*</primary>
395 </indexterm>
396 </listitem>
397 </varlistentry>
398
399 <varlistentry id="libgcov">
400 <term><filename class="libraryfile">libgcov</filename></term>
401 <listitem>
402 <para>This library is linked in to a program when GCC is instructed
403 to enable profiling</para>
404 <indexterm zone="ch-system-gcc libgcov">
405 <primary sortas="c-libgcov">libgcov</primary>
406 </indexterm>
407 </listitem>
408 </varlistentry>
409
410 <varlistentry id="libgomp">
411 <term><filename class="libraryfile">libgomp</filename></term>
412 <listitem>
413 <para>GNU implementation of the OpenMP API for multi-platform
414 shared-memory parallel programming in C/C++ and Fortran</para>
415 <indexterm zone="ch-system-gcc libgomp">
416 <primary sortas="c-libgomp">libgomp</primary>
417 </indexterm>
418 </listitem>
419 </varlistentry>
420
421 <varlistentry id="libmudflap">
422 <term><filename class="libraryfile">libmudflap</filename></term>
423 <listitem>
424 <para>Contains routines that support GCC's bounds checking
425 functionality</para>
426 <indexterm zone="ch-system-gcc libmudflap">
427 <primary sortas="c-libmudflap*">libmudflap*</primary>
428 </indexterm>
429 </listitem>
430 </varlistentry>
431
432 <varlistentry id="libssp">
433 <term><filename class="libraryfile">libssp</filename></term>
434 <listitem>
435 <para>Contains routines supporting GCC's stack-smashing protection
436 functionality</para>
437 <indexterm zone="ch-system-gcc libssp">
438 <primary sortas="c-libssp*">libssp*</primary>
439 </indexterm>
440 </listitem>
441 </varlistentry>
442
443 <varlistentry id="libstdc">
444 <term><filename class="libraryfile">libstdc++</filename></term>
445 <listitem>
446 <para>The standard C++ library</para>
447 <indexterm zone="ch-system-gcc libstdc">
448 <primary sortas="c-libstdc++">libstdc++</primary>
449 </indexterm>
450 </listitem>
451 </varlistentry>
452
453 <varlistentry id="libsupc">
454 <term><filename class="libraryfile">libsupc++</filename></term>
455 <listitem>
456 <para>Provides supporting routines for the C++ programming
457 language</para>
458 <indexterm zone="ch-system-gcc libsupc">
459 <primary sortas="c-libsupc++">libsupc++</primary>
460 </indexterm>
461 </listitem>
462 </varlistentry>
463
464 </variablelist>
465
466 </sect2>
467
468</sect1>
Note: See TracBrowser for help on using the repository browser.