source: general/prog/gcc.xml@ 485f05c

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 485f05c was b89180f, checked in by Pierre Labastie <pierre.labastie@…>, 22 months ago

Add --enable-default-pie/ssp to gcc

Also command explanations and test result comments

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