[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 |
|
---|
[87532434] | 7 | <!ENTITY gcc-download-http "http://ftpmirror.gnu.org/gcc/gcc-&gcc-version;/gcc-&gcc-version;.tar.bz2">
|
---|
[9268fb5] | 8 | <!ENTITY gcc-download-ftp "ftp://ftp.gnu.org/gnu/gcc/gcc-&gcc-version;/gcc-&gcc-version;.tar.bz2">
|
---|
[b4c31a6] | 9 | <!ENTITY gcc-md5sum "677a7623c7ef6ab99881bc4e048debb6">
|
---|
[bed2286] | 10 | <!ENTITY gcc-size "95 MB">
|
---|
[b4c31a6] | 11 | <!ENTITY gcc-buildsize "7.7 GB (with tests)">
|
---|
| 12 | <!ENTITY gcc-time "58 SBU (with tests and parallelism=4)">
|
---|
[52d29f7] | 13 | ]>
|
---|
| 14 |
|
---|
[58bd309a] | 15 | <sect1 id="gcc" xreflabel="GCC-&gcc-version;">
|
---|
[70e3220] | 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">
|
---|
[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
|
---|
| 35 | following languages: C, C++, Fortran, Objective C, Objective C++, and Go.
|
---|
| 36 | Two additional languages , Ada and Java are available in the collection.
|
---|
| 37 | They have specific requirements, so they are described in separate pages
|
---|
| 38 | (<xref linkend="gcc-ada"/> and <xref linkend="gcc-java"/>). Since C and
|
---|
| 39 | C++ are installed in LFS, this page is either for upgrading C and C++,
|
---|
| 40 | or for installing additional compilers.
|
---|
| 41 | </para>
|
---|
[5512e64] | 42 |
|
---|
[5b55f9b3] | 43 | &lfs7a_checked;
|
---|
[625d5fe5] | 44 |
|
---|
[636acbb1] | 45 | <caution>
|
---|
[ae0673a] | 46 | <para>
|
---|
| 47 | If you are upgrading <application>GCC</application> from any other
|
---|
| 48 | version prior to &gcc-version;, then you must be careful compiling 3rd
|
---|
| 49 | party kernel modules. You should ensure that the kernel and all its
|
---|
| 50 | native modules are also compiled using the same version of
|
---|
| 51 | <application>GCC</application> that you use to build the 3rd party module.
|
---|
| 52 | This issue does not affect native kernel (and kernel modules) updates,
|
---|
| 53 | as the instructions below are a complete reinstallation of
|
---|
| 54 | <application>GCC</application>. If you have existing 3rd party modules
|
---|
| 55 | installed, ensure they are recompiled using the updated version of
|
---|
| 56 | <application>GCC</application>. As always, never update the kernel
|
---|
| 57 | headers from the ones used when <application>Glibc</application> was
|
---|
| 58 | compiled during LFS.
|
---|
| 59 | </para>
|
---|
| 60 |
|
---|
| 61 | <para>
|
---|
| 62 | The 5.1.0 version of GCC introduces an incompatible ABI change in the
|
---|
| 63 | C++ library <filename>libstdc++.so</filename>. This does not prevent
|
---|
| 64 | using programs compiled with the previous version of <application>GCC
|
---|
| 65 | </application>, since both old and new symbols are available in the
|
---|
[87532434] | 66 | library. But compiling, with the new version, programs which use
|
---|
| 67 | libraries compiled with the old version is likely to give errors. So,
|
---|
| 68 | if you are upgrading from any previous version prior to 5.1.0, you have
|
---|
| 69 | two solutions:
|
---|
[ae0673a] | 70 | recompile all the libraries with the new version, or use the <option>
|
---|
| 71 | --with-default-libstdcxx-abi</option> switch to configure.
|
---|
| 72 | </para>
|
---|
[636acbb1] | 73 | </caution>
|
---|
| 74 |
|
---|
[70e3220] | 75 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 76 | <itemizedlist spacing="compact">
|
---|
| 77 | <listitem>
|
---|
[ae0673a] | 78 | <para>
|
---|
| 79 | Download (HTTP): <ulink url="&gcc-download-http;"/>
|
---|
| 80 | </para>
|
---|
[70e3220] | 81 | </listitem>
|
---|
| 82 | <listitem>
|
---|
[ae0673a] | 83 | <para>
|
---|
| 84 | Download (FTP): <ulink url="&gcc-download-ftp;"/>
|
---|
| 85 | </para>
|
---|
[70e3220] | 86 | </listitem>
|
---|
| 87 | <listitem>
|
---|
[ae0673a] | 88 | <para>
|
---|
| 89 | Download MD5 sum: &gcc-md5sum;
|
---|
| 90 | </para>
|
---|
[70e3220] | 91 | </listitem>
|
---|
| 92 | <listitem>
|
---|
[ae0673a] | 93 | <para>
|
---|
| 94 | Download size: &gcc-size;
|
---|
| 95 | </para>
|
---|
[70e3220] | 96 | </listitem>
|
---|
| 97 | <listitem>
|
---|
[ae0673a] | 98 | <para>
|
---|
| 99 | Estimated disk space required: &gcc-buildsize;
|
---|
| 100 | </para>
|
---|
[70e3220] | 101 | </listitem>
|
---|
| 102 | <listitem>
|
---|
[ae0673a] | 103 | <para>
|
---|
| 104 | Estimated build time: &gcc-time;
|
---|
| 105 | </para>
|
---|
[70e3220] | 106 | </listitem>
|
---|
| 107 | </itemizedlist>
|
---|
[ae0673a] | 108 |
|
---|
[87532434] | 109 | <!-- <bridgehead renderas="sect3">Additional Downloads</bridgehead>
|
---|
[18310d86] | 110 | <itemizedlist spacing="compact">
|
---|
| 111 | <listitem>
|
---|
| 112 | <para>
|
---|
| 113 | Required patch:
|
---|
[5fd1f25b] | 114 | <ulink url="&patch-root;/gcc-&gcc-version;-upstream_fixes-1.patch"/>
|
---|
[18310d86] | 115 | </para>
|
---|
| 116 | </listitem>
|
---|
| 117 | </itemizedlist>
|
---|
[87532434] | 118 | -->
|
---|
[8ddc247] | 119 |
|
---|
[70e3220] | 120 | <bridgehead renderas="sect3">GCC Dependencies</bridgehead>
|
---|
| 121 |
|
---|
[7cadfea] | 122 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
| 123 | <para role="recommended">
|
---|
[eb631ac] | 124 | <xref linkend="dejagnu"/>, for tests
|
---|
[7cadfea] | 125 | </para>
|
---|
| 126 |
|
---|
[ae0673a] | 127 | <para condition="html" role="usernotes">
|
---|
| 128 | User Notes: <ulink url="&blfs-wiki;/gcc"/>
|
---|
| 129 | </para>
|
---|
[1039de3] | 130 |
|
---|
[70e3220] | 131 | </sect2>
|
---|
[034eda7] | 132 |
|
---|
[70e3220] | 133 | <sect2 role="installation">
|
---|
| 134 | <title>Installation of GCC</title>
|
---|
| 135 |
|
---|
| 136 | <important>
|
---|
[ae0673a] | 137 | <para>
|
---|
| 138 | Even if you specify only languages other than C and C++ to the
|
---|
| 139 | <command>./configure</command> command below, the
|
---|
| 140 | installation process will overwrite your existing
|
---|
| 141 | <application>GCC</application> C and C++ compilers and libraries.
|
---|
| 142 | Having the <application>Tcl</application>,
|
---|
| 143 | <application>Expect</application> and <application>DejaGnu</application>
|
---|
| 144 | packages installed before beginning the build is highly recommended so
|
---|
| 145 | you can run the full suite of tests.
|
---|
| 146 | </para>
|
---|
| 147 |
|
---|
| 148 | <para>
|
---|
| 149 | Do not continue with the <command>make install</command> command
|
---|
| 150 | until you are confident the build was successful. You can compare your
|
---|
| 151 | test results with those found at <ulink
|
---|
| 152 | url="http://gcc.gnu.org/ml/gcc-testresults/"/>. You may also want to
|
---|
| 153 | refer to the information found in the <application>GCC</application>
|
---|
| 154 | section of Chapter 6 in the LFS book (<ulink
|
---|
| 155 | url="&lfs-root;/chapter06/gcc.html"/>).
|
---|
| 156 | </para>
|
---|
[70e3220] | 157 | </important>
|
---|
| 158 |
|
---|
[ae0673a] | 159 | <para>
|
---|
| 160 | The instructions below are intentionally performing a
|
---|
| 161 | <quote>bootstrap</quote> process. Bootstrapping is needed for robustness
|
---|
| 162 | and is highly recommended when upgrading the compilers version. To disable
|
---|
| 163 | bootstrap anyways, add <parameter>--disable-bootstrap</parameter> to the
|
---|
| 164 | <command>./configure</command> options below.
|
---|
| 165 | </para>
|
---|
[c6bfee88] | 166 |
|
---|
[ae0673a] | 167 | <para>
|
---|
| 168 | Install <application>GCC</application> by running the following commands:
|
---|
| 169 | </para>
|
---|
| 170 |
|
---|
[92245989] | 171 | <screen><userinput>case $(uname -m) in
|
---|
| 172 | x86_64)
|
---|
| 173 | sed -e '/m64=/s/lib64/lib/' \
|
---|
| 174 | -i.orig gcc/config/i386/t-linux64
|
---|
| 175 | ;;
|
---|
| 176 | esac
|
---|
| 177 |
|
---|
| 178 | mkdir build &&
|
---|
[0e64979] | 179 | cd build &&
|
---|
[2d488eb] | 180 |
|
---|
[0e64979] | 181 | ../configure \
|
---|
[2d488eb] | 182 | --prefix=/usr \
|
---|
| 183 | --disable-multilib \
|
---|
| 184 | --with-system-zlib \
|
---|
| 185 | --enable-languages=c,c++,fortran,go,objc,obj-c++ &&
|
---|
[7cadfea] | 186 | make</userinput></screen>
|
---|
[5512e64] | 187 |
|
---|
[ae0673a] | 188 | <para>
|
---|
| 189 | If you have installed additional packages such as
|
---|
| 190 | <application>Valgrind</application> and <application>GDB</application>,
|
---|
| 191 | the <application>GCC</application> part of the testsuite will run more
|
---|
| 192 | tests than in LFS. Some of those will report FAIL and others XPASS
|
---|
| 193 | (pass when expected to FAIL). To run the tests, issue:
|
---|
| 194 | </para>
|
---|
[d3757f1c] | 195 |
|
---|
[7cadfea] | 196 | <screen><userinput>ulimit -s 32768 &&
|
---|
[b10cfc81] | 197 | make -k check</userinput></screen>
|
---|
| 198 | <!-- The command above may error out, so using && may prevent the summary
|
---|
| 199 | to be run. -->
|
---|
| 200 |
|
---|
[ae0673a] | 201 | <para>
|
---|
| 202 | The tests are very long, and the results may be hard to find in the
|
---|
| 203 | logs, specially if you use parallel jobs with make. You can get a summary
|
---|
| 204 | of the tests with:
|
---|
| 205 | </para>
|
---|
[5512e64] | 206 |
|
---|
[0e64979] | 207 | <screen><userinput>../contrib/test_summary</userinput></screen>
|
---|
[8c9ec303] | 208 |
|
---|
[ae0673a] | 209 | <para>
|
---|
| 210 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
| 211 | </para>
|
---|
[8c9ec303] | 212 |
|
---|
[70e3220] | 213 | <screen role="root"><userinput>make install &&
|
---|
[5512e64] | 214 |
|
---|
[7cadfea] | 215 | mkdir -pv /usr/share/gdb/auto-load/usr/lib &&
|
---|
| 216 | mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &&
|
---|
| 217 |
|
---|
[38485e5c] | 218 | chown -v -R root:root \
|
---|
[2d488eb] | 219 | /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed}</userinput></screen>
|
---|
[f182eed] | 220 |
|
---|
[ae0673a] | 221 | <para>
|
---|
| 222 | Some packages expect to find the C preprocessor in
|
---|
| 223 | <filename class="directory">/lib</filename> or may refer to the C compiler
|
---|
| 224 | under the name <command>cc</command>. The following symbolic links are not
|
---|
| 225 | needed if you have followed the LFS instructions, since they
|
---|
| 226 | have been already created. If you do not have them on your system, issue
|
---|
| 227 | as the <systemitem class="username">root</systemitem> user:
|
---|
| 228 | </para>
|
---|
[70e3220] | 229 |
|
---|
[ae0673a] | 230 | <screen role="root"><userinput>ln -v -sf ../usr/bin/cpp /lib &&
|
---|
| 231 | ln -v -sf gcc /usr/bin/cc &&
|
---|
| 232 | install -v -dm755 /usr/lib/bfd-plugins &&
|
---|
| 233 | ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/&gcc-version;/liblto_plugin.so /usr/lib/bfd-plugins/</userinput></screen>
|
---|
[034eda7] | 234 |
|
---|
[70e3220] | 235 | </sect2>
|
---|
| 236 |
|
---|
| 237 | <sect2 role="commands">
|
---|
| 238 | <title>Command Explanations</title>
|
---|
[8ddc247] | 239 |
|
---|
[2d488eb] | 240 | <para>
|
---|
[0e64979] | 241 | <command>mkdir build; cd build</command>: The
|
---|
[2d488eb] | 242 | <application>GCC</application> documentation recommends
|
---|
| 243 | building the package in a dedicated build directory.
|
---|
| 244 | </para>
|
---|
[70e3220] | 245 |
|
---|
[2d488eb] | 246 | <para>
|
---|
| 247 | <parameter>--disable-multilib</parameter>: This parameter ensures
|
---|
| 248 | that files are created for the specific architecture of your computer.
|
---|
| 249 | </para>
|
---|
[7cadfea] | 250 |
|
---|
[2d488eb] | 251 | <para>
|
---|
[fa200b8] | 252 | <parameter>--with-system-zlib</parameter>: Uses the system
|
---|
[2d488eb] | 253 | <application>zlib</application> instead of the bundled one.
|
---|
| 254 | <application>zlib</application> is used for compressing
|
---|
| 255 | and uncompressing <application>GCC</application>'s intermediate
|
---|
| 256 | language in LTO (Link Time Optimization) object files.
|
---|
| 257 | </para>
|
---|
[034eda7] | 258 |
|
---|
[800c9c3] | 259 | <para>
|
---|
[2d488eb] | 260 | <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++</parameter>:
|
---|
| 261 | This command identifies which languages to build. You may modify
|
---|
| 262 | this command to remove undesired languages.
|
---|
| 263 | </para>
|
---|
| 264 |
|
---|
[ae0673a] | 265 | <para>
|
---|
[0e64979] | 266 | <option>--with-default-libstdcxx-abi=gcc4-compatible</option>: Use this
|
---|
| 267 | switch if you are upgrading from a <application>GCC</application>
|
---|
| 268 | version prior to 5.1.0, and you do not want to recompile all the
|
---|
| 269 | libraries written in C++.
|
---|
[ae0673a] | 270 | </para>
|
---|
| 271 |
|
---|
[2d488eb] | 272 | <para>
|
---|
| 273 | <command>ulimit -s 32768</command>: This command prevents several
|
---|
| 274 | tests from running out of stack space.
|
---|
| 275 | </para>
|
---|
| 276 |
|
---|
| 277 | <para>
|
---|
| 278 | <command>make -k check</command>: This command runs the test suite
|
---|
| 279 | without stopping if any errors are encountered.
|
---|
| 280 | </para>
|
---|
| 281 |
|
---|
| 282 | <para>
|
---|
[0e64979] | 283 | <command>../contrib/test_summary</command>: This
|
---|
[2d488eb] | 284 | command will produce a summary of the test suite results. You can append
|
---|
| 285 | <command>| grep -A7 Summ</command> to the command to produce an even more
|
---|
| 286 | condensed version of the summary. You may also wish to redirect the output
|
---|
| 287 | to a file for review and comparison later on.
|
---|
| 288 | </para>
|
---|
| 289 |
|
---|
| 290 | <para>
|
---|
| 291 | <command>mv -v /usr/lib/*gdb.py ...</command>: The installation
|
---|
| 292 | stage puts some files used by <application>gdb</application> under the
|
---|
| 293 | <filename class="directory">/usr/lib</filename> directory. This generates
|
---|
| 294 | spurious error messages when performing <command>ldconfig</command>. This
|
---|
| 295 | command moves the files to another location.
|
---|
| 296 | </para>
|
---|
| 297 |
|
---|
| 298 | <para>
|
---|
| 299 | <command>chown -v -R root:root /usr/lib/gcc/*linux-gnu/...</command>:
|
---|
| 300 | If the package is built by a user other than root, the ownership of the
|
---|
| 301 | installed <filename class="directory">include</filename> directory (and
|
---|
| 302 | its content) will be incorrect. This command changes the ownership to the
|
---|
| 303 | <systemitem class="username">root</systemitem> user and group.
|
---|
| 304 | </para>
|
---|
[034eda7] | 305 |
|
---|
[70e3220] | 306 | </sect2>
|
---|
| 307 |
|
---|
| 308 | <sect2 role="content">
|
---|
| 309 | <title>Contents</title>
|
---|
| 310 |
|
---|
[ae0673a] | 311 | <para>
|
---|
| 312 | Some program and library names and descriptions are not listed here,
|
---|
| 313 | but can be found at
|
---|
| 314 | <ulink url="&lfs-root;/chapter06/gcc.html#contents-gcc"/> as they were
|
---|
| 315 | initially installed during the building of LFS.
|
---|
| 316 | </para>
|
---|
[2d488eb] | 317 |
|
---|
[70e3220] | 318 | <segmentedlist>
|
---|
| 319 | <segtitle>Installed Programs</segtitle>
|
---|
| 320 | <segtitle>Installed Libraries</segtitle>
|
---|
| 321 | <segtitle>Installed Directories</segtitle>
|
---|
| 322 |
|
---|
| 323 | <seglistitem>
|
---|
[7cadfea] | 324 | <seg>
|
---|
[87532434] | 325 | gccgo, go, gofmt and gfortran, hard-linked to architecture specific
|
---|
| 326 | names
|
---|
[7cadfea] | 327 | </seg>
|
---|
| 328 | <seg>
|
---|
[d7d743f0] | 329 | libgfortran.{so,a},
|
---|
| 330 | libgo.{so,a}, libgobegin.a, libgolibbegin.a, libnetgo.a,
|
---|
| 331 | libobjc.{so,a}, and numerous other run-time libraries and executables
|
---|
[7cadfea] | 332 | </seg>
|
---|
| 333 | <seg>
|
---|
[b4c31a6] | 334 | /usr/lib/go/&gcc-version;
|
---|
[7cadfea] | 335 | </seg>
|
---|
[70e3220] | 336 | </seglistitem>
|
---|
| 337 | </segmentedlist>
|
---|
| 338 |
|
---|
| 339 | <variablelist>
|
---|
| 340 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 341 | <?dbfo list-presentation="list"?>
|
---|
| 342 | <?dbhtml list-presentation="table"?>
|
---|
| 343 |
|
---|
[034eda7] | 344 | <varlistentry id="gccgo">
|
---|
| 345 | <term><command>gccgo</command></term>
|
---|
| 346 | <listitem>
|
---|
[ae0673a] | 347 | <para>
|
---|
[5b55f9b3] | 348 | is a GCC-based compiler for the <application>Go</application>
|
---|
| 349 | language.
|
---|
[ae0673a] | 350 | </para>
|
---|
[034eda7] | 351 | <indexterm zone="gcc gccgo">
|
---|
| 352 | <primary sortas="b-gccgo">gccgo</primary>
|
---|
[70e3220] | 353 | </indexterm>
|
---|
| 354 | </listitem>
|
---|
| 355 | </varlistentry>
|
---|
| 356 |
|
---|
[87532434] | 357 | <varlistentry id="go">
|
---|
| 358 | <term><command>go</command></term>
|
---|
| 359 | <listitem>
|
---|
| 360 | <para>
|
---|
| 361 | is a tool for managing <application>Go</application> source code.
|
---|
| 362 | </para>
|
---|
| 363 | <indexterm zone="gcc go">
|
---|
| 364 | <primary sortas="b-go">go</primary>
|
---|
| 365 | </indexterm>
|
---|
| 366 | </listitem>
|
---|
| 367 | </varlistentry>
|
---|
| 368 |
|
---|
| 369 | <varlistentry id="gofmt">
|
---|
| 370 | <term><command>gofmt</command></term>
|
---|
| 371 | <listitem>
|
---|
| 372 | <para>
|
---|
| 373 | is a tool for formatting <application>Go</application> source code.
|
---|
| 374 | </para>
|
---|
| 375 | <indexterm zone="gcc gofmt">
|
---|
| 376 | <primary sortas="b-gofmt">gofmt</primary>
|
---|
| 377 | </indexterm>
|
---|
| 378 | </listitem>
|
---|
| 379 | </varlistentry>
|
---|
| 380 |
|
---|
[800c9c3] | 381 | <varlistentry id="gfortran">
|
---|
| 382 | <term><command>gfortran</command></term>
|
---|
| 383 | <listitem>
|
---|
[ae0673a] | 384 | <para>
|
---|
| 385 | is a GCC-based compiler for the <application>Fortran</application>
|
---|
| 386 | language.
|
---|
| 387 | </para>
|
---|
[800c9c3] | 388 | <indexterm zone="gcc gfortran">
|
---|
| 389 | <primary sortas="b-gfortran">gfortran</primary>
|
---|
| 390 | </indexterm>
|
---|
| 391 | </listitem>
|
---|
| 392 | </varlistentry>
|
---|
| 393 |
|
---|
[70e3220] | 394 | </variablelist>
|
---|
| 395 |
|
---|
| 396 | </sect2>
|
---|
[1a686a1] | 397 |
|
---|
| 398 | </sect1>
|
---|