source: chapter05/gcc-pass1.xml@ d6f618b

xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1
Last change on this file since d6f618b was af800c8, checked in by Xi Ruoyao <xry111@…>, 11 months ago

loongarch: gcc: Remove GMP workaround in GCC pass 1 & 2

The workaround is not needed with GMP 6.3.0.

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