source: general/prog/gcc.xml@ 4222370

12.2
Last change on this file since 4222370 was 595b2cc, checked in by Douglas R. Reno <renodr@…>, 3 weeks ago

gcc: remove the 'ulimit -s 32768' command to sync with LFS

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