source: general/prog/gcc.xml@ e59834d

12.0 12.1 kea ken/TL2024 ken/tuningfonts lazarus lxqt plabs/newcss python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since e59834d was f0dd071, checked in by Thomas Trepl <thomas@…>, 15 months ago

Add a patch to fix gcc-go version string

  • Property mode set to 100644
File size: 16.9 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 &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 </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 Optional patch when adding Go to the desired language list:
124 <ulink url="&patch-root;/gcc-&gcc-version;-fix_go_version-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 Some packages checks on the phrase <literal>gccgo</literal> in the output
177 of <command>go version</command> to see which kind of Go compiler is
178 installed (gcc-go or golang). The absence of <literal>gccgo</literal> in
179 that string makes them to assume the compiler is the golang which is wrong.
180 If Go isn't in the list of desired languages, this patch can be skipped
181 while it does not harm if applied anyway. Fix the Go part of gcc to show
182 a valid version string when calling <command>go version</command> by
183 applying a patch:
184 </para>
185
186<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-fix_go_version-1.patch</userinput></screen>
187
188 <para>
189 Install <application>GCC</application> by running the following commands:
190 </para>
191
192<screen><userinput>case $(uname -m) in
193 x86_64)
194 sed -i.orig '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
195 ;;
196esac
197
198mkdir build &amp;&amp;
199cd build &amp;&amp;
200
201../configure \
202 --prefix=/usr \
203 --disable-multilib \
204 --with-system-zlib \
205 --enable-default-pie \
206 --enable-default-ssp \
207 --enable-languages=c,c++,fortran,go,objc,obj-c++ &amp;&amp;
208make</userinput></screen>
209
210 <para>
211 If you have installed additional packages such as
212 <application>Valgrind</application> and <application>GDB</application>,
213 the <application>GCC</application> part of the test suite will run more
214 tests than in LFS. Some of those will report FAIL and others XPASS
215 (pass when expected to FAIL). As of gcc-12.2.0, about 60 FAIL occur
216 in the <quote>guality</quote> suite, as well as miscellaneous failures
217 throughout the rest of the test suite, fifteen of which are already
218 present in the GCC tests of LFS. If all the compilers above are
219 built, there will be around 80 unexpected failures out of over
220 482,000 tests. To run the tests, issue:
221 </para>
222
223<screen><userinput>ulimit -s 32768 &amp;&amp;
224make -k check</userinput></screen>
225<!-- The command above may error out, so using && may prevent the summary
226to be run. -->
227
228 <para>
229 The tests are very long, and the results may be hard to find in the
230 logs, specially if you use parallel jobs with make. You can get a summary
231 of the tests with:
232 </para>
233
234<screen><userinput>../contrib/test_summary</userinput></screen>
235
236 <para>
237 Now, as the <systemitem class="username">root</systemitem> user:
238 </para>
239
240<screen role="root"><userinput>make install &amp;&amp;
241
242mkdir -pv /usr/share/gdb/auto-load/usr/lib &amp;&amp;
243mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &amp;&amp;
244
245chown -v -R root:root \
246 /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed}</userinput></screen>
247
248 <para>
249 Some packages expect to find the C preprocessor in
250 <filename class="directory">/lib</filename> or may refer to the C compiler
251 under the name <command>cc</command>. The following symbolic links are not
252 needed if you have followed the LFS instructions, since they
253 have been already created. If you do not have them on your system, issue
254 as the <systemitem class="username">root</systemitem> user:
255 </para>
256
257<screen role="root"><userinput>ln -v -sf ../usr/bin/cpp /lib &amp;&amp;
258ln -v -sf gcc /usr/bin/cc &amp;&amp;
259install -v -dm755 /usr/lib/bfd-plugins &amp;&amp;
260ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/&gcc-version;/liblto_plugin.so /usr/lib/bfd-plugins/</userinput></screen>
261
262 </sect2>
263
264 <sect2 role="commands">
265 <title>Command Explanations</title>
266
267 <para>
268 <command>mkdir build; cd build</command>: The
269 <application>GCC</application> documentation recommends
270 building the package in a dedicated build directory.
271 </para>
272
273 <para>
274 <parameter>--disable-multilib</parameter>: This parameter ensures
275 that files are created for the specific architecture of your computer.
276 </para>
277
278 <para>
279 <parameter>--with-system-zlib</parameter>: Uses the system
280 <application>zlib</application> instead of the bundled one.
281 <application>zlib</application> is used for compressing
282 and decompressing <application>GCC</application>'s intermediate
283 language in LTO (Link Time Optimization) object files.
284 </para>
285
286 <para>
287 <parameter>--enable-default-pie</parameter>: Makes the
288 <option>-fpie</option> option the default when compiling programs.
289 Together with the <xref linkend="gASLR"/> feature enabled in the kernel,
290 this defeats some kind of attacks based on known memory layouts.
291 </para>
292
293 <para>
294 <parameter>--enable-default-ssp</parameter>: Makes the
295 <option>-fstack-protector-strong</option> option the default when
296 compiling programs. <xref linkend="gSSP"/> is a technique preventing
297 alteration of the program flow by corrupting the parameter stack.
298 </para>
299
300 <para>
301 <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++</parameter>:
302 This command identifies which languages to build. You may modify
303 this command to remove undesired languages. Other languages can be
304 added, including ADA, D, BRIG (add
305 <parameter>brig</parameter> to the list of enabled languages), a binary
306 format for HSAIL (Heterogeneous System Architecture Intermediate
307 Language), and JIT (add <parameter>jit</parameter> to the list of enabled
308 languages), a library which can be linked into interpreters that want to
309 generate machine code <quote>on the fly</quote> at run-time. They have not
310 been tested by the BLFS developers.
311 </para>
312
313 <para>
314 <command>ulimit -s 32768</command>: This command prevents several
315 tests from running out of stack space.
316 </para>
317
318 <para>
319 <command>make -k check</command>: This command runs the test suite
320 without stopping if any errors are encountered.
321 </para>
322
323 <para>
324 <command>../contrib/test_summary</command>: This command will produce
325 a summary of the test suite results. You can append <command>| grep
326 -A7 Summ</command> to the command to produce an even more condensed
327 version of the summary. You may also wish to redirect the output
328 to a file for review and comparison later on.
329 </para>
330
331 <para>
332 <command>mv -v /usr/lib/*gdb.py ...</command>: The installation
333 stage puts some files used by <application>gdb</application> under the
334 <filename class="directory">/usr/lib</filename> directory. This generates
335 spurious error messages when performing <command>ldconfig</command>. This
336 command moves the files to another location.
337 </para>
338
339 <para>
340 <command>chown -v -R root:root /usr/lib/gcc/*linux-gnu/...</command>:
341 If the package is built by a user other than root, the ownership of the
342 installed <filename class="directory">include</filename> directory (and
343 its content) will be incorrect. This command changes the ownership to the
344 <systemitem class="username">root</systemitem> user and group.
345 </para>
346
347 </sect2>
348
349 <sect2 role="content">
350 <title>Contents</title>
351
352 <para>
353 Some program and library names and descriptions are not listed here,
354 but can be found at
355 <ulink url="&lfs-root;/chapter08/gcc.html#contents-gcc">LFS section
356 for GCC</ulink> as they were
357 initially installed during the building of LFS.
358 </para>
359
360 <segmentedlist>
361 <segtitle>Installed Programs</segtitle>
362 <segtitle>Installed Libraries</segtitle>
363 <segtitle>Installed Directories</segtitle>
364
365 <seglistitem>
366 <seg>
367 gccgo, gfortran, go, and gofmt, hard-linked to architecture
368 specific names
369 </seg>
370 <seg>
371 libgfortran.{so,a},
372 libgo.{so,a}, libgobegin.a, libgolibbegin.a,
373 libobjc.{so,a}, and numerous other run-time libraries and executables
374 </seg>
375 <seg>
376 /usr/lib/go
377 </seg>
378 </seglistitem>
379 </segmentedlist>
380
381 <variablelist>
382 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
383 <?dbfo list-presentation="list"?>
384 <?dbhtml list-presentation="table"?>
385
386 <varlistentry id="gccgo">
387 <term><command>gccgo</command></term>
388 <listitem>
389 <para>
390 is a GCC-based compiler for the <application>Go</application>
391 language
392 </para>
393 <indexterm zone="gcc gccgo">
394 <primary sortas="b-gccgo">gccgo</primary>
395 </indexterm>
396 </listitem>
397 </varlistentry>
398
399 <varlistentry id="go">
400 <term><command>go</command></term>
401 <listitem>
402 <para>
403 is a tool for managing <application>Go</application> source code
404 </para>
405 <indexterm zone="gcc go">
406 <primary sortas="b-go">go</primary>
407 </indexterm>
408 </listitem>
409 </varlistentry>
410
411 <varlistentry id="gofmt">
412 <term><command>gofmt</command></term>
413 <listitem>
414 <para>
415 is a tool for formatting <application>Go</application> source code
416 </para>
417 <indexterm zone="gcc gofmt">
418 <primary sortas="b-gofmt">gofmt</primary>
419 </indexterm>
420 </listitem>
421 </varlistentry>
422 <!--
423 <varlistentry id="gdc">
424 <term><command>gdc</command></term>
425 <listitem>
426 <para>
427 is a GCC-based compiler for the <application>D</application>
428 language
429 </para>
430 <indexterm zone="gcc gdc">
431 <primary sortas="b-gdc">gdc</primary>
432 </indexterm>
433 </listitem>
434 </varlistentry>
435 -->
436 <varlistentry id="gfortran">
437 <term><command>gfortran</command></term>
438 <listitem>
439 <para>
440 is a GCC-based compiler for the <application>Fortran</application>
441 language
442 </para>
443 <indexterm zone="gcc gfortran">
444 <primary sortas="b-gfortran">gfortran</primary>
445 </indexterm>
446 </listitem>
447 </varlistentry>
448
449 </variablelist>
450
451 </sect2>
452
453</sect1>
Note: See TracBrowser for help on using the repository browser.