source: chapter05/gcc-pass1.xml@ dfe9593

xry111/arm64 xry111/arm64-12.0
Last change on this file since dfe9593 was dfe9593, checked in by Xi Ruoyao <xry111@…>, 17 months ago

Merge remote-tracking branch 'origin/trunk' into xry111/arm64

  • Property mode set to 100644
File size: 8.1 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" 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 ARM64 hosts, set the default directory name for
66 64-bit libraries to <quote>lib</quote>:</para>
67
68<screen><userinput remap="pre">sed -e '/lp64=/s/lib64/lib/' \
69 -i.orig gcc/config/aarch64/t-aarch64-linux</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>Prepare GCC for compilation:</para>
78
79<screen><userinput remap="configure">../configure \
80 --target=$LFS_TGT \
81 --prefix=$LFS/tools \
82 --with-glibc-version=&glibc-version; \
83 --with-sysroot=$LFS \
84 --with-newlib \
85 --without-headers \
86 --enable-default-pie \
87 --enable-default-ssp \
88 --disable-nls \
89 --disable-shared \
90 --disable-multilib \
91 --disable-threads \
92 --disable-libatomic \
93 --disable-libgomp \
94 --disable-libquadmath \
95 --disable-libssp \
96 --disable-libvtv \
97 --disable-libstdcxx \
98 --enable-languages=c,c++</userinput></screen>
99 <variablelist>
100 <title>The meaning of the configure options:</title>
101
102 <varlistentry>
103 <term><parameter>--with-glibc-version=&glibc-version;</parameter></term>
104 <listitem>
105 <para>This option specifies the version of Glibc which will be
106 used on the target. It is not relevant to the libc of the host
107 distro because everything compiled by pass1 GCC will run in the
108 chroot environment, which is isolated from libc of the host
109 distro.</para>
110 </listitem>
111 </varlistentry>
112
113 <varlistentry>
114 <term><parameter>--with-newlib</parameter></term>
115 <listitem>
116 <para>Since a working C library is not yet available, this ensures
117 that the inhibit_libc constant is defined when building libgcc. This prevents
118 the compiling of any code that requires libc support.</para>
119 </listitem>
120 </varlistentry>
121
122 <varlistentry>
123 <term><parameter>--without-headers</parameter></term>
124 <listitem>
125 <para>When creating a complete cross-compiler, GCC requires
126 standard headers compatible with the target system. For our
127 purposes these headers will not be needed. This switch prevents
128 GCC from looking for them.</para>
129 </listitem>
130 </varlistentry>
131
132 <varlistentry>
133 <term><parameter>--enable-default-pie and
134 --enable-default-ssp</parameter></term>
135 <listitem>
136 <para>Those switches allow GCC to compile programs with
137 some hardening security features (more information on those in
138 the <xref linkend="pie-ssp-info"/> in chapter 8) by default. The
139 are not strictly needed at this stage, since the compiler will
140 only produce temporary executables. But it is cleaner to have the
141 temporary packages be as close as possible to the final ones.
142 </para>
143 </listitem>
144 </varlistentry>
145
146 <varlistentry>
147 <term><parameter>--disable-shared</parameter></term>
148 <listitem>
149 <para>This switch forces GCC to link its internal libraries
150 statically. We need this because the shared libraries require Glibc,
151 which is not yet installed on the target system.</para>
152 </listitem>
153 </varlistentry>
154
155 <varlistentry>
156 <term><parameter>--disable-multilib</parameter></term>
157 <listitem>
158 <para>On ARM64, LFS does not support a multilib configuration.</para>
159 </listitem>
160 </varlistentry>
161
162 <varlistentry>
163 <term><parameter>--disable-decimal-float, --disable-threads,
164 --disable-libatomic, --disable-libgomp,
165 --disable-libquadmath, --disable-libssp, --disable-libvtv,
166 --disable-libstdcxx</parameter></term>
167 <listitem>
168 <para>These switches disable support for the decimal floating point
169 extension, threading, libatomic, libgomp, libquadmath, libssp,
170 libvtv, and the C++ standard library respectively. These features
171 will fail to compile when building a cross-compiler and are not
172 necessary for the task of cross-compiling the temporary libc.</para>
173 </listitem>
174 </varlistentry>
175
176 <varlistentry>
177 <term><parameter>--enable-languages=c,c++</parameter></term>
178 <listitem>
179 <para>This option ensures that only the C and C++ compilers are built.
180 These are the only languages needed now.</para>
181 </listitem>
182 </varlistentry>
183
184 </variablelist>
185
186 <para>Compile GCC by running:</para>
187
188<screen><userinput remap="make">make</userinput></screen>
189
190 <para>Install the package:</para>
191
192 <screen><userinput remap="install">make install</userinput></screen>
193
194 <para>This build of GCC has installed a couple of internal system
195 headers. Normally one of them, <filename>limits.h</filename>, would in turn
196 include the corresponding system <filename>limits.h</filename> header, in
197 this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
198 time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
199 does not exist, so the internal header that has just been installed is a
200 partial, self-contained file and does not include the extended features of
201 the system header. This is adequate for building Glibc, but the full
202 internal header will be needed later. Create a full version of the internal
203 header using a command that is identical to what the GCC build system does
204 in normal circumstances:</para>
205
206<screen><userinput remap="install">cd ..
207cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
208 `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
209 </sect2>
210
211 <sect2 role="content">
212 <title/>
213
214 <para>Details on this package are located in
215 <xref linkend="contents-gcc" role="."/></para>
216
217 </sect2>
218
219</sect1>
Note: See TracBrowser for help on using the repository browser.