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