2 % This is part of LFSbookja package.
4 % This is a CTIE change file for the original XML source of the LFSbook.
7 <?xml version="1.0" encoding="ISO-8859-1"?>
9 <?xml version="1.0" encoding="UTF-8"?>
13 <sect1 id="ch-tools-gcc-pass1" role="wrap" xreflabel="gcc-pass1">
15 <sect1 id="ch-tools-gcc-pass1" role="wrap" xreflabel="gcc 1 回め">
19 <title>GCC-&gcc-version; - Pass 1</title>
21 <title>GCC-&gcc-version; - 1回め</title>
25 <indexterm zone="ch-tools-gcc-pass1">
26 <primary sortas="a-GCC">GCC</primary>
27 <secondary>tools, pass 1</secondary>
30 <indexterm zone="ch-tools-gcc-pass1">
31 <primary sortas="a-GCC">GCC</primary>
32 <secondary>&Tools;, 1回め</secondary>
37 <title>Installation of Cross GCC</title>
39 <title>&InstallationOf1;クロスコンパイル版 GCC&InstallationOf2;</title>
43 <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
44 not be included in your host distribution, they will be built with
45 GCC. Unpack each package into the GCC source directory and rename the
46 resulting directories so the GCC build procedures will automatically
50 GCC は GMP、MPFR、MPC の各パッケージを必要とします。
51 これらのパッケージはホストシステムに含まれていないかもしれないため、以下を実行してビルドの準備をします。
52 個々のパッケージを GCC ソースディレクトリの中に伸張 (解凍) し、ディレクトリ名を変更します。
53 これは GCC のビルド処理においてそれらを自動的に利用できるようにするためです。
58 <note><para>There are frequent misunderstandings about this chapter. The
59 procedures are the same as every other chapter as explained earlier (<xref
60 linkend='buildinstr'/>). First extract the gcc tarball from the sources
61 directory and then change to the directory created. Only then should you
62 proceed with the instructions below.</para></note>
66 ここでの手順は他のものと同様であり、手順の概要 (<xref linkend='buildinstr'/>) は説明済です。
67 まず初めに gcc の tarball を伸張 (解凍) し、生成されたソースディレクトリに移動します。
68 それに加えて本節では、以下の手順を行うものとなります。
73 % <para>The following command will change the location of GCC's default
74 % dynamic linker to use the one installed in <filename
75 % class="directory">/tools</filename>. It also removes <filename
76 % class="directory">/usr/include</filename> from GCC's include search path.
80 % 以下のコマンドは GCC のデフォルトのダイナミックリンカーの配置ディレクトリを、既にインストールされている <filename
81 % class="directory">/tools</filename> とします。
82 % また GCC のインクルードパスから <filename
83 % class="directory">/usr/include</filename> を除きます。
88 % <para>In case the above seems hard to follow, let's break it down a bit.
89 % First we copy the files <filename>gcc/config/linux.h</filename>,
90 % <filename>gcc/config/i386/linux.h</filename>, and
91 % <filename>gcc/config/i386/linux64.h</filename> to a file of
92 % the same name but with an added suffix of <quote>.orig</quote>. Then the
93 % first sed expression prepends <quote>/tools</quote> to every instance of
94 % <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or
95 % <quote>/lib32/ld</quote>, while the second one replaces hard-coded
96 % instances of <quote>/usr</quote>. Next, we add our define statements which
97 % alter the default startfile prefix to the end of the file. Note that the
98 % trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required.
99 % Finally, we use <command>touch</command> to update the timestamp on the
100 % copied files. When used in conjunction with <command>cp -u</command>, this
101 % prevents unexpected changes to the original files in case the commands are
102 % inadvertently run twice.</para>
105 % 上のコマンドがよく分からない場合は一つ一つ読み下していってください。
106 % まず <filename>gcc/config/linux.h</filename>,
107 % <filename>gcc/config/i386/linux.h</filename>, and
108 % <filename>gcc/config/i386/linux64.h</filename> というファイルを、ファイル名称の末尾に <quote>.orig</quote> を付け加えてコピーします。
109 % そして一つめの sed コマンドでは、そのファイル内にある<quote>/lib/ld</quote>, <quote>/lib64/ld</quote>, <quote>/lib32/ld</quote>という記述部分の頭に<quote>/tools</quote>を付与します。
110 % また二つめの sed コマンドによってハードコーディングされている<quote>/usr</quote>という部分を書き換えます。
111 % そしてここで加えるべき定義文をファイルの末尾に追加し、検索パスと startfile プリフィックスを変更します。
112 % この際に<quote>/tools/lib/</quote>の終わりには<quote>/</quote>が必要となります。
113 % 最後に <command>touch</command> によってコピーしたファイルのタイムスタンプを更新します。
114 % <command>cp -u</command> を用いるのは、誤ってコマンドを二度起動したとしてもオリジナルファイルを壊さないようにするためです。
119 <para>On x86_64 hosts, set the default directory name for
120 64-bit libraries to <quote>lib</quote>:</para>
123 x86_64 ホストにおいて、64 ビットライブラリに対するデフォルトのディレクトリ名は<quote>lib</quote>です。
128 % <para>GCC doesn't detect stack protection correctly, which causes problems
129 % for the build of Glibc-&glibc-version;, so fix that by issuing the following
133 % GCC はスタックプロテクション (stack protection) を正しく検出しません。
134 % このことは Glibc-&glibc-version; においてビルドする際には問題となります。
135 % そこで以下のコマンドを実行することで解消します。
140 % <para>Also fix a problem identified upstream:</para>
143 % アップストリームが認識している問題を修正します。
148 <para>The GCC documentation recommends building GCC
149 in a dedicated build directory:</para>
152 GCC のドキュメントでは、専用のビルドディレクトリを作成することが推奨されています。
157 <para>Prepare GCC for compilation:</para>
159 <para>&PreparePackage1;GCC&PreparePackage2;</para>
163 <title>The meaning of the configure options:</title>
165 <title>&MeaningOfOption1;configure&MeaningOfOption2;</title>
168 @x --with-glibc-version=&glibc-version;
169 <para>This option specifies the version of glibc which will be
170 used on the target. It is not relevant to the libc of the host
171 distro because everything compiled by pass1 gcc will run in the
172 chroot environment, which is isolated from libc of the host
176 このオプションは、ターゲットにおいて用いられることになる glibc のバージョンを指定します。
177 これはホストディストリビューションにある libc のバージョンとは関係がありません。
178 1 回めの gcc によってコンパイルされるものは、すべて chroot 環境内で実行されるものであって、ホストにある libc とは切り離されているためです。
183 <para>Since a working C library is not yet available, this ensures
184 that the inhibit_libc constant is defined when building libgcc. This prevents
185 the compiling of any code that requires libc support.</para>
188 この時点では利用可能な C ライブラリがまだ存在しません。
189 したがって libgcc のビルド時に inhibit_libc 定数を定義します。
190 これを行うことで、libc サポートを必要とするコード部分をコンパイルしないようにします。
195 <para>When creating a complete cross-compiler, GCC requires
196 standard headers compatible with the target system. For our
197 purposes these headers will not be needed. This switch prevents
198 GCC from looking for them.</para>
201 完璧なクロスコンパイラーを構築するなら、GCC はターゲットシステムに互換性を持つ標準ヘッダーを必要とします。
202 本手順においては標準ヘッダーは必要ありません。
203 このスイッチは GCC がそういったヘッダーを探しにいかないようにします。
207 %@x --with-local-prefix=/tools
208 % <para>The local prefix is the location in the system that GCC will search
209 % for locally installed include files. The default is <filename>/usr/local</filename>.
210 % Setting this to <filename>/tools</filename> helps keep the host location of
211 % <filename>/usr/local</filename> out of this GCC's search path.</para>
214 % ローカルプリフックス (local prefix) は、GCC がローカルにインストールされているインクルードファイルを探しにいくディレクトリを意味します。
215 % そのデフォルトは <filename>/usr/local</filename> です。
216 % この設定を <filename>/tools</filename> とすることで、GCC が探し出すパスから <filename>/usr/local</filename> を除外します。
220 %@x --with-native-system-header-dir=/tools/include
221 % <para>By default, GCC searches <filename>/usr/include</filename> for
222 % system headers. In conjunction with the sysroot switch, this would
223 % normally translate to <filename>$LFS/usr/include</filename>. However
224 % the headers that will be installed in the next two sections will go
225 % to <filename>$LFS/tools/include</filename>. This switch ensures that
226 % gcc will find them correctly. In the second pass of GCC, this same
227 % switch will ensure that no headers from the host system are
231 % GCC がシステムヘッダーを探し出すデフォルトのパスは <filename>/usr/include</filename> です。
232 % 後に root を変更する際には、このディレクトリは <filename>$LFS/usr/include</filename> となります。
233 % しかしこの直後の2つの作業を通じて、ヘッダーをインストールする先は <filename>$LFS/tools/include</filename> としています。
234 % つまり本スイッチは GCC がヘッダーを正しく見つけ出せるようにするものです。
235 % GCC の2回めのビルドでは、同じスイッチを用いて、ホストシステムのヘッダーは一切見つけ出さないようにします。
239 @x --enable-initfini-array
240 <para>This switch forces the use of some internal data structures
241 that are needed but cannot be detected when building a cross
245 このスイッチは内部データ構造を利用することを指示します。
246 クロスコンパイラーのビルド時にこれが必要になりますが、自動では設定されません。
251 <para>This switch forces GCC to link its internal libraries
252 statically. We need this because the shared libraries require glibc,
253 which is not yet installed on the target system.</para>
256 このスイッチは内部ライブラリをスタティックライブラリとしてリンクすることを指示します。
257 共有ライブラリが glibc を必要としており、処理しているシステム上にはまだインストールされていないためです。
261 @x --disable-multilib
262 <para>On x86_64, LFS does not support a multilib configuration.
263 This switch is harmless for x86.</para>
266 x86_64 に対して LFS は multilib のサポートをしていません。
267 このオプション指定は x86 には無関係です。
271 @x --disable-decimal-float, --disable-threads, --disable-libatomic, --disable-libgomp, --disable-libquadmath, --disable-libssp, --disable-libvtv, --disable-libstdcxx
272 <para>These switches disable support for the decimal floating point
273 extension, threading, libatomic, libgomp, libquadmath, libssp,
274 libvtv, and the C++ standard library respectively. These features
275 will fail to compile when building a cross-compiler and are not
276 necessary for the task of cross-compiling the temporary libc.</para>
279 これらのオプションは順に、十進浮動小数点制御、スレッド処理、libatomic, libgomp, libquadmath, libssp, libvtv, C++ 標準ライブラリのサポートをいずれも無効にすることを指示します。
280 これらの機能を含めていると、クロスコンパイラーをビルドする際にはコンパイルに失敗します。
281 またクロスコンパイルによって一時的な libc ライブラリを構築する際には不要なものです。
285 @x --enable-languages=c,c++
286 <para>This option ensures that only the C and C++ compilers are built.
287 These are the only languages needed now.</para>
290 このオプションは C コンパイラーおよび C++ コンパイラーのみビルドすることを指示します。
291 この時点で必要なのはこの言語だけだからです。
296 <para>Compile GCC by running:</para>
298 <para>GCC をコンパイルします。</para>
302 % <para>Compilation is now complete. At this point, the test suite would
303 % normally be run, but, as mentioned before, the test suite framework is
304 % not in place yet. The benefits of running the tests at this point
305 % are minimal since the programs from this first pass will soon be
310 % この時点でもテストスイートを実行することはできます。
311 % ただ前にも述べているように、テストスイートのフレームワークがまだ準備できていません。
312 % さらにこの時点で生成されるプログラムは、すぐに次の生成作業によって置き換えられますから、この時点でテストを実行することはあまり意味がありません。
317 <para>Install the package:</para>
319 <para>&InstallThePackage;</para>
323 % <para>Using <parameter>--disable-shared</parameter> means that the
324 % <filename>libgcc_eh.a</filename> file isn't created and installed. The
325 % Glibc package depends on this library as it uses
326 % <parameter>-lgcc_eh</parameter> within its build system. This dependency
327 % can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
328 % since that file will end up containing the objects normally contained in
329 % <filename>libgcc_eh.a</filename>:</para>
332 % <parameter>--disable-shared</parameter> オプションを指定すると <filename>libgcc_eh.a</filename> を生成せずインストールしません。
333 % Glibc パッケージはこのライブラリに依存しており、ビルドの際に <parameter>-lgcc_eh</parameter> を指定することで利用されます。
334 % 依存している点は <filename>libgcc.a</filename> へのシンボリックリンクを生成しておけば問題はありません。
335 % <filename>libgcc_eh.a</filename> に含まれるオブジェクトが、最終的には <filename>libgcc.a</filename> の中にも含まれることになるからです。
340 <para>This build of GCC has installed a couple of internal system
341 headers. Normally one of them, <filename>limits.h</filename>, would in turn
342 include the corresponding system <filename>limits.h</filename> header, in
343 this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
344 time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
345 does not exist, so the internal header that has just been installed is a
346 partial, self-contained file and does not include the extended features of
347 the system header. This is adequate for building glibc, but the full
348 internal header will be needed later. Create a full version of the internal
349 header using a command that is identical to what the GCC build system does
350 in normal circumstances:</para>
353 ここでの GCC ビルドにおいては、内部にあるシステムヘッダーファイルをいくつかインストールしました。
354 そのうちの <filename>limits.h</filename> というものは、対応するシステムヘッダーファイルである <filename>limits.h</filename> を読み込むものになっています。
355 そのファイルはここでは <filename>$LFS/usr/include/limits.h</filename> になります。
356 ただし GCC をビルドしたこの時点において <filename>$LFS/usr/include/limits.h</filename> は存在していません。
357 したがってインストールされたばかりの内部ヘッダーファイルは、部分的に自己完結したファイルとなり、システムヘッダーファイルによる拡張された機能を含むものになっていません。
358 glibc をビルドする際にはこれでもかまわないのですが、後々内部ヘッダーファイルは完全なものが必要になります。
359 以下のようなコマンドを通じて、その内部ヘッダーファイルの完成版を作り出します。
360 このコマンドは GCC ビルドが通常行っている方法と同じものです。
365 <para>Details on this package are located in
366 <xref linkend="contents-gcc" role="."/></para>
369 &Details1;<xref linkend="contents-gcc" role=""/>&Details2;