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