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