source: general/prog/gcc.xml@ 907a269

12.0 12.1 kea ken/TL2024 ken/tuningfonts lazarus lxqt plabs/newcss python3.11 rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 907a269 was 42ddc30, checked in by Xi Ruoyao <xry111@…>, 12 months ago

treewide: Replace "User Notes" with "Editor Notes"

  • Property mode set to 100644
File size: 17.7 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 <!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">
9 <!-- Update this also on the grub-uefi page -->
10 <!ENTITY gcc-md5sum "43e4de77f2218c83ca675257ea1af9ef">
11 <!ENTITY gcc-size "83 MB">
12 <!ENTITY gcc-buildsize "9.6 GB (2.4 GB installed with all listed languages; add 1.4 GB for tests)">
13 <!ENTITY gcc-time "32 SBU (add 55 SBU for tests; both with parallelism=4)">
14]>
15
16<sect1 id="gcc" xreflabel="GCC-&gcc-version;">
17 <?dbhtml filename="gcc.html" ?>
18
19
20 <title>GCC-&gcc-version;</title>
21
22 <indexterm zone="gcc">
23 <primary sortas="a-gcc-5-0">GCC-&gcc-version;</primary>
24 </indexterm>
25
26 <sect2 role="package">
27 <title>Introduction to GCC</title>
28
29 <para>
30 The <application>GCC</application> package contains the GNU Compiler
31 Collection. This page describes the installation of compilers for the
32 following languages: C, C++, Fortran, Objective C, Objective C++, Go, and Modula2.
33 Since C and C++ are installed in LFS, this page is either for upgrading
34 C and C++, or for installing additional compilers.
35 </para>
36
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
49 &lfs113_checked;
50
51 <caution>
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>
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>
80 /usr/libexec/gcc/x86_64-pc-linux-gnu/&gcc-version;/install-tools/mkheaders
81 </command>. The machine triplet may be different on a 32-bit system.
82 </para>
83-->
84 </caution>
85
86 <bridgehead renderas="sect3">Package Information</bridgehead>
87 <itemizedlist spacing="compact">
88 <listitem>
89 <para>
90 Download (HTTP): <ulink url="&gcc-download-http;"/>
91 </para>
92 </listitem>
93 <listitem>
94 <para>
95 Download (FTP): <ulink url="&gcc-download-ftp;"/>
96 </para>
97 </listitem>
98 <listitem>
99 <para>
100 Download MD5 sum: &gcc-md5sum;
101 </para>
102 </listitem>
103 <listitem>
104 <para>
105 Download size: &gcc-size;
106 </para>
107 </listitem>
108 <listitem>
109 <para>
110 Estimated disk space required: &gcc-buildsize;
111 </para>
112 </listitem>
113 <listitem>
114 <para>
115 Estimated build time: &gcc-time;
116 </para>
117 </listitem>
118 </itemizedlist>
119<!--
120 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
121 <itemizedlist spacing="compact">
122 <listitem>
123 <para>
124 Optional patch when adding Go to the desired language list:
125 <ulink url="&patch-root;/gcc-&gcc-version;-fix_go_version-1.patch"/>
126 </para>
127 </listitem>
128 </itemizedlist>
129-->
130 <bridgehead renderas="sect3">GCC Dependencies</bridgehead>
131
132 <bridgehead renderas="sect4">Optional</bridgehead>
133 <para role="optional">
134 <xref linkend="gdb"/>,
135 <xref linkend="valgrind"/> (for tests), and
136 <ulink url="https://repo.or.cz/isl.git">ISL</ulink> (to enable graphite optimization)
137 </para>
138
139 <para condition="html" role="usernotes">
140 Editor Notes: <ulink url="&blfs-wiki;/gcc"/>
141 </para>
142
143 </sect2>
144
145 <sect2 role="installation">
146 <title>Installation of GCC</title>
147
148 <important>
149 <para>
150 Even if you specify only languages other than C and C++ to the
151 <command>./configure</command> command below, the
152 installation process will overwrite your existing
153 <application>GCC</application> C and C++ compilers and libraries.
154 Running the full suite of tests is recommended.
155 </para>
156
157 <para>
158 Do not continue with the <command>make install</command> command
159 until you are confident the build was successful. You can compare your
160 test results with those found at <ulink
161 url="https://gcc.gnu.org/ml/gcc-testresults/"/>. You may also want to
162 refer to the information found in the <application>GCC</application>
163 section of Chapter 8 in the LFS book (<ulink
164 url="&lfs-root;/chapter08/gcc.html"/>).
165 </para>
166 </important>
167
168 <para>
169 The instructions below are intentionally performing a
170 <quote>bootstrap</quote> process. Bootstrapping is needed for robustness
171 and is highly recommended when upgrading the compilers version. To disable
172 bootstrap anyway, add <parameter>--disable-bootstrap</parameter> to the
173 <command>./configure</command> options below.
174 </para>
175<!--
176 <para>
177 Some packages checks on the phrase <literal>gccgo</literal> in the output
178 of <command>go version</command> to see which kind of Go compiler is
179 installed (gcc-go or golang). The absence of <literal>gccgo</literal> in
180 that string makes them to assume the compiler is the golang which is wrong.
181 If Go isn't in the list of desired languages, this patch can be skipped
182 while it does not harm if applied anyway. Fix the Go part of gcc to show
183 a valid version string when calling <command>go version</command> by
184 applying a patch:
185 </para>
186
187<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-fix_go_version-1.patch</userinput></screen>
188-->
189 <para>
190 Install <application>GCC</application> by running the following commands:
191 </para>
192
193<screen><userinput>case $(uname -m) in
194 x86_64)
195 sed -i.orig '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
196 ;;
197esac
198
199mkdir build &amp;&amp;
200cd build &amp;&amp;
201
202../configure \
203 --prefix=/usr \
204 --disable-multilib \
205 --with-system-zlib \
206 --enable-default-pie \
207 --enable-default-ssp \
208 --disable-fixincludes \
209 --enable-languages=c,c++,fortran,go,objc,obj-c++,m2 &amp;&amp;
210make</userinput></screen>
211
212 <para>
213 If you have installed additional packages such as
214 <application>valgrind</application> and <application>gdb</application>,
215 the <application>gcc</application> part of the test suite will run more
216 tests than in LFS. Some of those will report FAIL and others XPASS
217 (pass when expected to FAIL). As of gcc-13.1.0, about 60 FAIL occur
218 in the <quote>guality</quote> suite, as well as miscellaneous failures
219 throughout the rest of the test suite.
220 If all the compilers above are built, there will be a little over 80
221 unexpected failures out of over 478,000 tests. To run the tests, issue:
222 </para>
223
224<screen><userinput>ulimit -s 32768 &amp;&amp;
225make -k check</userinput></screen>
226<!-- The command above may error out, so using && may prevent the summary
227to be run. -->
228
229 <para>
230 The tests are very long, and the results may be hard to find in the
231 logs, specially if you use parallel jobs with make. You can get a summary
232 of the tests with:
233 </para>
234
235<screen><userinput>../contrib/test_summary</userinput></screen>
236
237 <para>
238 Now, as the <systemitem class="username">root</systemitem> user:
239 </para>
240
241<screen role="root"><userinput>make install &amp;&amp;
242
243mkdir -pv /usr/share/gdb/auto-load/usr/lib &amp;&amp;
244mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &amp;&amp;
245
246chown -v -R root:root \
247 /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed}</userinput></screen>
248
249 <para>
250 Some packages expect to find the C preprocessor in
251 <filename class="directory">/lib</filename> or may refer to the C compiler
252 under the name <command>cc</command>. The following symbolic links are not
253 needed if you have followed the LFS instructions, since they
254 have been already created. If you do not have them on your system, issue
255 as the <systemitem class="username">root</systemitem> user:
256 </para>
257
258<screen role="root"><userinput>ln -v -sf ../usr/bin/cpp /lib &amp;&amp;
259ln -v -sf gcc /usr/bin/cc &amp;&amp;
260install -v -dm755 /usr/lib/bfd-plugins &amp;&amp;
261ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/&gcc-version;/liblto_plugin.so /usr/lib/bfd-plugins/</userinput></screen>
262
263 </sect2>
264
265 <sect2 role="commands">
266 <title>Command Explanations</title>
267
268 <para>
269 <command>mkdir build; cd build</command>: The
270 <application>GCC</application> documentation recommends
271 building the package in a dedicated build directory.
272 </para>
273
274 <para>
275 <parameter>--disable-multilib</parameter>: This parameter ensures
276 that files are created for the specific architecture of your computer.
277 </para>
278
279 <para>
280 <parameter>--with-system-zlib</parameter>: Uses the system
281 <application>zlib</application> instead of the bundled one.
282 <application>zlib</application> is used for compressing
283 and decompressing <application>GCC</application>'s intermediate
284 language in LTO (Link Time Optimization) object files.
285 </para>
286
287 <para>
288 <parameter>--enable-default-pie</parameter>: Makes the
289 <option>-fpie</option> option the default when compiling programs.
290 Together with the <xref linkend="gASLR"/> feature enabled in the kernel,
291 this defeats some kind of attacks based on known memory layouts.
292 </para>
293
294 <para>
295 <parameter>--enable-default-ssp</parameter>: Makes the
296 <option>-fstack-protector-strong</option> option the default when
297 compiling programs. <xref linkend="gSSP"/> is a technique preventing
298 alteration of the program flow by corrupting the parameter stack.
299 </para>
300
301 <para>
302 <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++,m2</parameter>:
303 This command identifies which languages to build. You may modify
304 this command to remove undesired languages. GCC also supports Ada
305 and D, but building GCC with Ada (or D) support needs an existing
306 Ada (or D) compiler. So they are not enabled here.
307 </para>
308
309 <para>
310 <command>ulimit -s 32768</command>: This command prevents several
311 tests from running out of stack space.
312 </para>
313
314 <para>
315 <command>make -k check</command>: This command runs the test suite
316 without stopping if any errors are encountered.
317 </para>
318
319 <para>
320 <command>../contrib/test_summary</command>: This command will produce
321 a summary of the test suite results. You can append <command>| grep
322 -A7 Summ</command> to the command to produce an even more condensed
323 version of the summary. You may also wish to redirect the output
324 to a file for review and comparison later on.
325 </para>
326
327 <para>
328 <command>mv -v /usr/lib/*gdb.py ...</command>: The installation
329 stage puts some files used by <application>gdb</application> under the
330 <filename class="directory">/usr/lib</filename> directory. This generates
331 spurious error messages when performing <command>ldconfig</command>. This
332 command moves the files to another location.
333 </para>
334
335 <para>
336 <command>chown -v -R root:root /usr/lib/gcc/*linux-gnu/...</command>:
337 If the package is built by a user other than root, the ownership of the
338 installed <filename class="directory">include</filename> directory (and
339 its content) will be incorrect. This command changes the ownership to the
340 <systemitem class="username">root</systemitem> user and group.
341 </para>
342
343 <para>
344 <option>--enable-host-shared --enable-languages=jit</option>:
345 Build <systemitem class="library">libgccjit</systemitem>, a library
346 for embedding GCC inside programs and libraries for generating machine
347 code. Despite <quote>JIT</quote> (just-in-time) in the name, the
348 library can be used for AOT (ahead-of-time) compilation as well.
349 <option>--enable-host-shared</option> is needed for building
350 <systemitem class="library">libgccjit</systemitem>, but it
351 significantly slows down GCC. So
352 <systemitem class="library">libgccjit</systemitem> should be built and
353 installed separately, not as a part of the <quote>main</quote> GCC
354 installation. If you need this library, configure GCC with
355 these two options and install the library by running
356 <!-- from Arch, not tested -->
357 <command>make -C gcc jit.install-common jit.install-info</command>
358 as the &root; user. This library is not used by any BLFS package,
359 nor tested by the BLFS developers.
360 </para>
361
362 </sect2>
363
364 <sect2 role="content">
365 <title>Contents</title>
366
367 <para>
368 Some program and library names and descriptions are not listed here,
369 but can be found at
370 <ulink url="&lfs-root;/chapter08/gcc.html#contents-gcc">LFS section
371 for GCC</ulink> as they were
372 initially installed during the building of LFS.
373 </para>
374
375 <segmentedlist>
376 <segtitle>Installed Programs</segtitle>
377 <segtitle>Installed Libraries</segtitle>
378 <segtitle>Installed Directories</segtitle>
379
380 <seglistitem>
381 <seg>
382 gccgo, gfortran, gm2, go, and gofmt, hard-linked to architecture
383 specific names
384 </seg>
385 <seg>
386 libgfortran.{so,a}, libgm2.{so,a}
387 libgo.{so,a}, libgobegin.a, libgolibbegin.a,
388 libobjc.{so,a}, and numerous other run-time libraries and executables
389 </seg>
390 <seg>
391 /usr/lib/go
392 </seg>
393 </seglistitem>
394 </segmentedlist>
395
396 <variablelist>
397 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
398 <?dbfo list-presentation="list"?>
399 <?dbhtml list-presentation="table"?>
400
401 <varlistentry id="gccgo">
402 <term><command>gccgo</command></term>
403 <listitem>
404 <para>
405 is a GCC-based compiler for the <application>Go</application>
406 language
407 </para>
408 <indexterm zone="gcc gccgo">
409 <primary sortas="b-gccgo">gccgo</primary>
410 </indexterm>
411 </listitem>
412 </varlistentry>
413
414 <varlistentry id="gm2">
415 <term><command>gm2</command></term>
416 <listitem>
417 <para>
418 is a GCC-based compiler for the
419 <application>Modula-2</application> language
420 </para>
421 <indexterm zone="gcc gm2">
422 <primary sortas="b-gm2">gm2</primary>
423 </indexterm>
424 </listitem>
425 </varlistentry>
426
427 <varlistentry id="go">
428 <term><command>go</command></term>
429 <listitem>
430 <para>
431 is a tool for managing <application>Go</application> source code
432 </para>
433 <indexterm zone="gcc go">
434 <primary sortas="b-go">go</primary>
435 </indexterm>
436 </listitem>
437 </varlistentry>
438
439 <varlistentry id="gofmt">
440 <term><command>gofmt</command></term>
441 <listitem>
442 <para>
443 is a tool for formatting <application>Go</application> source code
444 </para>
445 <indexterm zone="gcc gofmt">
446 <primary sortas="b-gofmt">gofmt</primary>
447 </indexterm>
448 </listitem>
449 </varlistentry>
450 <!--
451 <varlistentry id="gdc">
452 <term><command>gdc</command></term>
453 <listitem>
454 <para>
455 is a GCC-based compiler for the <application>D</application>
456 language
457 </para>
458 <indexterm zone="gcc gdc">
459 <primary sortas="b-gdc">gdc</primary>
460 </indexterm>
461 </listitem>
462 </varlistentry>
463 -->
464 <varlistentry id="gfortran">
465 <term><command>gfortran</command></term>
466 <listitem>
467 <para>
468 is a GCC-based compiler for the <application>Fortran</application>
469 language
470 </para>
471 <indexterm zone="gcc gfortran">
472 <primary sortas="b-gfortran">gfortran</primary>
473 </indexterm>
474 </listitem>
475 </varlistentry>
476
477 </variablelist>
478
479 </sect2>
480
481</sect1>
Note: See TracBrowser for help on using the repository browser.