source: chapter06/gcc-pass2.xml@ 85acfcb0

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

Adopt changes to multilib instrustions. ML CURRENTLY BROKEN

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