source: chapter06/gcc.xml@ ae4d45a

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 6.7 6.8 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 ae4d45a was ae4d45a, checked in by Matthew Burgess <matthew@…>, 14 years ago

Make GCC use the system-wide copy of Zlib rather than its bundled version. Fixes #2718.

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

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