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