source: chapter05/gcc-pass1.xml@ 093c8d4b

xry111/mips64el
Last change on this file since 093c8d4b was 2469049, checked in by Xi Ruoyao <xry111@…>, 6 months ago

mips64el: gcc: Add --with-nan=2008 if needed

  • Property mode set to 100644
File size: 10.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
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" xreflabel="gcc-pass1">
9 <?dbhtml filename="gcc-pass1.html"?>
10
11 <sect1info condition="script">
12 <productname>gcc-pass1</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/2001/XInclude"
28 href="../chapter08/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-tmpp1-sbu;</seg>
37 <seg>&gcc-tmpp1-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of Cross GCC</title>
45
46 <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
47 not be included in your host distribution, they will be built with
48 GCC. Unpack each package into the GCC source directory and rename the
49 resulting directories so the GCC build procedures will automatically
50 use them:</para>
51
52 <note><para>There are frequent misunderstandings about this chapter. The
53 procedures are the same as every other chapter, as explained earlier (<xref
54 linkend='buildinstr'/>). First, extract the gcc-&gcc-version; tarball from the sources
55 directory, and then change to the directory created. Only then should you
56 proceed with the instructions below.</para></note>
57
58<screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
59mv -v mpfr-&mpfr-version; mpfr
60tar -xf ../gmp-&gmp-version;.tar.xz
61mv -v gmp-&gmp-version; gmp
62tar -xf ../mpc-&mpc-version;.tar.gz
63mv -v mpc-&mpc-version; mpc</userinput></screen>
64
65 <para>On 64-bit MIPS hosts, set the default directory name for
66 64-bit libraries to <quote>lib</quote>:</para>
67
68<screen><userinput remap="pre">sed -e 's/lib64/lib/' \
69 -i.orig gcc/config/mips/{mips.h,t-linux64}</userinput></screen>
70
71 <para>The GCC documentation recommends building GCC
72 in a dedicated build directory:</para>
73
74<screen><userinput remap="pre">mkdir -v build
75cd build</userinput></screen>
76
77 <para>Probe the NaN encoding of the CPU:</para>
78
79<screen><userinput remap="pre">cat > nan2008.c &lt;&lt; \EOF
80<literal>#include &lt;stdio.h&gt;
81int main()
82{
83 int x;
84 asm("cfc1\t%0,$31":"=r"(x));
85 return !(x &amp; 1 &lt;&lt; 18);
86}</literal>
87EOF
88gcc nan2008.c -o nan2008
89if ./nan2008; then
90 NAN_SWITCH=--with-nan=2008
91fi</userinput></screen>
92
93 <para>Prepare GCC for compilation:</para>
94
95<screen><userinput remap="configure">../configure \
96 --target=$LFS_TGT \
97 --prefix=$LFS/tools \
98 --with-arch=mips64r2 \
99 --with-glibc-version=&glibc-version; \
100 --with-sysroot=$LFS \
101 --with-newlib \
102 --without-headers \
103 --enable-default-pie \
104 --enable-default-ssp \
105 --disable-nls \
106 --disable-shared \
107 --disable-multilib \
108 --disable-threads \
109 --disable-libatomic \
110 --disable-libgomp \
111 --disable-libquadmath \
112 --disable-libssp \
113 --disable-libvtv \
114 --disable-libstdcxx \
115 --enable-languages=c,c++ \
116 $NAN_SWITCH</userinput></screen>
117 <variablelist>
118 <title>The meaning of the configure options:</title>
119
120 <varlistentry>
121 <term><parameter>--with-arch=mips64r2</parameter></term>
122 <listitem>
123 <para>Set the default value of <option>-march=</option> to
124 mips64r2. Most distros use it as the baseline for the MIPS port,
125 so we are doing the same. You may change it if your CPU is not
126 compatible with mips64r2 (for example, mips3 or mips64r6), or
127 your CPU is stronger than mips64r2 and you don't care about the
128 compatibility with mips64r2, but we've not tested any setting
129 other than mips64r2.</para>
130 </listitem>
131 </varlistentry>
132
133 <varlistentry>
134 <term><parameter>--with-glibc-version=&glibc-version;</parameter></term>
135 <listitem>
136 <para>This option specifies the version of Glibc which will be
137 used on the target. It is not relevant to the libc of the host
138 distro because everything compiled by pass1 GCC will run in the
139 chroot environment, which is isolated from libc of the host
140 distro.</para>
141 </listitem>
142 </varlistentry>
143
144 <varlistentry>
145 <term><parameter>--with-newlib</parameter></term>
146 <listitem>
147 <para>Since a working C library is not yet available, this ensures
148 that the inhibit_libc constant is defined when building libgcc. This prevents
149 the compiling of any code that requires libc support.</para>
150 </listitem>
151 </varlistentry>
152
153 <varlistentry>
154 <term><parameter>--without-headers</parameter></term>
155 <listitem>
156 <para>When creating a complete cross-compiler, GCC requires
157 standard headers compatible with the target system. For our
158 purposes these headers will not be needed. This switch prevents
159 GCC from looking for them.</para>
160 </listitem>
161 </varlistentry>
162
163 <varlistentry>
164 <term><parameter>--enable-default-pie and
165 --enable-default-ssp</parameter></term>
166 <listitem>
167 <para>Those switches allow GCC to compile programs with
168 some hardening security features (more information on those in
169 the <xref linkend="pie-ssp-info"/> in chapter 8) by default. The
170 are not strictly needed at this stage, since the compiler will
171 only produce temporary executables. But it is cleaner to have the
172 temporary packages be as close as possible to the final ones.
173 </para>
174 </listitem>
175 </varlistentry>
176
177 <varlistentry>
178 <term><parameter>--disable-shared</parameter></term>
179 <listitem>
180 <para>This switch forces GCC to link its internal libraries
181 statically. We need this because the shared libraries require Glibc,
182 which is not yet installed on the target system.</para>
183 </listitem>
184 </varlistentry>
185
186 <varlistentry>
187 <term><parameter>--disable-multilib</parameter></term>
188 <listitem>
189 <para>On 64-bit MIPS, LFS does not support a multilib configuration.</para>
190 </listitem>
191 </varlistentry>
192
193 <varlistentry>
194 <term><parameter>--disable-threads,
195 --disable-libatomic, --disable-libgomp,
196 --disable-libquadmath, --disable-libssp, --disable-libvtv,
197 --disable-libstdcxx</parameter></term>
198 <listitem>
199 <para>These switches disable support for
200 threading, libatomic, libgomp, libquadmath, libssp,
201 libvtv, and the C++ standard library respectively. These features
202 may fail to compile when building a cross-compiler and are not
203 necessary for the task of cross-compiling the temporary libc.</para>
204 </listitem>
205 </varlistentry>
206
207 <varlistentry>
208 <term><parameter>--enable-languages=c,c++</parameter></term>
209 <listitem>
210 <para>This option ensures that only the C and C++ compilers are built.
211 These are the only languages needed now.</para>
212 </listitem>
213 </varlistentry>
214
215 <varlistentry>
216 <term><parameter>$NAN_SWITCH</parameter></term>
217 <listitem>
218 <para>If the CPU encodes NaN (Not a Number) values following
219 IEEE 754-2008 (indicated by the 16th bit of FCSR), this variable
220 will be set to <option>--with-nan=2008</option> so GCC will be
221 configured to use the IEEE 754-2008 encoding for NaN values as
222 the default. If this option is not properly set to match the CPU,
223 many Glibc and Python tests will fail because of the wrong NaN
224 encoding.</para>
225 </listitem>
226 </varlistentry>
227
228 </variablelist>
229
230 <para>Compile GCC by running:</para>
231
232<screen><userinput remap="make">make</userinput></screen>
233
234 <para>Install the package:</para>
235
236 <screen><userinput remap="install">make install</userinput></screen>
237
238 <para>This build of GCC has installed a couple of internal system
239 headers. Normally one of them, <filename>limits.h</filename>, would in turn
240 include the corresponding system <filename>limits.h</filename> header, in
241 this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
242 time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
243 does not exist, so the internal header that has just been installed is a
244 partial, self-contained file and does not include the extended features of
245 the system header. This is adequate for building Glibc, but the full
246 internal header will be needed later. Create a full version of the internal
247 header using a command that is identical to what the GCC build system does
248 in normal circumstances:</para>
249
250 <note>
251 <para>The command below shows an example of nested command substitution
252 using two methods: backquotes and a <literal>$()</literal> construct.
253 It could be rewritten using the same method for both substitutions,
254 but is shown this way to demonstrate how they can be mixed. Generally
255 the <literal>$()</literal> method is preferred.</para>
256 </note>
257
258<screen><userinput remap="install">cd ..
259cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
260 `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include/limits.h</userinput></screen>
261 </sect2>
262
263 <sect2 role="content">
264 <title/>
265
266 <para>Details on this package are located in
267 <xref linkend="contents-gcc" role="."/></para>
268
269 </sect2>
270
271</sect1>
Note: See TracBrowser for help on using the repository browser.