[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
[9652249] | 6 | <sect1 id="ch-tools-gcc-pass1" role="wrap">
|
---|
[673b0d8] | 7 | <title>GCC-&gcc-version; - Pass 1</title>
|
---|
| 8 | <?dbhtml filename="gcc-pass1.html"?>
|
---|
[bc82645e] | 9 |
|
---|
[673b0d8] | 10 | <indexterm zone="ch-tools-gcc-pass1">
|
---|
| 11 | <primary sortas="a-GCC">GCC</primary>
|
---|
| 12 | <secondary>tools, pass 1</secondary></indexterm>
|
---|
[bc82645e] | 13 |
|
---|
[9652249] | 14 | <sect2 role="package"><title/>
|
---|
| 15 | <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
|
---|
[5888299] | 16 |
|
---|
[9652249] | 17 | <segmentedlist>
|
---|
| 18 | <segtitle>&buildtime;</segtitle>
|
---|
| 19 | <segtitle>&diskspace;</segtitle>
|
---|
| 20 | <seglistitem><seg>4.4 SBU</seg><seg>300 MB</seg></seglistitem>
|
---|
| 21 | </segmentedlist>
|
---|
[673b0d8] | 22 |
|
---|
[9652249] | 23 | <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
|
---|
[73aedd1d] | 24 |
|
---|
[9652249] | 25 | </sect2>
|
---|
[73aedd1d] | 26 |
|
---|
[9652249] | 27 | <sect2 role="installation">
|
---|
[73aedd1d] | 28 | <title>Installation of GCC</title>
|
---|
| 29 |
|
---|
[ede9b9b] | 30 | <para>Unpack only the GCC-core tarball, as we won't be needing the C++ compiler
|
---|
[673b0d8] | 31 | nor the test suite here.</para>
|
---|
[73aedd1d] | 32 |
|
---|
[ede9b9b] | 33 | <para>This package is known to behave badly when you change its default
|
---|
[574b0ea] | 34 | optimization flags (including the <parameter>-march</parameter> and
|
---|
| 35 | <parameter>-mcpu</parameter> options). Therefore, if you have defined any
|
---|
[ede9b9b] | 36 | environment variables that override default optimizations, such as CFLAGS and
|
---|
[673b0d8] | 37 | CXXFLAGS, we recommend un-setting them when building GCC.</para>
|
---|
[73aedd1d] | 38 |
|
---|
| 39 | <para>The GCC documentation recommends building GCC outside of the source
|
---|
| 40 | directory in a dedicated build directory:</para>
|
---|
| 41 |
|
---|
| 42 | <screen><userinput>mkdir ../gcc-build
|
---|
| 43 | cd ../gcc-build</userinput></screen>
|
---|
| 44 |
|
---|
[d27a27b] | 45 | <para>Prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 46 |
|
---|
[673b0d8] | 47 | <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
|
---|
[9dfc02f] | 48 | --libexecdir=/tools/lib --with-local-prefix=/tools \
|
---|
| 49 | --disable-nls --enable-shared --enable-languages=c</userinput></screen>
|
---|
[73aedd1d] | 50 |
|
---|
| 51 | <para>The meaning of the configure options:</para>
|
---|
| 52 |
|
---|
[9652249] | 53 | <variablelist>
|
---|
| 54 | <varlistentry>
|
---|
[574b0ea] | 55 | <term><parameter>--with-local-prefix=/tools</parameter></term>
|
---|
| 56 | <listitem><para>The purpose of this switch is to remove <filename class="directory">/usr/local/include</filename>
|
---|
[90e3cb3] | 57 | from <command>gcc</command>'s include search path. This is not absolutely
|
---|
[73aedd1d] | 58 | essential; however, we want to try to minimize the influence of the host
|
---|
[673b0d8] | 59 | system, so this a sensible thing to do.</para></listitem>
|
---|
[9652249] | 60 | </varlistentry>
|
---|
[73aedd1d] | 61 |
|
---|
[9652249] | 62 | <varlistentry>
|
---|
[574b0ea] | 63 | <term><parameter>--enable-shared</parameter></term>
|
---|
[9652249] | 64 | <listitem><para>This switch may
|
---|
[73aedd1d] | 65 | seem counter-intuitive at first. But using it allows the building of
|
---|
| 66 | <filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
|
---|
| 67 | having <filename>libgcc_eh.a</filename> available ensures that the configure
|
---|
| 68 | script for Glibc (the next package we compile) produces the proper results.
|
---|
[574b0ea] | 69 | Note that the GCC binaries will still be linked
|
---|
| 70 | statically, as this is controlled by the <parameter>-static</parameter>
|
---|
[ede9b9b] | 71 | value of BOOT_LDFLAGS in the next step.</para></listitem>
|
---|
[9652249] | 72 | </varlistentry>
|
---|
[73aedd1d] | 73 |
|
---|
[9652249] | 74 | <varlistentry>
|
---|
[574b0ea] | 75 | <term><parameter>--enable-languages=c</parameter></term>
|
---|
[9652249] | 76 | <listitem><para>This option
|
---|
[73aedd1d] | 77 | ensures that only the C compiler is built. The option is only needed when you
|
---|
| 78 | have downloaded and unpacked the full GCC tarball.</para></listitem>
|
---|
[9652249] | 79 | </varlistentry>
|
---|
| 80 | </variablelist>
|
---|
[73aedd1d] | 81 |
|
---|
| 82 | <para>Continue with compiling the package:</para>
|
---|
| 83 |
|
---|
| 84 | <screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen>
|
---|
| 85 |
|
---|
| 86 | <para>The meaning of the make parameters:</para>
|
---|
| 87 |
|
---|
[9652249] | 88 | <variablelist>
|
---|
| 89 | <varlistentry>
|
---|
[574b0ea] | 90 | <term><parameter>BOOT_LDFLAGS="-static"</parameter></term>
|
---|
[9652249] | 91 | <listitem><para>This tells GCC to link its programs statically.</para></listitem>
|
---|
| 92 | </varlistentry>
|
---|
[73aedd1d] | 93 |
|
---|
[9652249] | 94 | <varlistentry>
|
---|
[574b0ea] | 95 | <term><parameter>bootstrap</parameter></term>
|
---|
[9652249] | 96 | <listitem><para>This target doesn't just
|
---|
[73aedd1d] | 97 | compile GCC, but compiles it several times. It uses the programs compiled in
|
---|
| 98 | a first round to compile itself a second time, and then again a third time.
|
---|
| 99 | It then compares these second and third compiles to make sure it can
|
---|
| 100 | reproduce itself flawlessly, which most probably means that it was
|
---|
| 101 | compiled correctly.</para></listitem>
|
---|
[9652249] | 102 | </varlistentry>
|
---|
| 103 | </variablelist>
|
---|
[73aedd1d] | 104 |
|
---|
[ede9b9b] | 105 | <para>Compilation is now complete, and at this point we would normally run the
|
---|
| 106 | test suite. But, as mentioned before, the test suite framework is not in place
|
---|
| 107 | yet. And there would be little point in running the tests anyhow, since the
|
---|
| 108 | programs from this first pass will soon be replaced.</para>
|
---|
[443cace] | 109 |
|
---|
[673b0d8] | 110 | <para>Now install the package:</para>
|
---|
[73aedd1d] | 111 |
|
---|
| 112 | <screen><userinput>make install</userinput></screen>
|
---|
| 113 |
|
---|
[ede9b9b] | 114 | <para>As a finishing touch we'll create a symlink. Many programs and scripts
|
---|
| 115 | run <command>cc</command> instead of <command>gcc</command>,
|
---|
[73aedd1d] | 116 | a thing meant to keep programs generic and therefore usable on all kinds of
|
---|
| 117 | Unix systems. Not everybody has the GNU C compiler installed. Simply running
|
---|
[90e3cb3] | 118 | <command>cc</command> leaves the system administrator free to decide what
|
---|
[73aedd1d] | 119 | C compiler to install, as long as there's a symlink pointing to it:</para>
|
---|
| 120 |
|
---|
[51fe215] | 121 | <screen><userinput>ln -s gcc /tools/bin/cc</userinput></screen>
|
---|
[73aedd1d] | 122 |
|
---|
| 123 | </sect2>
|
---|
[bc82645e] | 124 |
|
---|
[9652249] | 125 | <sect2 role="content"><title/>
|
---|
[5888299] | 126 | <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
|
---|
[0868461] | 127 | </sect2>
|
---|
[5888299] | 128 |
|
---|
[bc82645e] | 129 | </sect1>
|
---|