source: general/prog/gcc.xml@ 87065037

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 87065037 was b89180f, checked in by Pierre Labastie <pierre.labastie@…>, 20 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
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 <sect1info>
20 <date>$Date$</date>
21 </sect1info>
22
23 <title>GCC-&gcc-version;</title>
24
25 <indexterm zone="gcc">
26 <primary sortas="a-gcc-5-0">GCC-&gcc-version;</primary>
27 </indexterm>
28
29 <sect2 role="package">
30 <title>Introduction to GCC</title>
31
32 <para>
33 The <application>GCC</application> package contains the GNU Compiler
34 Collection. This page describes the installation of compilers for the
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.
38 </para>
39
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
52 &lfs112_checked;
53
54 <caution>
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>
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>
83 /usr/libexec/gcc/x86_64-pc-linux-gnu/&gcc-version;/install-tools/mkheaders
84 </command>. The machine triplet may be different on a 32-bit system.
85 </para>
86 </caution>
87
88 <bridgehead renderas="sect3">Package Information</bridgehead>
89 <itemizedlist spacing="compact">
90 <listitem>
91 <para>
92 Download (HTTP): <ulink url="&gcc-download-http;"/>
93 </para>
94 </listitem>
95 <listitem>
96 <para>
97 Download (FTP): <ulink url="&gcc-download-ftp;"/>
98 </para>
99 </listitem>
100 <listitem>
101 <para>
102 Download MD5 sum: &gcc-md5sum;
103 </para>
104 </listitem>
105 <listitem>
106 <para>
107 Download size: &gcc-size;
108 </para>
109 </listitem>
110 <listitem>
111 <para>
112 Estimated disk space required: &gcc-buildsize;
113 </para>
114 </listitem>
115 <listitem>
116 <para>
117 Estimated build time: &gcc-time;
118 </para>
119 </listitem>
120 </itemizedlist>
121<!--
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>
131-->
132 <bridgehead renderas="sect3">GCC Dependencies</bridgehead>
133
134 <bridgehead renderas="sect4">Optional</bridgehead>
135 <para role="optional">
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)
139 </para>
140
141 <para condition="html" role="usernotes">
142 User Notes: <ulink url="&blfs-wiki;/gcc"/>
143 </para>
144
145 </sect2>
146
147 <sect2 role="installation">
148 <title>Installation of GCC</title>
149
150 <important>
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.
156 Running the full suite of tests is recommended.
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
163 url="https://gcc.gnu.org/ml/gcc-testresults/"/>. You may also want to
164 refer to the information found in the <application>GCC</application>
165 section of Chapter 8 in the LFS book (<ulink
166 url="&lfs-root;/chapter08/gcc.html"/>).
167 </para>
168 </important>
169
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
174 bootstrap anyway, add <parameter>--disable-bootstrap</parameter> to the
175 <command>./configure</command> options below.
176 </para>
177<!--
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>
183-->
184 <para>
185 Install <application>GCC</application> by running the following commands:
186 </para>
187
188<screen><userinput>case $(uname -m) in
189 x86_64)
190 sed -i.orig '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
191 ;;
192esac
193
194mkdir build &amp;&amp;
195cd build &amp;&amp;
196
197../configure \
198 --prefix=/usr \
199 --disable-multilib \
200 --with-system-zlib \
201 --enable-default-pie \
202 --enable-default-ssp \
203 --enable-languages=c,c++,fortran,go,objc,obj-c++ &amp;&amp;
204make</userinput></screen>
205
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
211 (pass when expected to FAIL). As of gcc-12.2.0, about 60 FAIL occur
212 in the <quote>guality</quote> suite, as well as miscellaneous failures
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:
217 </para>
218
219<screen><userinput>ulimit -s 32768 &amp;&amp;
220make -k check</userinput></screen>
221<!-- The command above may error out, so using && may prevent the summary
222to be run. -->
223
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>
229
230<screen><userinput>../contrib/test_summary</userinput></screen>
231
232 <para>
233 Now, as the <systemitem class="username">root</systemitem> user:
234 </para>
235
236<screen role="root"><userinput>make install &amp;&amp;
237
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
241chown -v -R root:root \
242 /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed}</userinput></screen>
243
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>
252
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>
257
258 </sect2>
259
260 <sect2 role="commands">
261 <title>Command Explanations</title>
262
263 <para>
264 <command>mkdir build; cd build</command>: The
265 <application>GCC</application> documentation recommends
266 building the package in a dedicated build directory.
267 </para>
268
269 <para>
270 <parameter>--disable-multilib</parameter>: This parameter ensures
271 that files are created for the specific architecture of your computer.
272 </para>
273
274 <para>
275 <parameter>--with-system-zlib</parameter>: Uses the system
276 <application>zlib</application> instead of the bundled one.
277 <application>zlib</application> is used for compressing
278 and decompressing <application>GCC</application>'s intermediate
279 language in LTO (Link Time Optimization) object files.
280 </para>
281
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
296 <para>
297 <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++</parameter>:
298 This command identifies which languages to build. You may modify
299 this command to remove undesired languages. Other languages can be
300 added, including ADA, D, BRIG (add
301 <parameter>brig</parameter> to the list of enabled languages), a binary
302 format for HSAIL (Heterogeneous System Architecture Intermediate
303 Language), and JIT (add <parameter>jit</parameter> to the list of enabled
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.
307 </para>
308
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>
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
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>
342
343 </sect2>
344
345 <sect2 role="content">
346 <title>Contents</title>
347
348 <para>
349 Some program and library names and descriptions are not listed here,
350 but can be found at
351 <ulink url="&lfs-root;/chapter08/gcc.html#contents-gcc">LFS section
352 for GCC</ulink> as they were
353 initially installed during the building of LFS.
354 </para>
355
356 <segmentedlist>
357 <segtitle>Installed Programs</segtitle>
358 <segtitle>Installed Libraries</segtitle>
359 <segtitle>Installed Directories</segtitle>
360
361 <seglistitem>
362 <seg>
363 gccgo, gfortran, go, and gofmt, hard-linked to architecture
364 specific names
365 </seg>
366 <seg>
367 libgfortran.{so,a},
368 libgo.{so,a}, libgobegin.a, libgolibbegin.a,
369 libobjc.{so,a}, and numerous other run-time libraries and executables
370 </seg>
371 <seg>
372 /usr/lib/go
373 </seg>
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
382 <varlistentry id="gccgo">
383 <term><command>gccgo</command></term>
384 <listitem>
385 <para>
386 is a GCC-based compiler for the <application>Go</application>
387 language
388 </para>
389 <indexterm zone="gcc gccgo">
390 <primary sortas="b-gccgo">gccgo</primary>
391 </indexterm>
392 </listitem>
393 </varlistentry>
394
395 <varlistentry id="go">
396 <term><command>go</command></term>
397 <listitem>
398 <para>
399 is a tool for managing <application>Go</application> source code
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>
411 is a tool for formatting <application>Go</application> source code
412 </para>
413 <indexterm zone="gcc gofmt">
414 <primary sortas="b-gofmt">gofmt</primary>
415 </indexterm>
416 </listitem>
417 </varlistentry>
418 <!--
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>
424 language
425 </para>
426 <indexterm zone="gcc gdc">
427 <primary sortas="b-gdc">gdc</primary>
428 </indexterm>
429 </listitem>
430 </varlistentry>
431 -->
432 <varlistentry id="gfortran">
433 <term><command>gfortran</command></term>
434 <listitem>
435 <para>
436 is a GCC-based compiler for the <application>Fortran</application>
437 language
438 </para>
439 <indexterm zone="gcc gfortran">
440 <primary sortas="b-gfortran">gfortran</primary>
441 </indexterm>
442 </listitem>
443 </varlistentry>
444
445 </variablelist>
446
447 </sect2>
448
449</sect1>
Note: See TracBrowser for help on using the repository browser.