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 | <!ENTITY gcc-md5sum "4ab282f414676496483b3e1793d07862">
|
---|
10 | <!ENTITY gcc-size "61 MB">
|
---|
11 | <!ENTITY gcc-buildsize "8.5 GB (an additonal 140MB for tests)">
|
---|
12 | <!ENTITY gcc-time "29 SBU (with parallelism=4, an additional 106 SBU for tests with parallelism=1)">
|
---|
13 | ]>
|
---|
14 |
|
---|
15 | <sect1 id="gcc" xreflabel="GCC-&gcc-version;">
|
---|
16 | <?dbhtml filename="gcc.html" ?>
|
---|
17 |
|
---|
18 | <sect1info>
|
---|
19 | <othername>$LastChangedBy$</othername>
|
---|
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 | One additional language, Ada, is available in the collection. It has
|
---|
37 | a binary bootstrap requirement for the first installation, so it is
|
---|
38 | described on a separate page (<xref linkend="gcc-ada"/>), but can be added
|
---|
39 | here if you are performing a rebuild or upgrade. Since C and C++ are
|
---|
40 | installed in LFS, this page is either for upgrading C and C++, or for
|
---|
41 | installing additional compilers.
|
---|
42 | </para>
|
---|
43 |
|
---|
44 | &lfs83_checked;
|
---|
45 |
|
---|
46 | <caution>
|
---|
47 | <para>
|
---|
48 | If you are upgrading <application>GCC</application> from any other
|
---|
49 | version prior to &gcc-version;, then you must be careful compiling 3rd
|
---|
50 | party kernel modules. You should ensure that the kernel and all its
|
---|
51 | native modules are also compiled using the same version of
|
---|
52 | <application>GCC</application> that you use to build the 3rd party module.
|
---|
53 | This issue does not affect native kernel (and kernel modules) updates,
|
---|
54 | as the instructions below are a complete reinstallation of
|
---|
55 | <application>GCC</application>. If you have existing 3rd party modules
|
---|
56 | installed, ensure they are recompiled using the updated version of
|
---|
57 | <application>GCC</application>. As always, never update the kernel
|
---|
58 | headers from the ones used when <application>Glibc</application> was
|
---|
59 | compiled during LFS.
|
---|
60 | </para>
|
---|
61 |
|
---|
62 | <para>
|
---|
63 | Some system headers need to be fixed to be used with GCC. This is done
|
---|
64 | during the installation of GCC, and the <quote>fixed</quote> headers
|
---|
65 | are installed in <filename class="directory">
|
---|
66 | /usr/lib/gcc/<machine triplet>/<GCC version>/include-fixed
|
---|
67 | </filename>. This is harmless if GCC is built during the LFS stage. But
|
---|
68 | if you reinstall GCC in BLFS, some of the BLFS packages may be
|
---|
69 | <quote>fixed</quote>. If one of those packages is reinstalled
|
---|
70 | afterwards, the <quote>fixed</quote> headers are not updated, which may
|
---|
71 | lead to version mismatches. In case that happens, the
|
---|
72 | <quote>fixed</quote> headers must be updated by running (as
|
---|
73 | <systemitem class="username">root</systemitem>):
|
---|
74 | <command>
|
---|
75 | /usr/libexec/gcc/x86_64-pc-linux-gnu/&gcc-version;/install-tools/mkheaders
|
---|
76 | </command>. The machine triplet may be different on a 32bit system.
|
---|
77 | </para>
|
---|
78 | </caution>
|
---|
79 |
|
---|
80 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
81 | <itemizedlist spacing="compact">
|
---|
82 | <listitem>
|
---|
83 | <para>
|
---|
84 | Download (HTTP): <ulink url="&gcc-download-http;"/>
|
---|
85 | </para>
|
---|
86 | </listitem>
|
---|
87 | <listitem>
|
---|
88 | <para>
|
---|
89 | Download (FTP): <ulink url="&gcc-download-ftp;"/>
|
---|
90 | </para>
|
---|
91 | </listitem>
|
---|
92 | <listitem>
|
---|
93 | <para>
|
---|
94 | Download MD5 sum: &gcc-md5sum;
|
---|
95 | </para>
|
---|
96 | </listitem>
|
---|
97 | <listitem>
|
---|
98 | <para>
|
---|
99 | Download size: &gcc-size;
|
---|
100 | </para>
|
---|
101 | </listitem>
|
---|
102 | <listitem>
|
---|
103 | <para>
|
---|
104 | Estimated disk space required: &gcc-buildsize;
|
---|
105 | </para>
|
---|
106 | </listitem>
|
---|
107 | <listitem>
|
---|
108 | <para>
|
---|
109 | Estimated build time: &gcc-time;
|
---|
110 | </para>
|
---|
111 | </listitem>
|
---|
112 | </itemizedlist>
|
---|
113 |
|
---|
114 | <!-- <bridgehead renderas="sect3">Additional Downloads</bridgehead>
|
---|
115 | <itemizedlist spacing="compact">
|
---|
116 | <listitem>
|
---|
117 | <para>
|
---|
118 | Required patch:
|
---|
119 | <ulink url="&patch-root;/gcc-&gcc-version;-upstream_fixes-1.patch"/>
|
---|
120 | </para>
|
---|
121 | </listitem>
|
---|
122 | </itemizedlist>
|
---|
123 | -->
|
---|
124 |
|
---|
125 | <bridgehead renderas="sect3">GCC Dependencies</bridgehead>
|
---|
126 |
|
---|
127 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
128 | <para role="recommended">
|
---|
129 | <xref linkend="dejagnu"/>, for tests
|
---|
130 | </para>
|
---|
131 |
|
---|
132 | <para condition="html" role="usernotes">
|
---|
133 | User Notes: <ulink url="&blfs-wiki;/gcc"/>
|
---|
134 | </para>
|
---|
135 |
|
---|
136 | </sect2>
|
---|
137 |
|
---|
138 | <sect2 role="installation">
|
---|
139 | <title>Installation of GCC</title>
|
---|
140 |
|
---|
141 | <important>
|
---|
142 | <para>
|
---|
143 | Even if you specify only languages other than C and C++ to the
|
---|
144 | <command>./configure</command> command below, the
|
---|
145 | installation process will overwrite your existing
|
---|
146 | <application>GCC</application> C and C++ compilers and libraries.
|
---|
147 | Having the <application>Tcl</application>,
|
---|
148 | <application>Expect</application> and <application>DejaGnu</application>
|
---|
149 | packages installed before beginning the build is highly recommended so
|
---|
150 | you can run the full suite of tests.
|
---|
151 | </para>
|
---|
152 |
|
---|
153 | <para>
|
---|
154 | Do not continue with the <command>make install</command> command
|
---|
155 | until you are confident the build was successful. You can compare your
|
---|
156 | test results with those found at <ulink
|
---|
157 | url="http://gcc.gnu.org/ml/gcc-testresults/"/>. You may also want to
|
---|
158 | refer to the information found in the <application>GCC</application>
|
---|
159 | section of Chapter 6 in the LFS book (<ulink
|
---|
160 | url="&lfs-root;/chapter06/gcc.html"/>).
|
---|
161 | </para>
|
---|
162 | </important>
|
---|
163 |
|
---|
164 | <para>
|
---|
165 | The instructions below are intentionally performing a
|
---|
166 | <quote>bootstrap</quote> process. Bootstrapping is needed for robustness
|
---|
167 | and is highly recommended when upgrading the compilers version. To disable
|
---|
168 | bootstrap anyways, add <parameter>--disable-bootstrap</parameter> to the
|
---|
169 | <command>./configure</command> options below.
|
---|
170 | </para>
|
---|
171 |
|
---|
172 | <para>
|
---|
173 | Install <application>GCC</application> by running the following commands:
|
---|
174 | </para>
|
---|
175 |
|
---|
176 | <screen><userinput>case $(uname -m) in
|
---|
177 | x86_64)
|
---|
178 | sed -e '/m64=/s/lib64/lib/' \
|
---|
179 | -i.orig gcc/config/i386/t-linux64
|
---|
180 | ;;
|
---|
181 | esac
|
---|
182 |
|
---|
183 | mkdir build &&
|
---|
184 | cd build &&
|
---|
185 |
|
---|
186 | ../configure \
|
---|
187 | --prefix=/usr \
|
---|
188 | --disable-multilib \
|
---|
189 | --disable-libmpx \
|
---|
190 | --with-system-zlib \
|
---|
191 | --enable-languages=c,c++,fortran,go,objc,obj-c++ &&
|
---|
192 | make</userinput></screen>
|
---|
193 |
|
---|
194 | <para>
|
---|
195 | If you have installed additional packages such as
|
---|
196 | <application>Valgrind</application> and <application>GDB</application>,
|
---|
197 | the <application>GCC</application> part of the testsuite will run more
|
---|
198 | tests than in LFS. Some of those will report FAIL and others XPASS
|
---|
199 | (pass when expected to FAIL). 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. Two other languages can be
|
---|
269 | added, besides ADA (see introduction above): 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 | <option>--with-default-libstdcxx-abi=gcc4-compatible</option>: Use this
|
---|
280 | switch if you are upgrading from a <application>GCC</application>
|
---|
281 | version prior to 5.1.0, and you do not want to recompile all the
|
---|
282 | libraries written in C++.
|
---|
283 | </para>
|
---|
284 |
|
---|
285 | <para>
|
---|
286 | <command>ulimit -s 32768</command>: This command prevents several
|
---|
287 | tests from running out of stack space.
|
---|
288 | </para>
|
---|
289 |
|
---|
290 | <para>
|
---|
291 | <command>make -k check</command>: This command runs the test suite
|
---|
292 | without stopping if any errors are encountered.
|
---|
293 | </para>
|
---|
294 |
|
---|
295 | <para>
|
---|
296 | <command>../contrib/test_summary</command>: This command will produce
|
---|
297 | a summary of the test suite results. You can append <command>| grep
|
---|
298 | -A7 Summ</command> to the command to produce an even more condensed
|
---|
299 | version of the summary. You may also wish to redirect the output
|
---|
300 | to a file for review and comparison later on.
|
---|
301 | </para>
|
---|
302 |
|
---|
303 | <para>
|
---|
304 | <command>mv -v /usr/lib/*gdb.py ...</command>: The installation
|
---|
305 | stage puts some files used by <application>gdb</application> under the
|
---|
306 | <filename class="directory">/usr/lib</filename> directory. This generates
|
---|
307 | spurious error messages when performing <command>ldconfig</command>. This
|
---|
308 | command moves the files to another location.
|
---|
309 | </para>
|
---|
310 |
|
---|
311 | <para>
|
---|
312 | <command>chown -v -R root:root /usr/lib/gcc/*linux-gnu/...</command>:
|
---|
313 | If the package is built by a user other than root, the ownership of the
|
---|
314 | installed <filename class="directory">include</filename> directory (and
|
---|
315 | its content) will be incorrect. This command changes the ownership to the
|
---|
316 | <systemitem class="username">root</systemitem> user and group.
|
---|
317 | </para>
|
---|
318 |
|
---|
319 | </sect2>
|
---|
320 |
|
---|
321 | <sect2 role="content">
|
---|
322 | <title>Contents</title>
|
---|
323 |
|
---|
324 | <para>
|
---|
325 | Some program and library names and descriptions are not listed here,
|
---|
326 | but can be found at
|
---|
327 | <ulink url="&lfs-root;/chapter06/gcc.html#contents-gcc"/> as they were
|
---|
328 | initially installed during the building of LFS.
|
---|
329 | </para>
|
---|
330 |
|
---|
331 | <segmentedlist>
|
---|
332 | <segtitle>Installed Programs</segtitle>
|
---|
333 | <segtitle>Installed Libraries</segtitle>
|
---|
334 | <segtitle>Installed Directories</segtitle>
|
---|
335 |
|
---|
336 | <seglistitem>
|
---|
337 | <seg>
|
---|
338 | gccgo, go, gofmt, and gfortran, hard-linked to architecture specific
|
---|
339 | names
|
---|
340 | </seg>
|
---|
341 | <seg>
|
---|
342 | libgfortran.{so,a},
|
---|
343 | libgo.{so,a}, libgobegin.a, libgolibbegin.a,
|
---|
344 | libobjc.{so,a}, and numerous other run-time libraries and executables
|
---|
345 | </seg>
|
---|
346 | <seg>
|
---|
347 | /usr/lib/go
|
---|
348 | </seg>
|
---|
349 | </seglistitem>
|
---|
350 | </segmentedlist>
|
---|
351 |
|
---|
352 | <variablelist>
|
---|
353 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
354 | <?dbfo list-presentation="list"?>
|
---|
355 | <?dbhtml list-presentation="table"?>
|
---|
356 |
|
---|
357 | <varlistentry id="gccgo">
|
---|
358 | <term><command>gccgo</command></term>
|
---|
359 | <listitem>
|
---|
360 | <para>
|
---|
361 | is a GCC-based compiler for the <application>Go</application>
|
---|
362 | language.
|
---|
363 | </para>
|
---|
364 | <indexterm zone="gcc gccgo">
|
---|
365 | <primary sortas="b-gccgo">gccgo</primary>
|
---|
366 | </indexterm>
|
---|
367 | </listitem>
|
---|
368 | </varlistentry>
|
---|
369 |
|
---|
370 | <varlistentry id="go">
|
---|
371 | <term><command>go</command></term>
|
---|
372 | <listitem>
|
---|
373 | <para>
|
---|
374 | is a tool for managing <application>Go</application> source code.
|
---|
375 | </para>
|
---|
376 | <indexterm zone="gcc go">
|
---|
377 | <primary sortas="b-go">go</primary>
|
---|
378 | </indexterm>
|
---|
379 | </listitem>
|
---|
380 | </varlistentry>
|
---|
381 |
|
---|
382 | <varlistentry id="gofmt">
|
---|
383 | <term><command>gofmt</command></term>
|
---|
384 | <listitem>
|
---|
385 | <para>
|
---|
386 | is a tool for formatting <application>Go</application> source code.
|
---|
387 | </para>
|
---|
388 | <indexterm zone="gcc gofmt">
|
---|
389 | <primary sortas="b-gofmt">gofmt</primary>
|
---|
390 | </indexterm>
|
---|
391 | </listitem>
|
---|
392 | </varlistentry>
|
---|
393 |
|
---|
394 | <varlistentry id="gfortran">
|
---|
395 | <term><command>gfortran</command></term>
|
---|
396 | <listitem>
|
---|
397 | <para>
|
---|
398 | is a GCC-based compiler for the <application>Fortran</application>
|
---|
399 | language.
|
---|
400 | </para>
|
---|
401 | <indexterm zone="gcc gfortran">
|
---|
402 | <primary sortas="b-gfortran">gfortran</primary>
|
---|
403 | </indexterm>
|
---|
404 | </listitem>
|
---|
405 | </varlistentry>
|
---|
406 |
|
---|
407 | </variablelist>
|
---|
408 |
|
---|
409 | </sect2>
|
---|
410 |
|
---|
411 | </sect1>
|
---|