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-pass2" role="wrap" xreflabel="gcc-pass2">
|
---|
9 | <?dbhtml filename="gcc-pass2.html"?>
|
---|
10 |
|
---|
11 | <sect1info condition="script">
|
---|
12 | <productname>gcc-pass2</productname>
|
---|
13 | <productnumber>&gcc-version;</productnumber>
|
---|
14 | <address>&gcc-url;</address>
|
---|
15 | </sect1info>
|
---|
16 |
|
---|
17 | <title>GCC-&gcc-version; - Pass 2</title>
|
---|
18 |
|
---|
19 | <indexterm zone="ch-tools-gcc-pass2">
|
---|
20 | <primary sortas="a-GCC">GCC</primary>
|
---|
21 | <secondary>tools, pass 2</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-tmpp2-sbu;</seg>
|
---|
37 | <seg>&gcc-tmpp2-du;</seg>
|
---|
38 | </seglistitem>
|
---|
39 | </segmentedlist>
|
---|
40 |
|
---|
41 | </sect2>
|
---|
42 |
|
---|
43 | <sect2 role="installation">
|
---|
44 | <title>Installation of GCC</title>
|
---|
45 | <!--
|
---|
46 | <para>First fix a problem with the latest version of glibc:</para>
|
---|
47 |
|
---|
48 | <screen><userinput remap="pre">patch -Np1 -i ../&gcc-upstream-fixes-patch;</userinput></screen>
|
---|
49 | -->
|
---|
50 | <para>As in the first build of GCC, the GMP, MPFR, and MPC packages are
|
---|
51 | required. Unpack the tarballs and move them into the required directories:</para>
|
---|
52 |
|
---|
53 | <screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
|
---|
54 | mv -v mpfr-&mpfr-version; mpfr
|
---|
55 | tar -xf ../gmp-&gmp-version;.tar.xz
|
---|
56 | mv -v gmp-&gmp-version; gmp
|
---|
57 | tar -xf ../mpc-&mpc-version;.tar.gz
|
---|
58 | mv -v mpc-&mpc-version; mpc</userinput></screen>
|
---|
59 |
|
---|
60 | <para>Set the default directory name for
|
---|
61 | 64-bit libraries to <quote>lib</quote>:</para>
|
---|
62 |
|
---|
63 | <screen><userinput remap="pre">sed -e 's/lib64/lib/' \
|
---|
64 | -i.orig gcc/config/loongarch/{t-linux,linux.h}</userinput></screen>
|
---|
65 |
|
---|
66 | <para>Override the building rule of libgcc and libstdc++ headers, to
|
---|
67 | allow building these libraries with POSIX threads support:</para>
|
---|
68 |
|
---|
69 | <screen><userinput remap="pre">sed '/thread_header =/s/@.*@/gthr-posix.h/' \
|
---|
70 | -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in</userinput></screen>
|
---|
71 |
|
---|
72 | <para>Create a separate build directory again:</para>
|
---|
73 |
|
---|
74 | <screen><userinput remap="pre">mkdir -v build
|
---|
75 | cd build</userinput></screen>
|
---|
76 |
|
---|
77 | <para>Before starting to build GCC, remember to unset any environment
|
---|
78 | variables that override the default optimization flags.</para>
|
---|
79 |
|
---|
80 | <para>Now prepare GCC for compilation:</para>
|
---|
81 |
|
---|
82 | <screen><userinput remap="configure">../configure \
|
---|
83 | --build=$(../config.guess) \
|
---|
84 | --host=$LFS_TGT \
|
---|
85 | --target=$LFS_TGT \
|
---|
86 | LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
|
---|
87 | --prefix=/usr \
|
---|
88 | --with-build-sysroot=$LFS \
|
---|
89 | --enable-default-pie \
|
---|
90 | --enable-default-ssp \
|
---|
91 | --disable-nls \
|
---|
92 | --disable-multilib \
|
---|
93 | --disable-libatomic \
|
---|
94 | --disable-libgomp \
|
---|
95 | --disable-libquadmath \
|
---|
96 | --disable-libsanitizer \
|
---|
97 | --disable-libssp \
|
---|
98 | --disable-libvtv \
|
---|
99 | --enable-languages=c,c++</userinput></screen>
|
---|
100 |
|
---|
101 | <variablelist>
|
---|
102 | <title>The meaning of the new configure options:</title><!-- WIP -->
|
---|
103 |
|
---|
104 | <varlistentry>
|
---|
105 | <term><parameter>--with-build-sysroot=$LFS</parameter></term>
|
---|
106 | <listitem>
|
---|
107 | <para>Normally, using <parameter>--host</parameter> ensures that
|
---|
108 | a cross-compiler is used for building GCC, and that compiler knows
|
---|
109 | that it has to look for headers and libraries in <filename
|
---|
110 | class="directory">$LFS</filename>. But the build system for GCC uses
|
---|
111 | other tools, which are not aware of this location. This switch is
|
---|
112 | needed so those tools will find the needed files in <filename
|
---|
113 | class="directory">$LFS</filename>, and not on the host.</para>
|
---|
114 | </listitem>
|
---|
115 | </varlistentry>
|
---|
116 |
|
---|
117 | <varlistentry>
|
---|
118 | <term><parameter>--target=$LFS_TGT</parameter></term>
|
---|
119 | <listitem>
|
---|
120 | <para>We are cross-compiling GCC, so it's impossible to build
|
---|
121 | target libraries (<filename class="libraryfile">libgcc</filename>
|
---|
122 | and <filename class="libraryfile">libstdc++</filename>) with the
|
---|
123 | GCC binaries compiled in this pass—those binaries won't run
|
---|
124 | on the host. The GCC build system will attempt to use the host's
|
---|
125 | C and C++ compilers as a workaround by default.
|
---|
126 | Building the GCC target libraries with a different
|
---|
127 | version of GCC is not supported, so using the host's compilers may cause
|
---|
128 | the build to fail. This parameter ensures the libraries are built by GCC
|
---|
129 | pass 1.</para>
|
---|
130 | </listitem>
|
---|
131 | </varlistentry>
|
---|
132 |
|
---|
133 | <varlistentry>
|
---|
134 | <term><parameter>LDFLAGS_FOR_TARGET=...</parameter></term>
|
---|
135 | <listitem>
|
---|
136 | <para>Allow <filename class="libraryfile">libstdc++</filename> to
|
---|
137 | use the <filename class="libraryfile">libgcc</filename> being
|
---|
138 | built in this pass, instead of the previous version built in
|
---|
139 | <xref linkend='ch-tools-gcc-pass1'/>. The previous version cannot
|
---|
140 | properly support C++ exception handling because it was built
|
---|
141 | without libc support.</para>
|
---|
142 | </listitem>
|
---|
143 | </varlistentry>
|
---|
144 |
|
---|
145 | <varlistentry>
|
---|
146 | <term><parameter>--disable-libsanitizer</parameter></term>
|
---|
147 | <listitem>
|
---|
148 | <para>Disable GCC sanitizer runtime libraries. They are not
|
---|
149 | needed for the temporary installation. In
|
---|
150 | <xref linkend='ch-tools-gcc-pass1'/> it was implied by
|
---|
151 | <parameter>--disable-libstdcxx</parameter>, and now we can
|
---|
152 | explicitly pass it.</para>
|
---|
153 | </listitem>
|
---|
154 | </varlistentry>
|
---|
155 |
|
---|
156 | </variablelist>
|
---|
157 |
|
---|
158 | <para>Compile the package:</para>
|
---|
159 |
|
---|
160 | <screen><userinput remap="make">make</userinput></screen>
|
---|
161 |
|
---|
162 | <para>Install the package:</para>
|
---|
163 |
|
---|
164 | <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
|
---|
165 |
|
---|
166 | <para>As a finishing touch, create a utility symlink. Many programs and scripts
|
---|
167 | run <command>cc</command> instead of <command>gcc</command>, which is
|
---|
168 | used to keep programs generic and therefore usable on all kinds of UNIX
|
---|
169 | systems where the GNU C compiler is not always installed. Running
|
---|
170 | <command>cc</command> leaves the system administrator free to decide
|
---|
171 | which C compiler to install:</para>
|
---|
172 |
|
---|
173 | <screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
|
---|
174 |
|
---|
175 | </sect2>
|
---|
176 |
|
---|
177 | <sect2 role="content">
|
---|
178 | <title/>
|
---|
179 |
|
---|
180 | <para>Details on this package are located in
|
---|
181 | <xref linkend="contents-gcc" role="."/></para>
|
---|
182 |
|
---|
183 | </sect2>
|
---|
184 |
|
---|
185 | </sect1>
|
---|