source: chapter06/gcc.xml@ bdb539b

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 12.2 12.2-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/loongarch-12.2 xry111/mips64el xry111/multilib xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since bdb539b was ed92274, checked in by Matthew Burgess <matthew@…>, 15 years ago

Fix GCC's libiberty testsuite due to a conflict with Glibc's getline function.

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

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