source: general/prog/gcc.xml@ f4ebf49

lazarus trunk
Last change on this file since f4ebf49 was f4ebf49, checked in by Xi Ruoyao <xry111@…>, 4 weeks ago

gcc: Update the LTO plugin symlink in /usr/lib/bfd-plugins

Or when GCC is updated, the symlink still points to the plugin from the
old GCC and bad thing can happen.

  • Property mode set to 100644
File size: 15.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 "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)">
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 --disable-fixincludes \
172 --enable-languages=c,c++,fortran,go,objc,obj-c++,m2 &amp;&amp;
173make</userinput></screen>
174
175 <para>
176 If you have installed additional packages such as
177 <application>valgrind</application> and <application>gdb</application>,
178 the <application>gcc</application> part of the test suite will run more
179 tests than in LFS. Some of those will report FAIL and others XPASS
180 (pass when expected to FAIL). As of gcc-13.2.0, about 65 FAIL occur
181 in the <quote>guality</quote> suite, as well as miscellaneous failures
182 throughout the rest of the test suite.
183 If all the compilers above are built, there will be a little over 80
184 unexpected failures out of over 546,000 tests. To run the tests, issue:
185 </para>
186
187<screen><userinput>ulimit -s 32768 &amp;&amp;
188make -k check</userinput></screen>
189<!-- The command above may error out, so using && may prevent the summary
190to be run. -->
191
192 <para>
193 The tests are very long, and the results may be hard to find in the
194 logs, specially if you use parallel jobs with make. You can get a summary
195 of the tests with:
196 </para>
197
198<screen><userinput>../contrib/test_summary</userinput></screen>
199
200 <para>
201 Now, as the <systemitem class="username">root</systemitem> user:
202 </para>
203
204<screen role="root"><userinput>make install &amp;&amp;
205
206mkdir -pv /usr/share/gdb/auto-load/usr/lib &amp;&amp;
207mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &amp;&amp;
208
209chown -v -R root:root \
210 /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed} &amp;&amp;
211
212ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/&gcc-version;/liblto_plugin.so \
213 /usr/lib/bfd-plugins/</userinput></screen>
214
215 </sect2>
216
217 <sect2 role="commands">
218 <title>Command Explanations</title>
219
220 <para>
221 <command>mkdir build; cd build</command>: The
222 <application>GCC</application> documentation recommends
223 building the package in a dedicated build directory.
224 </para>
225
226 <para>
227 <parameter>--disable-multilib</parameter>: This parameter ensures
228 that files are created for the specific architecture of your computer.
229 </para>
230
231 <para>
232 <parameter>--with-system-zlib</parameter>: Uses the system
233 <application>zlib</application> instead of the bundled one.
234 <application>zlib</application> is used for compressing
235 and decompressing <application>GCC</application>'s intermediate
236 language in LTO (Link Time Optimization) object files.
237 </para>
238
239 <para>
240 <parameter>--enable-default-pie</parameter>: Makes the
241 <option>-fpie</option> option the default when compiling programs.
242 Together with the <xref linkend="gASLR"/> feature enabled in the kernel,
243 this defeats some kind of attacks based on known memory layouts.
244 </para>
245
246 <para>
247 <parameter>--enable-default-ssp</parameter>: Makes the
248 <option>-fstack-protector-strong</option> option the default when
249 compiling programs. <xref linkend="gSSP"/> is a technique preventing
250 alteration of the program flow by corrupting the parameter stack.
251 </para>
252
253 <para>
254 <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++,m2</parameter>:
255 This command identifies which languages to build. You may modify
256 this command to remove undesired languages. GCC also supports Ada
257 and D, but building GCC with Ada (or D) support needs an existing
258 Ada (or D) compiler. So they are not enabled here.
259 </para>
260
261 <para>
262 <command>ulimit -s 32768</command>: This command prevents several
263 tests from running out of stack space.
264 </para>
265
266 <para>
267 <command>make -k check</command>: This command runs the test suite
268 without stopping if any errors are encountered.
269 </para>
270
271 <para>
272 <command>../contrib/test_summary</command>: This command will produce
273 a summary of the test suite results. You can append <command>| grep
274 -A7 Summ</command> to the command to produce an even more condensed
275 version of the summary. You may also wish to redirect the output
276 to a file for review and comparison later on.
277 </para>
278
279 <para>
280 <command>mv -v /usr/lib/*gdb.py ...</command>: The installation
281 stage puts some files used by <application>gdb</application> under the
282 <filename class="directory">/usr/lib</filename> directory. This generates
283 spurious error messages when performing <command>ldconfig</command>. This
284 command moves the files to another location.
285 </para>
286
287 <para>
288 <command>chown -v -R root:root /usr/lib/gcc/*linux-gnu/...</command>:
289 If the package is built by a user other than root, the ownership of the
290 installed <filename class="directory">include</filename> directory (and
291 its content) will be incorrect. This command changes the ownership to the
292 <systemitem class="username">root</systemitem> user and group.
293 </para>
294
295 <para>
296 <option>--enable-host-shared --enable-languages=jit</option>:
297 Build <systemitem class="library">libgccjit</systemitem>, a library
298 for embedding GCC inside programs and libraries for generating machine
299 code. Despite <quote>JIT</quote> (just-in-time) in the name, the
300 library can be used for AOT (ahead-of-time) compilation as well.
301 <option>--enable-host-shared</option> is needed for building
302 <systemitem class="library">libgccjit</systemitem>, but it
303 significantly slows down GCC. So
304 <systemitem class="library">libgccjit</systemitem> should be built and
305 installed separately, not as a part of the <quote>main</quote> GCC
306 installation. If you need this library, configure GCC with
307 these two options and install the library by running
308 <!-- from Arch, not tested -->
309 <command>make -C gcc jit.install-common jit.install-info</command>
310 as the &root; user. This library is not used by any BLFS package,
311 nor tested by the BLFS developers.
312 </para>
313
314 </sect2>
315
316 <sect2 role="content">
317 <title>Contents</title>
318
319 <para>
320 Some program and library names and descriptions are not listed here,
321 but can be found at
322 <ulink url="&lfs-root;/chapter08/gcc.html#contents-gcc">LFS section
323 for GCC</ulink> as they were
324 initially installed during the building of LFS.
325 </para>
326
327 <segmentedlist>
328 <segtitle>Installed Programs</segtitle>
329 <segtitle>Installed Libraries</segtitle>
330 <segtitle>Installed Directories</segtitle>
331
332 <seglistitem>
333 <seg>
334 gccgo, gfortran, gm2, go, and gofmt, hard-linked to architecture
335 specific names
336 </seg>
337 <seg>
338 libgfortran.{so,a}, libgm2.{so,a}
339 libgo.{so,a}, libgobegin.a, libgolibbegin.a,
340 libobjc.{so,a}, and numerous other run-time libraries and executables
341 </seg>
342 <seg>
343 /usr/lib/go
344 </seg>
345 </seglistitem>
346 </segmentedlist>
347
348 <variablelist>
349 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
350 <?dbfo list-presentation="list"?>
351 <?dbhtml list-presentation="table"?>
352
353 <varlistentry id="gccgo">
354 <term><command>gccgo</command></term>
355 <listitem>
356 <para>
357 is a GCC-based compiler for the <application>Go</application>
358 language
359 </para>
360 <indexterm zone="gcc gccgo">
361 <primary sortas="b-gccgo">gccgo</primary>
362 </indexterm>
363 </listitem>
364 </varlistentry>
365
366 <varlistentry id="gm2">
367 <term><command>gm2</command></term>
368 <listitem>
369 <para>
370 is a GCC-based compiler for the
371 <application>Modula-2</application> language
372 </para>
373 <indexterm zone="gcc gm2">
374 <primary sortas="b-gm2">gm2</primary>
375 </indexterm>
376 </listitem>
377 </varlistentry>
378
379 <varlistentry id="go">
380 <term><command>go</command></term>
381 <listitem>
382 <para>
383 is a tool for managing <application>Go</application> source code
384 </para>
385 <indexterm zone="gcc go">
386 <primary sortas="b-go">go</primary>
387 </indexterm>
388 </listitem>
389 </varlistentry>
390
391 <varlistentry id="gofmt">
392 <term><command>gofmt</command></term>
393 <listitem>
394 <para>
395 is a tool for formatting <application>Go</application> source code
396 </para>
397 <indexterm zone="gcc gofmt">
398 <primary sortas="b-gofmt">gofmt</primary>
399 </indexterm>
400 </listitem>
401 </varlistentry>
402 <!--
403 <varlistentry id="gdc">
404 <term><command>gdc</command></term>
405 <listitem>
406 <para>
407 is a GCC-based compiler for the <application>D</application>
408 language
409 </para>
410 <indexterm zone="gcc gdc">
411 <primary sortas="b-gdc">gdc</primary>
412 </indexterm>
413 </listitem>
414 </varlistentry>
415 -->
416 <varlistentry id="gfortran">
417 <term><command>gfortran</command></term>
418 <listitem>
419 <para>
420 is a GCC-based compiler for the <application>Fortran</application>
421 language
422 </para>
423 <indexterm zone="gcc gfortran">
424 <primary sortas="b-gfortran">gfortran</primary>
425 </indexterm>
426 </listitem>
427 </varlistentry>
428
429 </variablelist>
430
431 </sect2>
432
433</sect1>
Note: See TracBrowser for help on using the repository browser.