source: general/prog/gcc.xml@ 33cbf497

trunk
Last change on this file since 33cbf497 was cd3f88c, checked in by Bruce Dubbs <bdubbs@…>, 7 weeks ago

Update to gcc-14.1.

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