[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">
|
---|
[4879171] | 9 | <!ENTITY gcc-md5sum "fddf71348546af523353bd43d34919c1">
|
---|
[eb631ac] | 10 | <!ENTITY gcc-size "86 MB">
|
---|
[4879171] | 11 | <!ENTITY gcc-buildsize "5.1 GB">
|
---|
| 12 | <!ENTITY gcc-time "145 SBU">
|
---|
[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 |
|
---|
[c193fbe] | 41 | &lfs76_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>
|
---|
| 79 |
|
---|
[57105fd] | 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>
|
---|
[57105fd] | 89 |
|
---|
[70e3220] | 90 | <bridgehead renderas="sect3">GCC Dependencies</bridgehead>
|
---|
| 91 |
|
---|
[7cadfea] | 92 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
| 93 | <para role="recommended">
|
---|
[eb631ac] | 94 | <xref linkend="dejagnu"/>, for tests
|
---|
[7cadfea] | 95 | </para>
|
---|
| 96 |
|
---|
[1039de3] | 97 | <para condition="html" role="usernotes">User Notes:
|
---|
| 98 | <ulink url="&blfs-wiki;/gcc"/></para>
|
---|
| 99 |
|
---|
[70e3220] | 100 | </sect2>
|
---|
[034eda7] | 101 |
|
---|
[70e3220] | 102 | <sect2 role="installation">
|
---|
| 103 | <title>Installation of GCC</title>
|
---|
| 104 |
|
---|
| 105 | <important>
|
---|
[2d488eb] | 106 | <para>Even if you specify only languages other than C and C++ to the
|
---|
| 107 | <command>./configure</command> command below, the
|
---|
| 108 | installation process will overwrite your existing
|
---|
| 109 | <application>GCC</application> C and C++ compilers and libraries.
|
---|
| 110 | Having the <application>Tcl</application>,
|
---|
| 111 | <application>Expect</application> and <application>DejaGnu</application>
|
---|
| 112 | packages installed before beginning the build is highly recommended so
|
---|
| 113 | you can run the full suite of tests.</para>
|
---|
[70e3220] | 114 |
|
---|
[8092658] | 115 | <para>Do not continue with the <command>make install</command> command
|
---|
[fa0e8e65] | 116 | until you are confident the build was successful. You can compare your
|
---|
[d14cd9a1] | 117 | test results with those found at <ulink
|
---|
| 118 | url="http://gcc.gnu.org/ml/gcc-testresults/"/>. You may also want to
|
---|
| 119 | refer to the information found in the <application>GCC</application>
|
---|
| 120 | section of Chapter 6 in the LFS book (<ulink
|
---|
| 121 | url="&lfs-root;/chapter06/gcc.html"/>).</para>
|
---|
[70e3220] | 122 | </important>
|
---|
| 123 |
|
---|
[2d488eb] | 124 | <para>The instructions below are intentionally performing a
|
---|
| 125 | <quote>bootstrap</quote> process. Bootstrapping is needed for robustness
|
---|
| 126 | and is highly recommended when upgrading the compilers version. To disable
|
---|
| 127 | bootstrap anyways, add <parameter>--disable-bootstrap</parameter> to the
|
---|
[7cadfea] | 128 | <command>./configure</command> options below.</para>
|
---|
| 129 |
|
---|
[aedf4d7] | 130 | <para>As in LFS, fix a problem identified upstream:</para>
|
---|
| 131 |
|
---|
| 132 | <screen><userinput>sed -i 's/if \((code.*))\)/if (\1 \&\& \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>
|
---|
| 133 |
|
---|
[7cadfea] | 134 | <para>Install <application>GCC</application> by running the
|
---|
| 135 | following commands:</para>
|
---|
[d02add0] | 136 |
|
---|
[57105fd] | 137 | <screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-upstream_fixes-1.patch &&
|
---|
| 138 | mkdir ../gcc-build &&
|
---|
[2d488eb] | 139 | cd ../gcc-build &&
|
---|
| 140 |
|
---|
| 141 | ../gcc-&gcc-version;/configure \
|
---|
| 142 | --prefix=/usr \
|
---|
| 143 | --disable-multilib \
|
---|
| 144 | --with-system-zlib \
|
---|
| 145 | --enable-languages=c,c++,fortran,go,objc,obj-c++ &&
|
---|
[7cadfea] | 146 | make</userinput></screen>
|
---|
[5512e64] | 147 |
|
---|
[7cadfea] | 148 | <para>If you have installed additional packages such as
|
---|
| 149 | <application>Valgrind</application> and <application>GDB</application>,
|
---|
| 150 | the <application>GCC</application> part of the testsuite will run more
|
---|
| 151 | tests than in LFS. Some of those will report FAIL and others XPASS
|
---|
| 152 | (pass when expected to FAIL). To run the tests, issue:</para>
|
---|
[d3757f1c] | 153 |
|
---|
[7cadfea] | 154 | <screen><userinput>ulimit -s 32768 &&
|
---|
[b10cfc81] | 155 | make -k check</userinput></screen>
|
---|
| 156 | <!-- The command above may error out, so using && may prevent the summary
|
---|
| 157 | to be run. -->
|
---|
| 158 |
|
---|
| 159 | <para>The tests are very long, and the results may be hard to find in the
|
---|
[2d488eb] | 160 | logs, specially if you use parallel jobs with make. You can get a summary
|
---|
[b10cfc81] | 161 | of the tests with:</para>
|
---|
[5512e64] | 162 |
|
---|
[b10cfc81] | 163 | <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
|
---|
[8c9ec303] | 164 |
|
---|
[70e3220] | 165 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
[8c9ec303] | 166 |
|
---|
[70e3220] | 167 | <screen role="root"><userinput>make install &&
|
---|
[5512e64] | 168 |
|
---|
[7cadfea] | 169 | mkdir -pv /usr/share/gdb/auto-load/usr/lib &&
|
---|
| 170 | mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &&
|
---|
| 171 |
|
---|
[38485e5c] | 172 | chown -v -R root:root \
|
---|
[2d488eb] | 173 | /usr/lib/gcc/*linux-gnu/&gcc-version;/include{,-fixed}</userinput></screen>
|
---|
[f182eed] | 174 |
|
---|
[2d488eb] | 175 | <para>Some packages expect to find the C preprocessor in
|
---|
| 176 | <filename class="directory">/lib</filename> or may refer to the C compiler
|
---|
| 177 | under the name <command>cc</command>. The following symbolic links are not
|
---|
| 178 | needed if you have followed the LFS instructions, since they
|
---|
| 179 | have been already created. If you do not have them on your system, issue
|
---|
| 180 | as the <systemitem class="username">root</systemitem> user:</para>
|
---|
[70e3220] | 181 |
|
---|
[2d488eb] | 182 | <screen role="root"><userinput>ln -v -sf ../usr/bin/cpp /lib &&
|
---|
| 183 | ln -v -sf gcc /usr/bin/cc</userinput></screen>
|
---|
[034eda7] | 184 |
|
---|
[70e3220] | 185 | </sect2>
|
---|
| 186 |
|
---|
| 187 | <sect2 role="commands">
|
---|
| 188 | <title>Command Explanations</title>
|
---|
| 189 |
|
---|
[57105fd] | 190 | <para>
|
---|
| 191 | <command>patch ... gcc-&gcc-version;-upstream_fixes-1.patch</command>:
|
---|
| 192 | This patch corrects bugs in the C++ compiler, which lead to
|
---|
| 193 | segmentation faults in some cases.
|
---|
| 194 | </para>
|
---|
| 195 |
|
---|
[2d488eb] | 196 | <para>
|
---|
| 197 | <command>mkdir ../gcc-build; cd ../gcc-build</command>: The
|
---|
| 198 | <application>GCC</application> documentation recommends
|
---|
| 199 | building the package in a dedicated build directory.
|
---|
| 200 | </para>
|
---|
[70e3220] | 201 |
|
---|
[2d488eb] | 202 | <para>
|
---|
| 203 | <parameter>--disable-multilib</parameter>: This parameter ensures
|
---|
| 204 | that files are created for the specific architecture of your computer.
|
---|
| 205 | </para>
|
---|
[7cadfea] | 206 |
|
---|
[2d488eb] | 207 | <para>
|
---|
[fa200b8] | 208 | <parameter>--with-system-zlib</parameter>: Uses the system
|
---|
[2d488eb] | 209 | <application>zlib</application> instead of the bundled one.
|
---|
| 210 | <application>zlib</application> is used for compressing
|
---|
| 211 | and uncompressing <application>GCC</application>'s intermediate
|
---|
| 212 | language in LTO (Link Time Optimization) object files.
|
---|
| 213 | </para>
|
---|
[034eda7] | 214 |
|
---|
[800c9c3] | 215 | <para>
|
---|
[2d488eb] | 216 | <parameter>--enable-languages=c,c++,fortran,go,objc,obj-c++</parameter>:
|
---|
| 217 | This command identifies which languages to build. You may modify
|
---|
| 218 | this command to remove undesired languages.
|
---|
| 219 | </para>
|
---|
| 220 |
|
---|
| 221 | <para>
|
---|
| 222 | <command>ulimit -s 32768</command>: This command prevents several
|
---|
| 223 | tests from running out of stack space.
|
---|
| 224 | </para>
|
---|
| 225 |
|
---|
| 226 | <para>
|
---|
| 227 | <command>make -k check</command>: This command runs the test suite
|
---|
| 228 | without stopping if any errors are encountered.
|
---|
| 229 | </para>
|
---|
| 230 |
|
---|
| 231 | <para>
|
---|
| 232 | <command>../gcc-&gcc-version;/contrib/test_summary</command>: This
|
---|
| 233 | command will produce a summary of the test suite results. You can append
|
---|
| 234 | <command>| grep -A7 Summ</command> to the command to produce an even more
|
---|
| 235 | condensed version of the summary. You may also wish to redirect the output
|
---|
| 236 | to a file for review and comparison later on.
|
---|
| 237 | </para>
|
---|
| 238 |
|
---|
| 239 | <para>
|
---|
| 240 | <command>mv -v /usr/lib/*gdb.py ...</command>: The installation
|
---|
| 241 | stage puts some files used by <application>gdb</application> under the
|
---|
| 242 | <filename class="directory">/usr/lib</filename> directory. This generates
|
---|
| 243 | spurious error messages when performing <command>ldconfig</command>. This
|
---|
| 244 | command moves the files to another location.
|
---|
| 245 | </para>
|
---|
| 246 |
|
---|
| 247 | <para>
|
---|
| 248 | <command>chown -v -R root:root /usr/lib/gcc/*linux-gnu/...</command>:
|
---|
| 249 | If the package is built by a user other than root, the ownership of the
|
---|
| 250 | installed <filename class="directory">include</filename> directory (and
|
---|
| 251 | its content) will be incorrect. This command changes the ownership to the
|
---|
| 252 | <systemitem class="username">root</systemitem> user and group.
|
---|
| 253 | </para>
|
---|
[034eda7] | 254 |
|
---|
[70e3220] | 255 | </sect2>
|
---|
| 256 |
|
---|
| 257 | <sect2 role="content">
|
---|
| 258 | <title>Contents</title>
|
---|
| 259 |
|
---|
[2d488eb] | 260 | <para>Some program and library names and descriptions are not listed here,
|
---|
| 261 | but can be found at
|
---|
| 262 | <ulink url="&lfs-root;/chapter06/gcc.html#contents-gcc"/> as they were
|
---|
| 263 | initially installed during the building of LFS.</para>
|
---|
| 264 |
|
---|
[70e3220] | 265 | <segmentedlist>
|
---|
| 266 | <segtitle>Installed Programs</segtitle>
|
---|
| 267 | <segtitle>Installed Libraries</segtitle>
|
---|
| 268 | <segtitle>Installed Directories</segtitle>
|
---|
| 269 |
|
---|
| 270 | <seglistitem>
|
---|
[7cadfea] | 271 | <seg>
|
---|
[2d488eb] | 272 | gccgo and gfortran,
|
---|
| 273 | hard-linked to architecture specific names
|
---|
[7cadfea] | 274 | </seg>
|
---|
| 275 | <seg>
|
---|
[2d488eb] | 276 | libgfortran.{so,a},
|
---|
| 277 | libgo.{so,a}, libgobegin.a, libobjc.{so,a}, and numerous other
|
---|
| 278 | run-time libraries and executables in <filename class="directory">
|
---|
| 279 | /usr/lib/gcc</filename> and <filename class="directory">
|
---|
| 280 | /usr/libexec/gcc</filename>
|
---|
[7cadfea] | 281 | </seg>
|
---|
| 282 | <seg>
|
---|
[2d488eb] | 283 | /usr/lib/gcc/<arch-triplet>/&gcc-version;/include/objc and
|
---|
| 284 | /usr/lib/go
|
---|
[7cadfea] | 285 | </seg>
|
---|
[70e3220] | 286 | </seglistitem>
|
---|
| 287 | </segmentedlist>
|
---|
| 288 |
|
---|
| 289 | <variablelist>
|
---|
| 290 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 291 | <?dbfo list-presentation="list"?>
|
---|
| 292 | <?dbhtml list-presentation="table"?>
|
---|
| 293 |
|
---|
[034eda7] | 294 | <varlistentry id="gccgo">
|
---|
| 295 | <term><command>gccgo</command></term>
|
---|
| 296 | <listitem>
|
---|
| 297 | <para>is a GCC-based compiler for the
|
---|
| 298 | <application>Go</application> language.</para>
|
---|
| 299 | <indexterm zone="gcc gccgo">
|
---|
| 300 | <primary sortas="b-gccgo">gccgo</primary>
|
---|
[70e3220] | 301 | </indexterm>
|
---|
| 302 | </listitem>
|
---|
| 303 | </varlistentry>
|
---|
| 304 |
|
---|
[800c9c3] | 305 | <varlistentry id="gfortran">
|
---|
| 306 | <term><command>gfortran</command></term>
|
---|
| 307 | <listitem>
|
---|
[2d488eb] | 308 | <para>is a GCC-based compiler for the
|
---|
| 309 | <application>Fortran</application> language.</para>
|
---|
[800c9c3] | 310 | <indexterm zone="gcc gfortran">
|
---|
| 311 | <primary sortas="b-gfortran">gfortran</primary>
|
---|
| 312 | </indexterm>
|
---|
| 313 | </listitem>
|
---|
| 314 | </varlistentry>
|
---|
| 315 |
|
---|
[70e3220] | 316 | </variablelist>
|
---|
| 317 |
|
---|
| 318 | </sect2>
|
---|
[1a686a1] | 319 |
|
---|
| 320 | </sect1>
|
---|