source: chapter06/gcc-pass2.xml@ c84ec38

xry111/arm64 xry111/arm64-12.0
Last change on this file since c84ec38 was 9334a3f, checked in by Xi Ruoyao <xry111@…>, 20 months ago

arm64: adapt GCC lib64 -> lib quirk for aarch64

  • Property mode set to 100644
File size: 6.8 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 <para>On ARM64 hosts, set the default directory name for
62 64-bit libraries to <quote>lib</quote>:</para>
63
64<screen><userinput remap="pre">sed -e '/lp64=/s/lib64/lib/' \
65 -i.orig gcc/config/aarch64/t-aarch64-linux</userinput></screen>
66
67 <para>Override the building rule of libgcc and libstdc++ headers, to
68 allow building these libraries with POSIX threads support:</para>
69
70<screen><userinput remap="pre">sed '/thread_header =/s/@.*@/gthr-posix.h/' \
71 -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in</userinput></screen>
72
73 <para>Create a separate build directory again:</para>
74
75<screen><userinput remap="pre">mkdir -v build
76cd build</userinput></screen>
77
78 <para>Before starting to build GCC, remember to unset any environment
79 variables that override the default optimization flags.</para>
80
81 <para>Now prepare GCC for compilation:</para>
82
83<screen><userinput remap="configure">../configure \
84 --build=$(../config.guess) \
85 --host=$LFS_TGT \
86 --target=$LFS_TGT \
87 LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
88 --prefix=/usr \
89 --with-build-sysroot=$LFS \
90 --enable-initfini-array \
91 --disable-nls \
92 --disable-multilib \
93 --disable-decimal-float \
94 --disable-libatomic \
95 --disable-libgomp \
96 --disable-libquadmath \
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 of GCC uses
111 other tools, which are not aware of this location. This switch is
112 needed to have them 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>As we are cross-compiling GCC, it's impossible to build
121 target libraries (<filename class="libraryfile">libgcc</filename>
122 and <filename class="libraryfile">libstdc++</filename>) with the
123 compiled GCC binaries because these binaries won't run on the
124 host distro. GCC building system will attempt to use the
125 C and C++ compilers on the host distro as a workaround by default.
126 It's not supported to build GCC target libraries with a different
127 version of GCC, so using host compilers may cause building
128 failure. This parameter ensures to build the libraries with GCC
129 pass 1 and prevent the issue.</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 shared <filename class="libraryfile">libgcc</filename> being
138 built in this pass, instead of the static version built in GCC
139 pass 1. This is needed for supporting C++ exception
140 handling.</para>
141 </listitem>
142 </varlistentry>
143
144 <varlistentry>
145 <term><parameter>--enable-initfini-array</parameter></term>
146 <listitem>
147 <para>This option is automatically enabled when building a native
148 compiler with a native compiler on x86. But here, we build with
149 a cross compiler, so we need to explicitly set this option.</para>
150 </listitem>
151 </varlistentry>
152
153 </variablelist>
154
155 <para>Compile the package:</para>
156
157<screen><userinput remap="make">make</userinput></screen>
158
159 <para>Install the package:</para>
160
161<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
162
163 <para>As a finishing touch, create a utility symlink. Many programs and scripts
164 run <command>cc</command> instead of <command>gcc</command>, which is
165 used to keep programs generic and therefore usable on all kinds of UNIX
166 systems where the GNU C compiler is not always installed. Running
167 <command>cc</command> leaves the system administrator free to decide
168 which C compiler to install:</para>
169
170<screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
171
172 </sect2>
173
174 <sect2 role="content">
175 <title/>
176
177 <para>Details on this package are located in
178 <xref linkend="contents-gcc" role="."/></para>
179
180 </sect2>
181
182</sect1>
Note: See TracBrowser for help on using the repository browser.