source: general/prog/gcc.xml@ 32c6921

12.1 ken/TL2024 lazarus rahul/power-profiles-daemon trunk xry111/llvm18
Last change on this file since 32c6921 was ab4fdfc, checked in by Pierre Labastie <pierre.labastie@…>, 4 months ago

Change all xml decl to encoding=utf-8

  • Property mode set to 100644
File size: 15.2 KB
RevLine 
[ab4fdfc]1<?xml version="1.0" encoding="UTF-8"?>
[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">
[e1e58be]8 <!ENTITY gcc-download-ftp " ">
[b5844a0]9 <!-- Update this also on the grub-uefi page -->
[5864a166]10 <!ENTITY gcc-md5sum "e0e48554cc6e4f261d55ddee9ab69075">
11 <!ENTITY gcc-size "84 MB">
12 <!ENTITY gcc-buildsize "13 GB (2.9 GB installed with all listed languages; add 1.5 GB for tests)">
13 <!ENTITY gcc-time "13 SBU (add 29 SBU for tests; both with parallelism=8)">
[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
[64e462a7]32 following languages: C, C++, Fortran, Objective C, Objective C++, Go, and Modula2.
[7354b9a]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>
[64e462a7]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
[7354b9a]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
[282a0eb]49 &lfs120_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>
[636acbb1]66 </caution>
67
[70e3220]68 <bridgehead renderas="sect3">Package Information</bridgehead>
69 <itemizedlist spacing="compact">
70 <listitem>
[ae0673a]71 <para>
72 Download (HTTP): <ulink url="&gcc-download-http;"/>
73 </para>
[70e3220]74 </listitem>
75 <listitem>
[ae0673a]76 <para>
77 Download (FTP): <ulink url="&gcc-download-ftp;"/>
78 </para>
[70e3220]79 </listitem>
80 <listitem>
[ae0673a]81 <para>
82 Download MD5 sum: &gcc-md5sum;
83 </para>
[70e3220]84 </listitem>
85 <listitem>
[ae0673a]86 <para>
87 Download size: &gcc-size;
88 </para>
[70e3220]89 </listitem>
90 <listitem>
[ae0673a]91 <para>
92 Estimated disk space required: &gcc-buildsize;
93 </para>
[70e3220]94 </listitem>
95 <listitem>
[ae0673a]96 <para>
97 Estimated build time: &gcc-time;
98 </para>
[70e3220]99 </listitem>
100 </itemizedlist>
[64e462a7]101<!--
[12ab2eb]102 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
103 <itemizedlist spacing="compact">
104 <listitem>
105 <para>
[f0dd071]106 Optional patch when adding Go to the desired language list:
107 <ulink url="&patch-root;/gcc-&gcc-version;-fix_go_version-1.patch"/>
[12ab2eb]108 </para>
109 </listitem>
110 </itemizedlist>
[64e462a7]111-->
[70e3220]112 <bridgehead renderas="sect3">GCC Dependencies</bridgehead>
[7354b9a]113
[a7e88c5c]114 <bridgehead renderas="sect4">Optional</bridgehead>
115 <para role="optional">
[1a8a995]116 <xref linkend="gdb"/>,
117 <xref linkend="valgrind"/> (for tests), and
118 <ulink url="https://repo.or.cz/isl.git">ISL</ulink> (to enable graphite optimization)
[a7e88c5c]119 </para>
[8558044]120
[70e3220]121 </sect2>
[034eda7]122
[70e3220]123 <sect2 role="installation">
124 <title>Installation of GCC</title>
125
126 <important>
[ae0673a]127 <para>
128 Even if you specify only languages other than C and C++ to the
129 <command>./configure</command> command below, the
130 installation process will overwrite your existing
131 <application>GCC</application> C and C++ compilers and libraries.
[3026cde]132 Running the full suite of tests is recommended.
[ae0673a]133 </para>
134
135 <para>
136 Do not continue with the <command>make install</command> command
137 until you are confident the build was successful. You can compare your
138 test results with those found at <ulink
[579bdb04]139 url="https://gcc.gnu.org/ml/gcc-testresults/"/>. You may also want to
[ae0673a]140 refer to the information found in the <application>GCC</application>
[f0dc9578]141 section of Chapter 8 in the LFS book (<ulink
142 url="&lfs-root;/chapter08/gcc.html"/>).
[ae0673a]143 </para>
[70e3220]144 </important>
145
[ae0673a]146 <para>
147 The instructions below are intentionally performing a
148 <quote>bootstrap</quote> process. Bootstrapping is needed for robustness
149 and is highly recommended when upgrading the compilers version. To disable
[0c953f12]150 bootstrap anyway, add <parameter>--disable-bootstrap</parameter> to the
[ae0673a]151 <command>./configure</command> options below.
152 </para>
[12ab2eb]153
[ae0673a]154 <para>
[e6d0be6]155 Install <application>GCC</application> by running the following commands:
[ae0673a]156 </para>
157
[e6d0be6]158<screen><userinput>case $(uname -m) in
[92245989]159 x86_64)
[df0e196]160 sed -i.orig '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
[92245989]161 ;;
162esac
163
[64e462a7]164mkdir build &amp;&amp;
165cd build &amp;&amp;
166
167../configure \
168 --prefix=/usr \
169 --disable-multilib \
170 --with-system-zlib \
171 --enable-default-pie \
172 --enable-default-ssp \
173 --disable-fixincludes \
174 --enable-languages=c,c++,fortran,go,objc,obj-c++,m2 &amp;&amp;
[7cadfea]175make</userinput></screen>
[5512e64]176
[ae0673a]177 <para>
178 If you have installed additional packages such as
[64e462a7]179 <application>valgrind</application> and <application>gdb</application>,
180 the <application>gcc</application> part of the test suite will run more
[ae0673a]181 tests than in LFS. Some of those will report FAIL and others XPASS
[5864a166]182 (pass when expected to FAIL). As of gcc-13.2.0, about 65 FAIL occur
[3b187ea]183 in the <quote>guality</quote> suite, as well as miscellaneous failures
[64e462a7]184 throughout the rest of the test suite.
[e440af5]185 If all the compilers above are built, there will be a little over 80
[5864a166]186 unexpected failures out of over 546,000 tests. To run the tests, issue:
[ae0673a]187 </para>
[d3757f1c]188
[7cadfea]189<screen><userinput>ulimit -s 32768 &amp;&amp;
[b10cfc81]190make -k check</userinput></screen>
191<!-- The command above may error out, so using && may prevent the summary
192to be run. -->
193
[ae0673a]194 <para>
195 The tests are very long, and the results may be hard to find in the
196 logs, specially if you use parallel jobs with make. You can get a summary
197 of the tests with:
198 </para>
[5512e64]199
[0e64979]200<screen><userinput>../contrib/test_summary</userinput></screen>
[8c9ec303]201
[ae0673a]202 <para>
203 Now, as the <systemitem class="username">root</systemitem> user:
204 </para>
[8c9ec303]205
[70e3220]206<screen role="root"><userinput>make install &amp;&amp;
[5512e64]207
[7cadfea]208mkdir -pv /usr/share/gdb/auto-load/usr/lib &amp;&amp;
209mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &amp;&amp;
210
[38485e5c]211chown -v -R root:root \
[7354b9a]212 /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed}</userinput></screen>
[f182eed]213
[70e3220]214 </sect2>
215
216 <sect2 role="commands">
217 <title>Command Explanations</title>
[8ddc247]218
[2d488eb]219 <para>
[0e64979]220 <command>mkdir build; cd build</command>: The
[2d488eb]221 <application>GCC</application> documentation recommends
222 building the package in a dedicated build directory.
223 </para>
[70e3220]224
[2d488eb]225 <para>
226 <parameter>--disable-multilib</parameter>: This parameter ensures
227 that files are created for the specific architecture of your computer.
228 </para>
[7cadfea]229
[2d488eb]230 <para>
[fa200b8]231 <parameter>--with-system-zlib</parameter>: Uses the system
[2d488eb]232 <application>zlib</application> instead of the bundled one.
233 <application>zlib</application> is used for compressing
[b89180f]234 and decompressing <application>GCC</application>'s intermediate
[2d488eb]235 language in LTO (Link Time Optimization) object files.
236 </para>
[034eda7]237
[b89180f]238 <para>
239 <parameter>--enable-default-pie</parameter>: Makes the
240 <option>-fpie</option> option the default when compiling programs.
241 Together with the <xref linkend="gASLR"/> feature enabled in the kernel,
242 this defeats some kind of attacks based on known memory layouts.
243 </para>
244
245 <para>
246 <parameter>--enable-default-ssp</parameter>: Makes the
247 <option>-fstack-protector-strong</option> option the default when
248 compiling programs. <xref linkend="gSSP"/> is a technique preventing
249 alteration of the program flow by corrupting the parameter stack.
250 </para>
251
[800c9c3]252 <para>
[64e462a7]253 <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++,m2</parameter>:
[2d488eb]254 This command identifies which languages to build. You may modify
[0c0bf1f]255 this command to remove undesired languages. GCC also supports Ada
256 and D, but building GCC with Ada (or D) support needs an existing
257 Ada (or D) compiler. So they are not enabled here.
[2d488eb]258 </para>
[ae0673a]259
[2d488eb]260 <para>
261 <command>ulimit -s 32768</command>: This command prevents several
262 tests from running out of stack space.
263 </para>
264
265 <para>
266 <command>make -k check</command>: This command runs the test suite
267 without stopping if any errors are encountered.
268 </para>
269
270 <para>
[9562b375]271 <command>../contrib/test_summary</command>: This command will produce
272 a summary of the test suite results. You can append <command>| grep
273 -A7 Summ</command> to the command to produce an even more condensed
274 version of the summary. You may also wish to redirect the output
[2d488eb]275 to a file for review and comparison later on.
276 </para>
277
278 <para>
279 <command>mv -v /usr/lib/*gdb.py ...</command>: The installation
280 stage puts some files used by <application>gdb</application> under the
281 <filename class="directory">/usr/lib</filename> directory. This generates
282 spurious error messages when performing <command>ldconfig</command>. This
283 command moves the files to another location.
284 </para>
285
286 <para>
287 <command>chown -v -R root:root /usr/lib/gcc/*linux-gnu/...</command>:
288 If the package is built by a user other than root, the ownership of the
289 installed <filename class="directory">include</filename> directory (and
290 its content) will be incorrect. This command changes the ownership to the
291 <systemitem class="username">root</systemitem> user and group.
292 </para>
[0c0bf1f]293
294 <para>
295 <option>--enable-host-shared --enable-languages=jit</option>:
296 Build <systemitem class="library">libgccjit</systemitem>, a library
297 for embedding GCC inside programs and libraries for generating machine
298 code. Despite <quote>JIT</quote> (just-in-time) in the name, the
299 library can be used for AOT (ahead-of-time) compilation as well.
300 <option>--enable-host-shared</option> is needed for building
301 <systemitem class="library">libgccjit</systemitem>, but it
302 significantly slows down GCC. So
303 <systemitem class="library">libgccjit</systemitem> should be built and
304 installed separately, not as a part of the <quote>main</quote> GCC
305 installation. If you need this library, configure GCC with
306 these two options and install the library by running
307 <!-- from Arch, not tested -->
308 <command>make -C gcc jit.install-common jit.install-info</command>
309 as the &root; user. This library is not used by any BLFS package,
310 nor tested by the BLFS developers.
311 </para>
[034eda7]312
[70e3220]313 </sect2>
314
315 <sect2 role="content">
316 <title>Contents</title>
317
[ae0673a]318 <para>
319 Some program and library names and descriptions are not listed here,
320 but can be found at
[9771f84]321 <ulink url="&lfs-root;/chapter08/gcc.html#contents-gcc">LFS section
322 for GCC</ulink> as they were
[ae0673a]323 initially installed during the building of LFS.
324 </para>
[2d488eb]325
[70e3220]326 <segmentedlist>
327 <segtitle>Installed Programs</segtitle>
328 <segtitle>Installed Libraries</segtitle>
329 <segtitle>Installed Directories</segtitle>
330
331 <seglistitem>
[7cadfea]332 <seg>
[bcedca6]333 gccgo, gfortran, gm2, go, and gofmt, hard-linked to architecture
[adbf61f]334 specific names
[7cadfea]335 </seg>
336 <seg>
[bcedca6]337 libgfortran.{so,a}, libgm2.{so,a}
[9562b375]338 libgo.{so,a}, libgobegin.a, libgolibbegin.a,
[d7d743f0]339 libobjc.{so,a}, and numerous other run-time libraries and executables
[7cadfea]340 </seg>
341 <seg>
[d5e9aa8]342 /usr/lib/go
[7cadfea]343 </seg>
[70e3220]344 </seglistitem>
345 </segmentedlist>
346
347 <variablelist>
348 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
349 <?dbfo list-presentation="list"?>
350 <?dbhtml list-presentation="table"?>
351
[034eda7]352 <varlistentry id="gccgo">
353 <term><command>gccgo</command></term>
354 <listitem>
[ae0673a]355 <para>
[5b55f9b3]356 is a GCC-based compiler for the <application>Go</application>
[4c24eb0a]357 language
[ae0673a]358 </para>
[034eda7]359 <indexterm zone="gcc gccgo">
360 <primary sortas="b-gccgo">gccgo</primary>
[70e3220]361 </indexterm>
362 </listitem>
363 </varlistentry>
364
[bcedca6]365 <varlistentry id="gm2">
366 <term><command>gm2</command></term>
367 <listitem>
368 <para>
369 is a GCC-based compiler for the
370 <application>Modula-2</application> language
371 </para>
372 <indexterm zone="gcc gm2">
373 <primary sortas="b-gm2">gm2</primary>
374 </indexterm>
375 </listitem>
376 </varlistentry>
377
[87532434]378 <varlistentry id="go">
379 <term><command>go</command></term>
380 <listitem>
381 <para>
[4c24eb0a]382 is a tool for managing <application>Go</application> source code
[87532434]383 </para>
384 <indexterm zone="gcc go">
385 <primary sortas="b-go">go</primary>
386 </indexterm>
387 </listitem>
388 </varlistentry>
389
390 <varlistentry id="gofmt">
391 <term><command>gofmt</command></term>
392 <listitem>
393 <para>
[4c24eb0a]394 is a tool for formatting <application>Go</application> source code
[87532434]395 </para>
396 <indexterm zone="gcc gofmt">
397 <primary sortas="b-gofmt">gofmt</primary>
398 </indexterm>
399 </listitem>
400 </varlistentry>
[7354b9a]401 <!--
[adbf61f]402 <varlistentry id="gdc">
403 <term><command>gdc</command></term>
404 <listitem>
405 <para>
406 is a GCC-based compiler for the <application>D</application>
[4c24eb0a]407 language
[adbf61f]408 </para>
409 <indexterm zone="gcc gdc">
410 <primary sortas="b-gdc">gdc</primary>
411 </indexterm>
412 </listitem>
413 </varlistentry>
[7354b9a]414 -->
[800c9c3]415 <varlistentry id="gfortran">
416 <term><command>gfortran</command></term>
417 <listitem>
[ae0673a]418 <para>
419 is a GCC-based compiler for the <application>Fortran</application>
[4c24eb0a]420 language
[ae0673a]421 </para>
[800c9c3]422 <indexterm zone="gcc gfortran">
423 <primary sortas="b-gfortran">gfortran</primary>
424 </indexterm>
425 </listitem>
426 </varlistentry>
427
[70e3220]428 </variablelist>
429
430 </sect2>
[1a686a1]431
432</sect1>
Note: See TracBrowser for help on using the repository browser.