[3be4d97] | 1 | <sect1 id="ch-tools-gcc-pass1">
|
---|
[bc82645e] | 2 | <title>Installing GCC-&gcc-version; - Pass 1</title>
|
---|
| 3 | <?dbhtml filename="gcc-pass1.html" dir="chapter05"?>
|
---|
| 4 |
|
---|
[69276a94] | 5 | <screen>&buildtime; &gcc-time-tools-pass1;
|
---|
| 6 | &diskspace; &gcc-compsize-tools-pass1;</screen>
|
---|
[bc82645e] | 7 |
|
---|
[5888299] | 8 | <literallayout>Official download location for GCC (&gcc-version;):
|
---|
| 9 | <ulink url="ftp://ftp.gnu.org/pub/gnu/gcc/"/></literallayout>
|
---|
| 10 |
|
---|
[d0dfce4] | 11 | &aa-gcc-dep;
|
---|
[73aedd1d] | 12 |
|
---|
| 13 | <sect2><title> </title><para> </para></sect2>
|
---|
| 14 |
|
---|
| 15 | <sect2>
|
---|
| 16 | <title>Installation of GCC</title>
|
---|
| 17 |
|
---|
[ede9b9b] | 18 | <para>Unpack only the GCC-core tarball, as we won't be needing the C++ compiler
|
---|
| 19 | nor the test suite at the moment.</para>
|
---|
[73aedd1d] | 20 |
|
---|
[ede9b9b] | 21 | <para>This package is known to behave badly when you change its default
|
---|
| 22 | optimization flags (including the <emphasis>-march</emphasis> and
|
---|
| 23 | <emphasis>-mcpu</emphasis> options). Therefore, if you have defined any
|
---|
| 24 | environment variables that override default optimizations, such as CFLAGS and
|
---|
| 25 | CXXFLAGS, we recommend unsetting them when building GCC.</para>
|
---|
[73aedd1d] | 26 |
|
---|
| 27 | <para>The GCC documentation recommends building GCC outside of the source
|
---|
| 28 | directory in a dedicated build directory:</para>
|
---|
| 29 |
|
---|
| 30 | <screen><userinput>mkdir ../gcc-build
|
---|
| 31 | cd ../gcc-build</userinput></screen>
|
---|
| 32 |
|
---|
[d27a27b] | 33 | <para>Prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 34 |
|
---|
[d962702] | 35 | <screen><userinput>../&gcc-dir;/configure --prefix=/tools \
|
---|
[73aedd1d] | 36 | --with-local-prefix=/tools \
|
---|
| 37 | --disable-nls --enable-shared \
|
---|
| 38 | --enable-languages=c</userinput></screen>
|
---|
| 39 |
|
---|
| 40 | <para>The meaning of the configure options:</para>
|
---|
| 41 |
|
---|
| 42 | <itemizedlist>
|
---|
[17476c5] | 43 | <listitem><para><userinput>--with-local-prefix=/tools</userinput>: The
|
---|
[73aedd1d] | 44 | purpose of this switch is to remove <filename>/usr/local/include</filename>
|
---|
[90e3cb3] | 45 | from <command>gcc</command>'s include search path. This is not absolutely
|
---|
[73aedd1d] | 46 | essential; however, we want to try to minimize the influence of the host
|
---|
| 47 | system, thus making this a sensible thing to do.</para></listitem>
|
---|
| 48 |
|
---|
| 49 | <listitem><para><userinput>--enable-shared</userinput>: This switch may
|
---|
| 50 | seem counter-intuitive at first. But using it allows the building of
|
---|
| 51 | <filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
|
---|
| 52 | having <filename>libgcc_eh.a</filename> available ensures that the configure
|
---|
| 53 | script for Glibc (the next package we compile) produces the proper results.
|
---|
[90e3cb3] | 54 | Note that the <command>gcc</command> binaries will still be linked
|
---|
[ede9b9b] | 55 | statically, as this is controlled by the <emphasis>-static</emphasis>
|
---|
| 56 | value of BOOT_LDFLAGS in the next step.</para></listitem>
|
---|
[73aedd1d] | 57 |
|
---|
| 58 | <listitem><para><userinput>--enable-languages=c</userinput>: This option
|
---|
| 59 | ensures that only the C compiler is built. The option is only needed when you
|
---|
| 60 | have downloaded and unpacked the full GCC tarball.</para></listitem>
|
---|
| 61 | </itemizedlist>
|
---|
| 62 |
|
---|
| 63 | <para>Continue with compiling the package:</para>
|
---|
| 64 |
|
---|
| 65 | <screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen>
|
---|
| 66 |
|
---|
| 67 | <para>The meaning of the make parameters:</para>
|
---|
| 68 |
|
---|
| 69 | <itemizedlist>
|
---|
| 70 | <listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This tells
|
---|
| 71 | GCC to link its programs statically.</para></listitem>
|
---|
| 72 |
|
---|
| 73 | <listitem><para><userinput>bootstrap</userinput>: This target doesn't just
|
---|
| 74 | compile GCC, but compiles it several times. It uses the programs compiled in
|
---|
| 75 | a first round to compile itself a second time, and then again a third time.
|
---|
| 76 | It then compares these second and third compiles to make sure it can
|
---|
| 77 | reproduce itself flawlessly, which most probably means that it was
|
---|
| 78 | compiled correctly.</para></listitem>
|
---|
| 79 | </itemizedlist>
|
---|
| 80 |
|
---|
[ede9b9b] | 81 | <para>Compilation is now complete, and at this point we would normally run the
|
---|
| 82 | test suite. But, as mentioned before, the test suite framework is not in place
|
---|
| 83 | yet. And there would be little point in running the tests anyhow, since the
|
---|
| 84 | programs from this first pass will soon be replaced.</para>
|
---|
[443cace] | 85 |
|
---|
[73aedd1d] | 86 | <para>And install the package:</para>
|
---|
| 87 |
|
---|
| 88 | <screen><userinput>make install</userinput></screen>
|
---|
| 89 |
|
---|
[ede9b9b] | 90 | <para>As a finishing touch we'll create a symlink. Many programs and scripts
|
---|
| 91 | run <command>cc</command> instead of <command>gcc</command>,
|
---|
[73aedd1d] | 92 | a thing meant to keep programs generic and therefore usable on all kinds of
|
---|
| 93 | Unix systems. Not everybody has the GNU C compiler installed. Simply running
|
---|
[90e3cb3] | 94 | <command>cc</command> leaves the system administrator free to decide what
|
---|
[73aedd1d] | 95 | C compiler to install, as long as there's a symlink pointing to it:</para>
|
---|
| 96 |
|
---|
[51fe215] | 97 | <screen><userinput>ln -s gcc /tools/bin/cc</userinput></screen>
|
---|
[73aedd1d] | 98 |
|
---|
| 99 | </sect2>
|
---|
[bc82645e] | 100 |
|
---|
[5888299] | 101 | <sect2><title> </title><para> </para>
|
---|
| 102 | <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
|
---|
| 103 | <para> </para></sect2>
|
---|
| 104 |
|
---|
[bc82645e] | 105 | </sect1>
|
---|
| 106 |
|
---|