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