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