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