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
RevLine 
[52d29f7]1<?xml version="1.0" encoding="ISO-8859-1"?>
[6732c094]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[52d29f7]4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6
[8dfc5c3]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">
[b5844a0]9 <!-- Update this also on the grub-uefi page -->
[0f21ed27]10 <!ENTITY gcc-md5sum "73bafd0af874439dcdb9fc063b6fb069">
11 <!ENTITY gcc-size "81 MB">
[7354b9a]12 <!ENTITY gcc-buildsize "10.5 GB (2.4 GB installed with all listed languages; add 1.3 GB for tests)">
[0f21ed27]13 <!ENTITY gcc-time "32 SBU (add 66 SBU for tests; both with parallelism=4)">
[52d29f7]14]>
15
[58bd309a]16<sect1 id="gcc" xreflabel="GCC-&gcc-version;">
[70e3220]17 <?dbhtml filename="gcc.html" ?>
18
19
20 <title>GCC-&gcc-version;</title>
21
22 <indexterm zone="gcc">
[ae0673a]23 <primary sortas="a-gcc-5-0">GCC-&gcc-version;</primary>
[70e3220]24 </indexterm>
25
26 <sect2 role="package">
27 <title>Introduction to GCC</title>
28
[ae0673a]29 <para>
30 The <application>GCC</application> package contains the GNU Compiler
31 Collection. This page describes the installation of compilers for the
[7354b9a]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.
[ae0673a]35 </para>
[5512e64]36
[7354b9a]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
[dc1a45e]49 &lfs113_checked;
[625d5fe5]50
[636acbb1]51 <caution>
[ae0673a]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>
[e9cab664]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>
[da8e9f9]80 /usr/libexec/gcc/x86_64-pc-linux-gnu/&gcc-version;/install-tools/mkheaders
[b9c353b]81 </command>. The machine triplet may be different on a 32-bit system.
[ae0673a]82 </para>
[636acbb1]83 </caution>
84
[70e3220]85 <bridgehead renderas="sect3">Package Information</bridgehead>
86 <itemizedlist spacing="compact">
87 <listitem>
[ae0673a]88 <para>
89 Download (HTTP): <ulink url="&gcc-download-http;"/>
90 </para>
[70e3220]91 </listitem>
92 <listitem>
[ae0673a]93 <para>
94 Download (FTP): <ulink url="&gcc-download-ftp;"/>
95 </para>
[70e3220]96 </listitem>
97 <listitem>
[ae0673a]98 <para>
99 Download MD5 sum: &gcc-md5sum;
100 </para>
[70e3220]101 </listitem>
102 <listitem>
[ae0673a]103 <para>
104 Download size: &gcc-size;
105 </para>
[70e3220]106 </listitem>
107 <listitem>
[ae0673a]108 <para>
109 Estimated disk space required: &gcc-buildsize;
110 </para>
[70e3220]111 </listitem>
112 <listitem>
[ae0673a]113 <para>
114 Estimated build time: &gcc-time;
115 </para>
[70e3220]116 </listitem>
117 </itemizedlist>
[f0dd071]118
[12ab2eb]119 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
120 <itemizedlist spacing="compact">
121 <listitem>
122 <para>
[f0dd071]123 Optional patch when adding Go to the desired language list:
124 <ulink url="&patch-root;/gcc-&gcc-version;-fix_go_version-1.patch"/>
[12ab2eb]125 </para>
126 </listitem>
127 </itemizedlist>
[f0dd071]128
[70e3220]129 <bridgehead renderas="sect3">GCC Dependencies</bridgehead>
[7354b9a]130
[a7e88c5c]131 <bridgehead renderas="sect4">Optional</bridgehead>
132 <para role="optional">
[1a8a995]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)
[a7e88c5c]136 </para>
[8558044]137
[ae0673a]138 <para condition="html" role="usernotes">
139 User Notes: <ulink url="&blfs-wiki;/gcc"/>
140 </para>
[1039de3]141
[70e3220]142 </sect2>
[034eda7]143
[70e3220]144 <sect2 role="installation">
145 <title>Installation of GCC</title>
146
147 <important>
[ae0673a]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.
[3026cde]153 Running the full suite of tests is recommended.
[ae0673a]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
[579bdb04]160 url="https://gcc.gnu.org/ml/gcc-testresults/"/>. You may also want to
[ae0673a]161 refer to the information found in the <application>GCC</application>
[f0dc9578]162 section of Chapter 8 in the LFS book (<ulink
163 url="&lfs-root;/chapter08/gcc.html"/>).
[ae0673a]164 </para>
[70e3220]165 </important>
166
[ae0673a]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
[0c953f12]171 bootstrap anyway, add <parameter>--disable-bootstrap</parameter> to the
[ae0673a]172 <command>./configure</command> options below.
173 </para>
[f0dd071]174
[12ab2eb]175 <para>
[f0dd071]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:
[12ab2eb]184 </para>
185
[f0dd071]186<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-fix_go_version-1.patch</userinput></screen>
187
[ae0673a]188 <para>
[e6d0be6]189 Install <application>GCC</application> by running the following commands:
[ae0673a]190 </para>
191
[e6d0be6]192<screen><userinput>case $(uname -m) in
[92245989]193 x86_64)
[df0e196]194 sed -i.orig '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
[92245989]195 ;;
196esac
197
[adbf61f]198mkdir build &amp;&amp;
199cd build &amp;&amp;
200
201../configure \
202 --prefix=/usr \
203 --disable-multilib \
204 --with-system-zlib \
[b89180f]205 --enable-default-pie \
206 --enable-default-ssp \
[7354b9a]207 --enable-languages=c,c++,fortran,go,objc,obj-c++ &amp;&amp;
[7cadfea]208make</userinput></screen>
[5512e64]209
[ae0673a]210 <para>
211 If you have installed additional packages such as
212 <application>Valgrind</application> and <application>GDB</application>,
[48771ae]213 the <application>GCC</application> part of the test suite will run more
[ae0673a]214 tests than in LFS. Some of those will report FAIL and others XPASS
[b89180f]215 (pass when expected to FAIL). As of gcc-12.2.0, about 60 FAIL occur
[3b187ea]216 in the <quote>guality</quote> suite, as well as miscellaneous failures
[b89180f]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:
[ae0673a]221 </para>
[d3757f1c]222
[7cadfea]223<screen><userinput>ulimit -s 32768 &amp;&amp;
[b10cfc81]224make -k check</userinput></screen>
225<!-- The command above may error out, so using && may prevent the summary
226to be run. -->
227
[ae0673a]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>
[5512e64]233
[0e64979]234<screen><userinput>../contrib/test_summary</userinput></screen>
[8c9ec303]235
[ae0673a]236 <para>
237 Now, as the <systemitem class="username">root</systemitem> user:
238 </para>
[8c9ec303]239
[70e3220]240<screen role="root"><userinput>make install &amp;&amp;
[5512e64]241
[7cadfea]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
[38485e5c]245chown -v -R root:root \
[7354b9a]246 /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed}</userinput></screen>
[f182eed]247
[ae0673a]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>
[70e3220]256
[ae0673a]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>
[034eda7]261
[70e3220]262 </sect2>
263
264 <sect2 role="commands">
265 <title>Command Explanations</title>
[8ddc247]266
[2d488eb]267 <para>
[0e64979]268 <command>mkdir build; cd build</command>: The
[2d488eb]269 <application>GCC</application> documentation recommends
270 building the package in a dedicated build directory.
271 </para>
[70e3220]272
[2d488eb]273 <para>
274 <parameter>--disable-multilib</parameter>: This parameter ensures
275 that files are created for the specific architecture of your computer.
276 </para>
[7cadfea]277
[2d488eb]278 <para>
[fa200b8]279 <parameter>--with-system-zlib</parameter>: Uses the system
[2d488eb]280 <application>zlib</application> instead of the bundled one.
281 <application>zlib</application> is used for compressing
[b89180f]282 and decompressing <application>GCC</application>'s intermediate
[2d488eb]283 language in LTO (Link Time Optimization) object files.
284 </para>
[034eda7]285
[b89180f]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
[800c9c3]300 <para>
[7354b9a]301 <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++</parameter>:
[2d488eb]302 This command identifies which languages to build. You may modify
[7354b9a]303 this command to remove undesired languages. Other languages can be
304 added, including ADA, D, BRIG (add
[3d9141c]305 <parameter>brig</parameter> to the list of enabled languages), a binary
[9562b375]306 format for HSAIL (Heterogeneous System Architecture Intermediate
[3d9141c]307 Language), and JIT (add <parameter>jit</parameter> to the list of enabled
[0f18e26]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.
[2d488eb]311 </para>
[ae0673a]312
[2d488eb]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>
[9562b375]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
[2d488eb]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>
[034eda7]346
[70e3220]347 </sect2>
348
349 <sect2 role="content">
350 <title>Contents</title>
351
[ae0673a]352 <para>
353 Some program and library names and descriptions are not listed here,
354 but can be found at
[9771f84]355 <ulink url="&lfs-root;/chapter08/gcc.html#contents-gcc">LFS section
356 for GCC</ulink> as they were
[ae0673a]357 initially installed during the building of LFS.
358 </para>
[2d488eb]359
[70e3220]360 <segmentedlist>
361 <segtitle>Installed Programs</segtitle>
362 <segtitle>Installed Libraries</segtitle>
363 <segtitle>Installed Directories</segtitle>
364
365 <seglistitem>
[7cadfea]366 <seg>
[7354b9a]367 gccgo, gfortran, go, and gofmt, hard-linked to architecture
[adbf61f]368 specific names
[7cadfea]369 </seg>
370 <seg>
[d7d743f0]371 libgfortran.{so,a},
[9562b375]372 libgo.{so,a}, libgobegin.a, libgolibbegin.a,
[d7d743f0]373 libobjc.{so,a}, and numerous other run-time libraries and executables
[7cadfea]374 </seg>
375 <seg>
[d5e9aa8]376 /usr/lib/go
[7cadfea]377 </seg>
[70e3220]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
[034eda7]386 <varlistentry id="gccgo">
387 <term><command>gccgo</command></term>
388 <listitem>
[ae0673a]389 <para>
[5b55f9b3]390 is a GCC-based compiler for the <application>Go</application>
[4c24eb0a]391 language
[ae0673a]392 </para>
[034eda7]393 <indexterm zone="gcc gccgo">
394 <primary sortas="b-gccgo">gccgo</primary>
[70e3220]395 </indexterm>
396 </listitem>
397 </varlistentry>
398
[87532434]399 <varlistentry id="go">
400 <term><command>go</command></term>
401 <listitem>
402 <para>
[4c24eb0a]403 is a tool for managing <application>Go</application> source code
[87532434]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>
[4c24eb0a]415 is a tool for formatting <application>Go</application> source code
[87532434]416 </para>
417 <indexterm zone="gcc gofmt">
418 <primary sortas="b-gofmt">gofmt</primary>
419 </indexterm>
420 </listitem>
421 </varlistentry>
[7354b9a]422 <!--
[adbf61f]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>
[4c24eb0a]428 language
[adbf61f]429 </para>
430 <indexterm zone="gcc gdc">
431 <primary sortas="b-gdc">gdc</primary>
432 </indexterm>
433 </listitem>
434 </varlistentry>
[7354b9a]435 -->
[800c9c3]436 <varlistentry id="gfortran">
437 <term><command>gfortran</command></term>
438 <listitem>
[ae0673a]439 <para>
440 is a GCC-based compiler for the <application>Fortran</application>
[4c24eb0a]441 language
[ae0673a]442 </para>
[800c9c3]443 <indexterm zone="gcc gfortran">
444 <primary sortas="b-gfortran">gfortran</primary>
445 </indexterm>
446 </listitem>
447 </varlistentry>
448
[70e3220]449 </variablelist>
450
451 </sect2>
[1a686a1]452
453</sect1>
Note: See TracBrowser for help on using the repository browser.