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