source: general/prog/gcc.xml@ 8ccee9ac

12.0 12.1 kea ken/TL2024 ken/tuningfonts lazarus lxqt plabs/newcss python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 8ccee9ac was dc1a45e, checked in by Bruce Dubbs <bdubbs@…>, 17 months ago

Lots of tags

  • Property mode set to 100644
File size: 16.3 KB
RevLine 
[52d29f7]1<?xml version="1.0" encoding="ISO-8859-1"?>
[6732c094]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[52d29f7]4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6
[8dfc5c3]7 <!ENTITY gcc-download-http "&gnu-http;/gcc/gcc-&gcc-version;/gcc-&gcc-version;.tar.xz">
8 <!ENTITY gcc-download-ftp "&gnu-ftp;/gcc/gcc-&gcc-version;/gcc-&gcc-version;.tar.xz">
[b5844a0]9 <!-- Update this also on the grub-uefi page -->
[0f21ed27]10 <!ENTITY gcc-md5sum "73bafd0af874439dcdb9fc063b6fb069">
11 <!ENTITY gcc-size "81 MB">
[7354b9a]12 <!ENTITY gcc-buildsize "10.5 GB (2.4 GB installed with all listed languages; add 1.3 GB for tests)">
[0f21ed27]13 <!ENTITY gcc-time "32 SBU (add 66 SBU for tests; both with parallelism=4)">
[52d29f7]14]>
15
[58bd309a]16<sect1 id="gcc" xreflabel="GCC-&gcc-version;">
[70e3220]17 <?dbhtml filename="gcc.html" ?>
18
19
20 <title>GCC-&gcc-version;</title>
21
22 <indexterm zone="gcc">
[ae0673a]23 <primary sortas="a-gcc-5-0">GCC-&gcc-version;</primary>
[70e3220]24 </indexterm>
25
26 <sect2 role="package">
27 <title>Introduction to GCC</title>
28
[ae0673a]29 <para>
30 The <application>GCC</application> package contains the GNU Compiler
31 Collection. This page describes the installation of compilers for the
[7354b9a]32 following languages: C, C++, Fortran, Objective C, Objective C++, and Go.
33 Since C and C++ are installed in LFS, this page is either for upgrading
34 C and C++, or for installing additional compilers.
[ae0673a]35 </para>
[5512e64]36
[7354b9a]37 <note>
38 <para>
39 Additional languages, among which D and ADA, are available in the
40 collection. D and ADA have a binary bootstrap requirement for the first
41 installation, so their installation is not described here. To install
42 them, you can proceed along the same lines as below after installing
43 the corresponding compiler from a binary package, adding
44 <option>ada</option> or <option>d</option> to the
45 <parameter>--enable-languages</parameter> line.
46 </para>
47 </note>
48
[dc1a45e]49 &lfs113_checked;
[625d5fe5]50
[636acbb1]51 <caution>
[ae0673a]52 <para>
53 If you are upgrading <application>GCC</application> from any other
54 version prior to &gcc-version;, then you must be careful compiling 3rd
55 party kernel modules. You should ensure that the kernel and all its
56 native modules are also compiled using the same version of
57 <application>GCC</application> that you use to build the 3rd party module.
58 This issue does not affect native kernel (and kernel modules) updates,
59 as the instructions below are a complete reinstallation of
60 <application>GCC</application>. If you have existing 3rd party modules
61 installed, ensure they are recompiled using the updated version of
62 <application>GCC</application>. As always, never update the kernel
63 headers from the ones used when <application>Glibc</application> was
64 compiled during LFS.
65 </para>
66
67 <para>
[e9cab664]68 Some system headers need to be fixed to be used with GCC. This is done
69 during the installation of GCC, and the <quote>fixed</quote> headers
70 are installed in <filename class="directory">
71 /usr/lib/gcc/&lt;machine triplet&gt;/&lt;GCC version&gt;/include-fixed
72 </filename>. This is harmless if GCC is built during the LFS stage. But
73 if you reinstall GCC in BLFS, some of the BLFS packages may be
74 <quote>fixed</quote>. If one of those packages is reinstalled
75 afterwards, the <quote>fixed</quote> headers are not updated, which may
76 lead to version mismatches. In case that happens, the
77 <quote>fixed</quote> headers must be updated by running (as
78 <systemitem class="username">root</systemitem>):
79 <command>
[da8e9f9]80 /usr/libexec/gcc/x86_64-pc-linux-gnu/&gcc-version;/install-tools/mkheaders
[b9c353b]81 </command>. The machine triplet may be different on a 32-bit system.
[ae0673a]82 </para>
[636acbb1]83 </caution>
84
[70e3220]85 <bridgehead renderas="sect3">Package Information</bridgehead>
86 <itemizedlist spacing="compact">
87 <listitem>
[ae0673a]88 <para>
89 Download (HTTP): <ulink url="&gcc-download-http;"/>
90 </para>
[70e3220]91 </listitem>
92 <listitem>
[ae0673a]93 <para>
94 Download (FTP): <ulink url="&gcc-download-ftp;"/>
95 </para>
[70e3220]96 </listitem>
97 <listitem>
[ae0673a]98 <para>
99 Download MD5 sum: &gcc-md5sum;
100 </para>
[70e3220]101 </listitem>
102 <listitem>
[ae0673a]103 <para>
104 Download size: &gcc-size;
105 </para>
[70e3220]106 </listitem>
107 <listitem>
[ae0673a]108 <para>
109 Estimated disk space required: &gcc-buildsize;
110 </para>
[70e3220]111 </listitem>
112 <listitem>
[ae0673a]113 <para>
114 Estimated build time: &gcc-time;
115 </para>
[70e3220]116 </listitem>
117 </itemizedlist>
[0f21ed27]118<!--
[12ab2eb]119 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
120 <itemizedlist spacing="compact">
121 <listitem>
122 <para>
123 Required patch for building against glibc-2.36:
124 <ulink url="&patch-root;/gcc-&gcc-version;-glibc_2.36-1.patch"/>
125 </para>
126 </listitem>
127 </itemizedlist>
[0f21ed27]128-->
[70e3220]129 <bridgehead renderas="sect3">GCC Dependencies</bridgehead>
[7354b9a]130
[a7e88c5c]131 <bridgehead renderas="sect4">Optional</bridgehead>
132 <para role="optional">
[1a8a995]133 <xref linkend="gdb"/>,
134 <xref linkend="valgrind"/> (for tests), and
135 <ulink url="https://repo.or.cz/isl.git">ISL</ulink> (to enable graphite optimization)
[a7e88c5c]136 </para>
[8558044]137
[ae0673a]138 <para condition="html" role="usernotes">
139 User Notes: <ulink url="&blfs-wiki;/gcc"/>
140 </para>
[1039de3]141
[70e3220]142 </sect2>
[034eda7]143
[70e3220]144 <sect2 role="installation">
145 <title>Installation of GCC</title>
146
147 <important>
[ae0673a]148 <para>
149 Even if you specify only languages other than C and C++ to the
150 <command>./configure</command> command below, the
151 installation process will overwrite your existing
152 <application>GCC</application> C and C++ compilers and libraries.
[3026cde]153 Running the full suite of tests is recommended.
[ae0673a]154 </para>
155
156 <para>
157 Do not continue with the <command>make install</command> command
158 until you are confident the build was successful. You can compare your
159 test results with those found at <ulink
[579bdb04]160 url="https://gcc.gnu.org/ml/gcc-testresults/"/>. You may also want to
[ae0673a]161 refer to the information found in the <application>GCC</application>
[f0dc9578]162 section of Chapter 8 in the LFS book (<ulink
163 url="&lfs-root;/chapter08/gcc.html"/>).
[ae0673a]164 </para>
[70e3220]165 </important>
166
[ae0673a]167 <para>
168 The instructions below are intentionally performing a
169 <quote>bootstrap</quote> process. Bootstrapping is needed for robustness
170 and is highly recommended when upgrading the compilers version. To disable
[0c953f12]171 bootstrap anyway, add <parameter>--disable-bootstrap</parameter> to the
[ae0673a]172 <command>./configure</command> options below.
173 </para>
[0f21ed27]174<!--
[12ab2eb]175 <para>
176 First fix a problem with glibc-2.36:
177 </para>
178
179<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-glibc_2.36-1.patch</userinput></screen>
[0f21ed27]180-->
[ae0673a]181 <para>
[e6d0be6]182 Install <application>GCC</application> by running the following commands:
[ae0673a]183 </para>
184
[e6d0be6]185<screen><userinput>case $(uname -m) in
[92245989]186 x86_64)
[df0e196]187 sed -i.orig '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
[92245989]188 ;;
189esac
190
[adbf61f]191mkdir build &amp;&amp;
192cd build &amp;&amp;
193
194../configure \
195 --prefix=/usr \
196 --disable-multilib \
197 --with-system-zlib \
[b89180f]198 --enable-default-pie \
199 --enable-default-ssp \
[7354b9a]200 --enable-languages=c,c++,fortran,go,objc,obj-c++ &amp;&amp;
[7cadfea]201make</userinput></screen>
[5512e64]202
[ae0673a]203 <para>
204 If you have installed additional packages such as
205 <application>Valgrind</application> and <application>GDB</application>,
[48771ae]206 the <application>GCC</application> part of the test suite will run more
[ae0673a]207 tests than in LFS. Some of those will report FAIL and others XPASS
[b89180f]208 (pass when expected to FAIL). As of gcc-12.2.0, about 60 FAIL occur
[3b187ea]209 in the <quote>guality</quote> suite, as well as miscellaneous failures
[b89180f]210 throughout the rest of the test suite, fifteen of which are already
211 present in the GCC tests of LFS. If all the compilers above are
212 built, there will be around 80 unexpected failures out of over
213 482,000 tests. To run the tests, issue:
[ae0673a]214 </para>
[d3757f1c]215
[7cadfea]216<screen><userinput>ulimit -s 32768 &amp;&amp;
[b10cfc81]217make -k check</userinput></screen>
218<!-- The command above may error out, so using && may prevent the summary
219to be run. -->
220
[ae0673a]221 <para>
222 The tests are very long, and the results may be hard to find in the
223 logs, specially if you use parallel jobs with make. You can get a summary
224 of the tests with:
225 </para>
[5512e64]226
[0e64979]227<screen><userinput>../contrib/test_summary</userinput></screen>
[8c9ec303]228
[ae0673a]229 <para>
230 Now, as the <systemitem class="username">root</systemitem> user:
231 </para>
[8c9ec303]232
[70e3220]233<screen role="root"><userinput>make install &amp;&amp;
[5512e64]234
[7cadfea]235mkdir -pv /usr/share/gdb/auto-load/usr/lib &amp;&amp;
236mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &amp;&amp;
237
[38485e5c]238chown -v -R root:root \
[7354b9a]239 /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed}</userinput></screen>
[f182eed]240
[ae0673a]241 <para>
242 Some packages expect to find the C preprocessor in
243 <filename class="directory">/lib</filename> or may refer to the C compiler
244 under the name <command>cc</command>. The following symbolic links are not
245 needed if you have followed the LFS instructions, since they
246 have been already created. If you do not have them on your system, issue
247 as the <systemitem class="username">root</systemitem> user:
248 </para>
[70e3220]249
[ae0673a]250<screen role="root"><userinput>ln -v -sf ../usr/bin/cpp /lib &amp;&amp;
251ln -v -sf gcc /usr/bin/cc &amp;&amp;
252install -v -dm755 /usr/lib/bfd-plugins &amp;&amp;
253ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/&gcc-version;/liblto_plugin.so /usr/lib/bfd-plugins/</userinput></screen>
[034eda7]254
[70e3220]255 </sect2>
256
257 <sect2 role="commands">
258 <title>Command Explanations</title>
[8ddc247]259
[2d488eb]260 <para>
[0e64979]261 <command>mkdir build; cd build</command>: The
[2d488eb]262 <application>GCC</application> documentation recommends
263 building the package in a dedicated build directory.
264 </para>
[70e3220]265
[2d488eb]266 <para>
267 <parameter>--disable-multilib</parameter>: This parameter ensures
268 that files are created for the specific architecture of your computer.
269 </para>
[7cadfea]270
[2d488eb]271 <para>
[fa200b8]272 <parameter>--with-system-zlib</parameter>: Uses the system
[2d488eb]273 <application>zlib</application> instead of the bundled one.
274 <application>zlib</application> is used for compressing
[b89180f]275 and decompressing <application>GCC</application>'s intermediate
[2d488eb]276 language in LTO (Link Time Optimization) object files.
277 </para>
[034eda7]278
[b89180f]279 <para>
280 <parameter>--enable-default-pie</parameter>: Makes the
281 <option>-fpie</option> option the default when compiling programs.
282 Together with the <xref linkend="gASLR"/> feature enabled in the kernel,
283 this defeats some kind of attacks based on known memory layouts.
284 </para>
285
286 <para>
287 <parameter>--enable-default-ssp</parameter>: Makes the
288 <option>-fstack-protector-strong</option> option the default when
289 compiling programs. <xref linkend="gSSP"/> is a technique preventing
290 alteration of the program flow by corrupting the parameter stack.
291 </para>
292
[800c9c3]293 <para>
[7354b9a]294 <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++</parameter>:
[2d488eb]295 This command identifies which languages to build. You may modify
[7354b9a]296 this command to remove undesired languages. Other languages can be
297 added, including ADA, D, BRIG (add
[3d9141c]298 <parameter>brig</parameter> to the list of enabled languages), a binary
[9562b375]299 format for HSAIL (Heterogeneous System Architecture Intermediate
[3d9141c]300 Language), and JIT (add <parameter>jit</parameter> to the list of enabled
[0f18e26]301 languages), a library which can be linked into interpreters that want to
302 generate machine code <quote>on the fly</quote> at run-time. They have not
303 been tested by the BLFS developers.
[2d488eb]304 </para>
[ae0673a]305
[2d488eb]306 <para>
307 <command>ulimit -s 32768</command>: This command prevents several
308 tests from running out of stack space.
309 </para>
310
311 <para>
312 <command>make -k check</command>: This command runs the test suite
313 without stopping if any errors are encountered.
314 </para>
315
316 <para>
[9562b375]317 <command>../contrib/test_summary</command>: This command will produce
318 a summary of the test suite results. You can append <command>| grep
319 -A7 Summ</command> to the command to produce an even more condensed
320 version of the summary. You may also wish to redirect the output
[2d488eb]321 to a file for review and comparison later on.
322 </para>
323
324 <para>
325 <command>mv -v /usr/lib/*gdb.py ...</command>: The installation
326 stage puts some files used by <application>gdb</application> under the
327 <filename class="directory">/usr/lib</filename> directory. This generates
328 spurious error messages when performing <command>ldconfig</command>. This
329 command moves the files to another location.
330 </para>
331
332 <para>
333 <command>chown -v -R root:root /usr/lib/gcc/*linux-gnu/...</command>:
334 If the package is built by a user other than root, the ownership of the
335 installed <filename class="directory">include</filename> directory (and
336 its content) will be incorrect. This command changes the ownership to the
337 <systemitem class="username">root</systemitem> user and group.
338 </para>
[034eda7]339
[70e3220]340 </sect2>
341
342 <sect2 role="content">
343 <title>Contents</title>
344
[ae0673a]345 <para>
346 Some program and library names and descriptions are not listed here,
347 but can be found at
[9771f84]348 <ulink url="&lfs-root;/chapter08/gcc.html#contents-gcc">LFS section
349 for GCC</ulink> as they were
[ae0673a]350 initially installed during the building of LFS.
351 </para>
[2d488eb]352
[70e3220]353 <segmentedlist>
354 <segtitle>Installed Programs</segtitle>
355 <segtitle>Installed Libraries</segtitle>
356 <segtitle>Installed Directories</segtitle>
357
358 <seglistitem>
[7cadfea]359 <seg>
[7354b9a]360 gccgo, gfortran, go, and gofmt, hard-linked to architecture
[adbf61f]361 specific names
[7cadfea]362 </seg>
363 <seg>
[d7d743f0]364 libgfortran.{so,a},
[9562b375]365 libgo.{so,a}, libgobegin.a, libgolibbegin.a,
[d7d743f0]366 libobjc.{so,a}, and numerous other run-time libraries and executables
[7cadfea]367 </seg>
368 <seg>
[d5e9aa8]369 /usr/lib/go
[7cadfea]370 </seg>
[70e3220]371 </seglistitem>
372 </segmentedlist>
373
374 <variablelist>
375 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
376 <?dbfo list-presentation="list"?>
377 <?dbhtml list-presentation="table"?>
378
[034eda7]379 <varlistentry id="gccgo">
380 <term><command>gccgo</command></term>
381 <listitem>
[ae0673a]382 <para>
[5b55f9b3]383 is a GCC-based compiler for the <application>Go</application>
[4c24eb0a]384 language
[ae0673a]385 </para>
[034eda7]386 <indexterm zone="gcc gccgo">
387 <primary sortas="b-gccgo">gccgo</primary>
[70e3220]388 </indexterm>
389 </listitem>
390 </varlistentry>
391
[87532434]392 <varlistentry id="go">
393 <term><command>go</command></term>
394 <listitem>
395 <para>
[4c24eb0a]396 is a tool for managing <application>Go</application> source code
[87532434]397 </para>
398 <indexterm zone="gcc go">
399 <primary sortas="b-go">go</primary>
400 </indexterm>
401 </listitem>
402 </varlistentry>
403
404 <varlistentry id="gofmt">
405 <term><command>gofmt</command></term>
406 <listitem>
407 <para>
[4c24eb0a]408 is a tool for formatting <application>Go</application> source code
[87532434]409 </para>
410 <indexterm zone="gcc gofmt">
411 <primary sortas="b-gofmt">gofmt</primary>
412 </indexterm>
413 </listitem>
414 </varlistentry>
[7354b9a]415 <!--
[adbf61f]416 <varlistentry id="gdc">
417 <term><command>gdc</command></term>
418 <listitem>
419 <para>
420 is a GCC-based compiler for the <application>D</application>
[4c24eb0a]421 language
[adbf61f]422 </para>
423 <indexterm zone="gcc gdc">
424 <primary sortas="b-gdc">gdc</primary>
425 </indexterm>
426 </listitem>
427 </varlistentry>
[7354b9a]428 -->
[800c9c3]429 <varlistentry id="gfortran">
430 <term><command>gfortran</command></term>
431 <listitem>
[ae0673a]432 <para>
433 is a GCC-based compiler for the <application>Fortran</application>
[4c24eb0a]434 language
[ae0673a]435 </para>
[800c9c3]436 <indexterm zone="gcc gfortran">
437 <primary sortas="b-gfortran">gfortran</primary>
438 </indexterm>
439 </listitem>
440 </varlistentry>
441
[70e3220]442 </variablelist>
443
444 </sect2>
[1a686a1]445
446</sect1>
Note: See TracBrowser for help on using the repository browser.