source: general/prog/gcc.xml@ 7241b26

11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 7241b26 was 3f2db3a6, checked in by Pierre Labastie <pierre.labastie@…>, 18 months ago

Remove sect1info tags

They only contain a date tag that is nowhere used.

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