source: chapter06/gcc-pass2.xml@ 3a72ffa

multilib
Last change on this file since 3a72ffa was 3a72ffa, checked in by Thomas Trepl (Moody) <thomas@…>, 2 years ago

Adopt upstream changes

  • Property mode set to 100644
File size: 8.3 KB
RevLine 
[6dfcfecc]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-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>As in the first build of GCC, the GMP, MPFR, and MPC packages are
47 required. Unpack the tarballs and move them into the required directory
48 names:</para>
49
50<screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
51mv -v mpfr-&mpfr-version; mpfr
52tar -xf ../gmp-&gmp-version;.tar.xz
53mv -v gmp-&gmp-version; gmp
54tar -xf ../mpc-&mpc-version;.tar.gz
[c4595c3]55mv -v mpc-&mpc-version; mpc</userinput></screen>
[6dfcfecc]56
57
58 <para arch="default">If building on x86_64, change the default directory name for 64-bit
59 libraries to <quote>lib</quote>:</para>
60
61<screen arch="default"><userinput remap="pre">case $(uname -m) in
62 x86_64)
63 sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
64 ;;
65esac</userinput></screen>
[d7e0db5]66
[d9bec1e]67 <para arch="ml_32,ml_x32,ml_all">Change the default directory name for the
[6dfcfecc]68 libraries:</para>
69
70<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
[0ebda11]71 -e '/m32=/s/m32=.*/m32=..\/lib32$(call if_multiarch,:i386-linux-gnu)/' \
[6dfcfecc]72 -i.orig gcc/config/i386/t-linux64</userinput></screen>
[d9bec1e]73
[459d493]74 <para>Override the building rule of libgcc and libstdc++ headers, to
75 allow building these libraries with POSIX threads support:</para>
76
77<screen><userinput remap="pre">sed '/thread_header =/s/@.*@/gthr-posix.h/' \
78 -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in</userinput></screen>
79
[6dfcfecc]80 <para>Create a separate build directory again:</para>
81
82<screen><userinput remap="pre">mkdir -v build
83cd build</userinput></screen>
84
85 <para>Before starting to build GCC, remember to unset any environment
86 variables that override the default optimization flags.</para>
87
88 <para>Now prepare GCC for compilation:</para>
89
90<screen arch="default"><userinput remap="configure">../configure \
91 --build=$(../config.guess) \
92 --host=$LFS_TGT \
[8e0f8a9]93 --target=$LFS_TGT \
[459d493]94 LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
[6dfcfecc]95 --prefix=/usr \
96 --with-build-sysroot=$LFS \
97 --enable-initfini-array \
98 --disable-nls \
99 --disable-multilib \
100 --disable-decimal-float \
101 --disable-libatomic \
102 --disable-libgomp \
103 --disable-libquadmath \
104 --disable-libssp \
105 --disable-libvtv \
106 --enable-languages=c,c++</userinput></screen>
107<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure"
108 arch="ml_32">mlist=m64,m32</userinput><userinput remap="configure"
109 arch="ml_x32">mlist=m64,mx32</userinput><userinput remap="configure"
110 arch="ml_all">mlist=m64,m32,mx32</userinput>
111<userinput remap="configure">../configure \
112 --build=$(../config.guess) \
113 --host=$LFS_TGT \
[85acfcb0]114 --target=$LFS_TGT \
115 LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
[6dfcfecc]116 --prefix=/usr \
117 --with-build-sysroot=$LFS \
118 --enable-initfini-array \
119 --disable-nls \
120 --enable-multilib --with-multilib-list=$mlist \
121 --disable-decimal-float \
122 --disable-libatomic \
123 --disable-libgomp \
124 --disable-libquadmath \
125 --disable-libssp \
126 --disable-libvtv \
[8acfbf67]127 --enable-languages=c,c++</userinput></screen>
[85acfcb0]128<!--
129 LDFLAGS_FOR_TARGET="-L$PWD/$LFS_TGT/libgcc -L$PWD/$LFS_TGT/32/libgcc -L$PWD/$LFS_TGT/x32/libgcc" \
130-->
[6dfcfecc]131 <variablelist>
132 <title>The meaning of the new configure options:</title><!-- WIP -->
133
134 <varlistentry>
[3bb463d]135 <term><parameter>--with-build-sysroot=$LFS</parameter></term>
[6dfcfecc]136 <listitem>
137 <para>Normally, using <parameter>--host</parameter> ensures that
138 a cross-compiler is used for building GCC, and that compiler knows
139 that it has to look for headers and libraries in <filename
140 class="directory">$LFS</filename>. But the build system of GCC uses
141 other tools, which are not aware of this location. This switch is
142 needed to have them find the needed files in <filename
143 class="directory">$LFS</filename>, and not on the host.</para>
144 </listitem>
145 </varlistentry>
146
[3bb463d]147 <varlistentry>
148 <term><parameter>--target=$LFS_TGT</parameter></term>
149 <listitem>
150 <para>As we are cross-compiling GCC, it's impossible to build
151 target libraries (<filename class="libraryfile">libgcc</filename>
152 and <filename class="libraryfile">libstdc++</filename>) with the
153 compiled GCC binaries because these binaries won't run on the
154 host distro. GCC building system will attempt to use the
155 C and C++ compilers on the host distro as a workaround by default.
156 It's not supported to build GCC target libraries with a different
157 version of GCC, so using host compilers may cause building
158 failure. This parameter ensures to build the libraries with GCC
159 pass 1 and prevent the issue.</para>
160 </listitem>
161 </varlistentry>
162
163 <varlistentry>
164 <term><parameter>LDFLAGS_FOR_TARGET=...</parameter></term>
165 <listitem>
166 <para>Allow <filename class="libraryfile">libstdc++</filename> to
167 use shared <filename class="libraryfile">libgcc</filename> being
168 built in this pass, instead of the static version built in GCC
169 pass 1. This is needed for supporting C++ exception
170 handling.</para>
171 </listitem>
172 </varlistentry>
173
[6dfcfecc]174 <varlistentry>
175 <term><parameter>--enable-initfini-array</parameter></term>
176 <listitem>
177 <para>This option is automatically enabled when building a native
178 compiler with a native compiler on x86. But here, we build with
[d7e0db5]179 a cross compiler, so we need to explicitly set this option.</para>
[6dfcfecc]180 </listitem>
181 </varlistentry>
182
183 </variablelist>
184
185 <para>Compile the package:</para>
186
187<screen><userinput remap="make">make</userinput></screen>
188
189 <para>Install the package:</para>
190
191<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
192
193 <para>As a finishing touch, create a utility symlink. Many programs and scripts
194 run <command>cc</command> instead of <command>gcc</command>, which is
195 used to keep programs generic and therefore usable on all kinds of UNIX
196 systems where the GNU C compiler is not always installed. Running
197 <command>cc</command> leaves the system administrator free to decide
198 which C compiler to install:</para>
199
200<screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
201
202 </sect2>
203
204 <sect2 role="content">
205 <title/>
206
207 <para>Details on this package are located in
208 <xref linkend="contents-gcc" role="."/></para>
209
210 </sect2>
211
212</sect1>
Note: See TracBrowser for help on using the repository browser.