source: chapter06/gcc-pass2.xml@ 1835fca

multilib
Last change on this file since 1835fca was 1835fca, checked in by Thomas Trepl (Moody) <thomas@…>, 20 months ago

Adopt PIE/SSP changes

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