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