source: chapter06/gcc-pass2.xml@ 100ca4e

xry111/clfs-ng
Last change on this file since 100ca4e was 100ca4e, checked in by Xi Ruoyao <xry111@…>, 2 years ago

Merge branch 'trunk' into xry111/clfs-ng

  • Property mode set to 100644
File size: 6.8 KB
RevLine 
[fcc02767]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
[9d06e69]8<sect1 id="ch-tools-gcc-pass2" role="wrap" xreflabel="gcc-pass2">
[fcc02767]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>
[fb386e0]36 <seg>&gcc-tmpp2-sbu;</seg>
37 <seg>&gcc-tmpp2-du;</seg>
[fcc02767]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
[30ae09bb]57 <para>For x86_64 target, set the default directory name for
58 64-bit libraries to <quote>lib</quote>. The command is unnecessary,
59 but harmless for 32-bit x86. If you are building for another target,
60 you may need to adjust the command for your target.</para>
61
62<screen><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
63 -i.orig gcc/config/i386/t-linux64</userinput></screen>
64
[459d493]65 <para>Override the building rule of libgcc and libstdc++ headers, to
66 allow building these libraries with POSIX threads support:</para>
67
68<screen><userinput remap="pre">sed '/thread_header =/s/@.*@/gthr-posix.h/' \
69 -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in</userinput></screen>
[fcc02767]70
71 <para>Create a separate build directory again:</para>
72
73<screen><userinput remap="pre">mkdir -v build
74cd build</userinput></screen>
75
76 <para>Before starting to build GCC, remember to unset any environment
77 variables that override the default optimization flags.</para>
78
79 <para>Now prepare GCC for compilation:</para>
80
81<screen><userinput remap="configure">../configure \
82 --build=$(../config.guess) \
83 --host=$LFS_TGT \
[8e0f8a9]84 --target=$LFS_TGT \
[459d493]85 LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
[fcc02767]86 --prefix=/usr \
87 --with-build-sysroot=$LFS \
88 --enable-initfini-array \
89 --disable-nls \
90 --disable-multilib \
91 --disable-decimal-float \
92 --disable-libatomic \
93 --disable-libgomp \
94 --disable-libquadmath \
95 --disable-libssp \
96 --disable-libvtv \
97 --enable-languages=c,c++</userinput></screen>
98
99 <variablelist>
100 <title>The meaning of the new configure options:</title><!-- WIP -->
101
102 <varlistentry>
[3bb463d]103 <term><parameter>--with-build-sysroot=$LFS</parameter></term>
[fcc02767]104 <listitem>
[bc8cca5]105 <para>Normally, using <parameter>--host</parameter> ensures that
[77d2cd8d]106 a cross-compiler is used for building GCC, and that compiler knows
[fcc02767]107 that it has to look for headers and libraries in <filename
108 class="directory">$LFS</filename>. But the build system of GCC uses
109 other tools, which are not aware of this location. This switch is
110 needed to have them find the needed files in <filename
111 class="directory">$LFS</filename>, and not on the host.</para>
112 </listitem>
113 </varlistentry>
114
[3bb463d]115 <varlistentry>
116 <term><parameter>--target=$LFS_TGT</parameter></term>
117 <listitem>
118 <para>As we are cross-compiling GCC, it's impossible to build
119 target libraries (<filename class="libraryfile">libgcc</filename>
120 and <filename class="libraryfile">libstdc++</filename>) with the
121 compiled GCC binaries because these binaries won't run on the
122 host distro. GCC building system will attempt to use the
123 C and C++ compilers on the host distro as a workaround by default.
124 It's not supported to build GCC target libraries with a different
125 version of GCC, so using host compilers may cause building
126 failure. This parameter ensures to build the libraries with GCC
127 pass 1 and prevent the issue.</para>
128 </listitem>
129 </varlistentry>
130
131 <varlistentry>
132 <term><parameter>LDFLAGS_FOR_TARGET=...</parameter></term>
133 <listitem>
134 <para>Allow <filename class="libraryfile">libstdc++</filename> to
135 use shared <filename class="libraryfile">libgcc</filename> being
136 built in this pass, instead of the static version built in GCC
137 pass 1. This is needed for supporting C++ exception
138 handling.</para>
139 </listitem>
140 </varlistentry>
141
[fcc02767]142 <varlistentry>
143 <term><parameter>--enable-initfini-array</parameter></term>
144 <listitem>
145 <para>This option is automatically enabled when building a native
146 compiler with a native compiler on x86. But here, we build with
[c0c616a]147 a cross compiler, so we need to explicitly set this option.</para>
[fcc02767]148 </listitem>
149 </varlistentry>
150
151 </variablelist>
152
153 <para>Compile the package:</para>
154
155<screen><userinput remap="make">make</userinput></screen>
156
157 <para>Install the package:</para>
158
159<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
160
[bc8cca5]161 <para>As a finishing touch, create a utility symlink. Many programs and scripts
[fcc02767]162 run <command>cc</command> instead of <command>gcc</command>, which is
163 used to keep programs generic and therefore usable on all kinds of UNIX
164 systems where the GNU C compiler is not always installed. Running
165 <command>cc</command> leaves the system administrator free to decide
166 which C compiler to install:</para>
167
168<screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
169
170 </sect2>
171
172 <sect2 role="content">
173 <title/>
174
175 <para>Details on this package are located in
176 <xref linkend="contents-gcc" role="."/></para>
177
178 </sect2>
179
180</sect1>
Note: See TracBrowser for help on using the repository browser.