source: chapter05/gcc-pass1.xml@ a3e320b9

Last change on this file since a3e320b9 was c11bcb7, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Merged r8366 from trunk.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/jh/BOOK@8367 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 6.8 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-tools-gcc-pass1" role="wrap">
9 <?dbhtml filename="gcc-pass1.html"?>
10
11 <sect1info condition="script">
12 <productname>gcc</productname>
13 <productnumber>&gcc-version;</productnumber>
14 <address>&gcc-url;</address>
15 </sect1info>
16
17 <title>GCC-&gcc-version; - Pass 1</title>
18
19 <indexterm zone="ch-tools-gcc-pass1">
20 <primary sortas="a-GCC">GCC</primary>
21 <secondary>tools, pass 1</secondary>
22 </indexterm>
23
24 <sect2 role="package">
25 <title/>
26
27 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
28 href="../chapter06/gcc.xml"
29 xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
30
31 <segmentedlist>
32 <segtitle>&buildtime;</segtitle>
33 <segtitle>&diskspace;</segtitle>
34
35 <seglistitem>
36 <seg>&gcc-ch5p1-sbu;</seg>
37 <seg>&gcc-ch5p1-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of GCC</title>
45
46 <para>The GCC documentation recommends building GCC outside of the
47 source directory in a dedicated build directory:</para>
48
49<screen><userinput>mkdir -v ../gcc-build
50cd ../gcc-build</userinput></screen>
51
52 <para>Set the --with-arch flag if the machine is x86:</para>
53
54<screen><userinput>test $(uname -m | grep i?86) &amp;&amp; WITHARCH="--with-arch=i486"</userinput></screen>
55
56 <para>Prepare GCC for compilation:</para>
57
58<screen><userinput>CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \
59 --with-local-prefix=/tools --disable-nls --disable-shared \
60 --enable-languages=c --disable-multilib \
61 $WITHARCH
62unset WITHARCH</userinput></screen>
63
64 <variablelist>
65 <title>The meaning of the configure options:</title>
66
67 <varlistentry>
68 <term><envar>CC="gcc -B/usr/bin/"</envar></term>
69 <listitem>
70 <para>This forces <command>gcc</command> to prefer the linker from
71 the host in <filename class="directory">/usr/bin</filename>. This
72 is necessary on some hosts where the new <command>ld</command>
73 built in the previous section is not compatible with the host's
74 <command>gcc</command>.</para>
75 </listitem>
76 </varlistentry>
77
78 <varlistentry>
79 <term><parameter>--with-local-prefix=/tools</parameter></term>
80 <listitem>
81 <para>The purpose of this switch is to remove <filename
82 class="directory">/usr/local/include</filename> from
83 <command>gcc</command>'s include search path. This is not
84 absolutely essential, however, it helps to minimize the
85 influence of the host system.</para>
86 </listitem>
87 </varlistentry>
88
89 <varlistentry>
90 <term><parameter>--disable-shared</parameter></term>
91 <listitem>
92 <para>This forces gcc to link its internal libraries statically. We do this
93 to avoid possible issues with the host system.</para>
94 </listitem>
95 </varlistentry>
96
97 <varlistentry>
98 <term><parameter>--enable-languages=c</parameter></term>
99 <listitem>
100 <para>This option ensures that only the C compiler is built.</para>
101 </listitem>
102 </varlistentry>
103
104 <varlistentry>
105 <term><parameter>--disable-multilib</parameter></term>
106 <listitem>
107 <para>We currently only want to build support for 64-bit libraries.</para>
108 </listitem>
109 </varlistentry>
110
111 <varlistentry>
112 <term><parameter>--with-arch=i486</parameter></term>
113 <listitem>
114 <para>On x86 machines Glibc-&glibc-version; needs to be built for a
115 minimum architecture of <quote>i486</quote>. In fact, Glibc developers suggest
116 setting the compiler flag <parameter>-march=i486</parameter> when compiling it.
117 However, by using the above parameter for the GCC build, we can set a default
118 value for <parameter>-march</parameter> at the compiler level, ensuring that
119 the entire system is built consistently, i.e., for the same cpu-type.
120 Of course, values greater or more specific than <quote>i486</quote> could be
121 used. See <command>man gcc</command> for other acceptable cpu-types.
122 Keep in mind that using an incompatible cpu-type for the machine will result
123 in breakage. The advantage of <quote>i486</quote> is that it is a generic
124 option and will work for all modern x86 machines.</para>
125 </listitem>
126 </varlistentry>
127
128 </variablelist>
129
130 <para>The following command will compile GCC not once, but several times. It
131 uses the programs compiled in a first round to compile itself a second time,
132 and then again a third time. It then compares these second and third compiles
133 to make sure it can reproduce itself flawlessly. This is called
134 <quote>bootstrapping</quote>. Building GCC in this way ensures that it was
135 compiled correctly and is now the default configuration for the released
136 package. Continue with compiling by running:</para>
137
138<screen><userinput>make</userinput></screen>
139
140 <para>Compilation is now complete. At this point, the test suite would
141 normally be run, but, as mentioned before, the test suite framework is
142 not in place yet. The benefits of running the tests at this point
143 are minimal since the programs from this first pass will soon be
144 replaced.</para>
145
146 <para>Install the package:</para>
147
148<screen><userinput>make install</userinput></screen>
149
150 <para>Using <command>--disable-shared</command> means that the file
151 <filename class="libraryfile">libgcc_eh.a</filename>
152 isn't created and installed. The next package, Glibc, depends on this
153 library as it uses <command>-lgcc_eh</command> within its build system.
154 We can satisfy that dependency by creating a symlink to
155 <filename class="libraryfile">libgcc.a</filename>, since that file will
156 end up containing the objects normally contained in
157 <filename class="libraryfile">libgcc_eh.a</filename>.</para>
158
159<screen><userinput>ln -vs libgcc.a `gcc -print-libgcc-file-name | \
160 sed 's/libgcc/&amp;_eh/'`</userinput></screen>
161
162 <para>As a finishing touch, create a symlink. Many programs and scripts
163 run <command>cc</command> instead of <command>gcc</command>, which is
164 used to keep programs generic and therefore usable on all kinds of UNIX
165 systems where the GNU C compiler is not always installed. Running
166 <command>cc</command> leaves the system administrator free to decide
167 which C compiler to install:</para>
168
169<screen><userinput>ln -vs gcc /tools/bin/cc</userinput></screen>
170
171 </sect2>
172
173 <sect2 role="content">
174 <title/>
175
176 <para>Details on this package are located in
177 <xref linkend="contents-gcc" role="."/></para>
178
179 </sect2>
180
181</sect1>
Note: See TracBrowser for help on using the repository browser.