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-pass2" role="wrap" xreflabel="gcc-pass2">
15 <sect1 id="ch-tools-gcc-pass2" role="wrap" xreflabel="GCC 2回め">
19 <title>GCC-&gcc-version; - Pass 2</title>
21 <title>GCC-&gcc-version; - 2回め</title>
25 <indexterm zone="ch-tools-gcc-pass2">
26 <primary sortas="a-GCC">GCC</primary>
27 <secondary>tools, pass 2</secondary>
30 <indexterm zone="ch-tools-gcc-pass2">
31 <primary sortas="a-GCC">GCC</primary>
32 <secondary>&Tools;, 2回め</secondary>
37 <title>Installation of GCC</title>
39 <title>&InstallationOf1;GCC&InstallationOf2;</title>
43 <para>As in the first build of GCC, the GMP, MPFR, and MPC packages are
44 required. Unpack the tarballs and move them into the required directory
48 GCC の 1 回めのビルドと同様に、ここでも GMP、MPFR、MPC の各パッケージを必要とします。
49 tarball を解凍して、所定のディレクトリ名に移動させます。
54 % <para>Once again, change the location of GCC's default dynamic linker to
55 % use the one installed in <filename
56 % class="directory">/tools</filename>.</para>
59 % もう一度、GCC のデフォルトのダイナミックリンカーの配置ディレクトリを、既にインストールされている <filename
60 % class="directory">/tools</filename> とします。
65 <para>If building on x86_64, change the default directory name for 64-bit
66 libraries to <quote>lib</quote>:</para>
69 x86_64 上でビルドしている場合は、64ビットライブラリのデフォルトディレクトリ名を<quote>lib</quote>にします。
74 % <para>Our first build of GCC has installed a couple of internal system
75 % headers. Normally one of them, <filename>limits.h</filename>, will in turn
76 % include the corresponding system <filename>limits.h</filename> header, in
77 % this case, <filename>/tools/include/limits.h</filename>. However, at the
78 % time of the first build of gcc <filename>/tools/include/limits.h</filename>
79 % did not exist, so the internal header that GCC installed is a partial,
80 % self-contained file and does not include the extended features of the
81 % system header. This was adequate for building the temporary libc, but this
82 % build of GCC now requires the full internal header. Create a full version
83 % of the internal header using a command that is identical to what the GCC
84 % build system does in normal circumstances:</para>
87 % 第1回めの GCC のビルドでは、内部的なシステムヘッダーをインストールしています。
88 % その1つ <filename>limits.h</filename> は、これに対応づくシステムヘッダー <filename>limits.h</filename> を読み込みます。
89 % そのファイルは実際には <filename>/tools/include/limits.h</filename> となります。
90 % しかし 1 回めの GCC のビルド時には <filename>/tools/include/limits.h</filename> は存在しません。
91 % したがって GCC がインストールする内部ヘッダーは、部分的で自己完結した (self-contained) もののみとなり、システムヘッダーが持つ拡張機能は含まれません。
92 % 一時的な libc を構築するならこれは正しかったのですが、この段階での GCC のビルドでは、内部ヘッダーが完全な形のものでなければなりません。
93 % 完全な内部ヘッダーを生成するために、GCC ビルドシステムが通常行っている方法と同じようにするための、以下のコマンドを実行します。
98 % <para>Fix an issue with GCC-10.1 when building with a cross
102 % クロスコンパイラーを使ってビルドするにあたり、GCC-10.1 の問題を修正します。
107 <para>Fix an issue causing failure cross-compiling libstdc++:</para>
110 libstdc++ のクロスコンパイルができなくなっている問題を修正します。
115 <para>Override the building rule of libgcc and libstdc++ headers, to
116 allow building these libraries with POSIX threads support:</para>
119 libgcc と libstdc++ のヘッダーのビルドルールを変更して、これらのライブラリに対して POSIX スレッドサポートを含めてビルドするようにします。
124 <para>Create a separate build directory again:</para>
132 <para>Before starting to build GCC, remember to unset any environment
133 variables that override the default optimization flags.</para>
136 GCC のビルドに入る前に、デフォルトの最適化フラグを上書きするような環境変数の設定がないことを確認してください。
141 <para>Now prepare GCC for compilation:</para>
143 <para>&PreparePackage1;GCC&PreparePackage2;</para>
147 <title>The meaning of the new configure options:</title><!-- WIP -->
149 <title>&MeaningOfOption1;configure&MeaningOfOption2;</title><!-- WIP -->
152 %@x --enable-languages=c,c++
153 % <para>This option ensures that both the C and C++ compilers are
157 % C と C++ の両コンパイラーを生成することを指示します。
161 %@x --disable-libstdcxx-pch
162 % <para>Do not build the pre-compiled header (PCH) for
163 % <filename class="libraryfile">libstdc++</filename>. It takes up a
164 % lot of space, and we have no use for it.</para>
167 % <filename class="libraryfile">libstdc++</filename> に対してプリコンパイルヘッダー (pre-compiled header; PCH) をビルドしないように指示します。
168 % これを含めてしまうとサイズが増えることになり、そもそも利用する必要がありません。
172 %@x --disable-bootstrap
173 % <para>For native builds of GCC, the default is to do a "bootstrap"
174 % build. This does not just compile GCC, but compiles it several times.
175 % It uses the programs compiled in a first round to compile itself a
176 % second time, and then again a third time. The second and third
177 % iterations are compared to make sure it can reproduce itself
178 % flawlessly. This also implies that it was compiled correctly.
179 % However, the LFS build method should provide a solid compiler
180 % without the need to bootstrap each time.</para>
183 % GCC のネイティブビルドを行うには、デフォルトでは "ブートストラップ" ビルドを行ないます。
184 % これは単に GCC をコンパイルするのではなく、数回のコンパイルを繰り返します。
185 % つまり一回めにビルドされたプログラムを使って二回め、三回めのコンパイルを行うものです。
186 % 二回め、三回めとコンパイルを繰り返すのは、これによって自分自身を再生成して完璧なものを作り出すためです。
187 % このことによってコンパイルが正確に行われたことを暗に示すことにもなります。
188 % しかし LFS のビルドでは、何度もブートストラップを行う必要のない、手堅い(solid) コンパイラーを作り出します。
192 @x -with-build-sysroot=$LFS
193 <para>Normally, using <parameter>--host</parameter> ensures that
194 a cross-compiler is used for building GCC, and that compiler knows
195 that it has to look for headers and libraries in <filename
196 class="directory">$LFS</filename>. But the build system of GCC uses
197 other tools, which are not aware of this location. This switch is
198 needed to have them find the needed files in <filename
199 class="directory">$LFS</filename>, and not on the host.</para>
202 通常は <parameter>--host</parameter> を用いれば、GCC ビルドにクロスコンパイラーが用いられ、参照すべきヘッダーやライブラリも <filename
203 class="directory">$LFS</filename> にあるものが用いられるように指示されます。
204 しかし今ビルドを行っているシステム上の GCC は別のツールを使っているので、上のような場所を認識できていません。
205 本スイッチは、必要なファイルをホスト内からではなく、<filename
206 class="directory">$LFS</filename> から探し出すようにします。
211 <para>As we are cross-compiling GCC, it's impossible to build
212 target libraries (<filename class="libraryfile">libgcc</filename>
213 and <filename class="libraryfile">libstdc++</filename>) with the
214 compiled GCC binaries because these binaries won't run on the
215 host distro. GCC building system will attempt to use the
216 C and C++ compilers on the host distro as a workaround by default.
217 It's not supported to build GCC target libraries with a different
218 version of GCC, so using host compilers may cause building
219 failure. This parameter ensures to build the libraries with GCC
220 pass 1 and prevent the issue.</para>
223 これまでの GCC はクロスコンパイルによって作り出してきているので、コンパイル済み GCC 実行ファイルからターゲットライブラリ(<filename
224 class="libraryfile">libgcc</filename> と <filename
225 class="libraryfile">libstdc++</filename>) をビルドして作り出すことができません。
226 なぜならその実行ファイルはホストディストリビューション上で動作させられないからです。
227 GCC ビルドシステムはその回避策として、デフォルトではホスト上にある C および C++ コンパイラーを利用しようとします。
228 ただし GCC のバージョンが異なる場合に、GCC ターゲットライブラリをビルドすることはサポートされていません。
229 したがってホスト上のコンパイラーがビルドに失敗する可能性があります。
230 本パラメーターは、確実に GCC 1回めの実行ファイルを使ってライブラリビルドを行うようにして、問題が発生しないようにします。
234 @x LDFLAGS_FOR_TARGET=...
235 <para>Allow <filename class="libraryfile">libstdc++</filename> to
236 use shared <filename class="libraryfile">libgcc</filename> being
237 built in this pass, instead of the static version built in GCC
238 pass 1. This is needed for supporting C++ exception
242 GCC 1回めではスタティックバージョンの <filename
243 class="libraryfile">libgcc</filename> をビルドしていましたが、ここでは共有の <filename
244 class="libraryfile">libgcc</filename> をビルドするようにします。
245 これは C++ 例外処理のために必要となります。
249 @x --enable-initfini-array
250 <para>This option is automatically enabled when building a native
251 compiler with a native compiler on x86. But here, we build with
252 a cross compiler, so we need to explicitly set this option.</para>
255 本オプションを指定すれば、自動的に x86 上のネイティブコンパイラーを使って、ネイティブコンパイラーをビルドするようにします。
256 しかしここではクロスコンパイラーを作り出すつもりでいます。
257 したがって明示的に本オプションへ指定が必要になります。
262 <para>Compile the package:</para>
264 <para>&CompileThePackage;</para>
268 <para>Install the package:</para>
270 <para>&InstallThePackage;</para>
274 <para>As a finishing touch, create a utility symlink. Many programs and scripts
275 run <command>cc</command> instead of <command>gcc</command>, which is
276 used to keep programs generic and therefore usable on all kinds of UNIX
277 systems where the GNU C compiler is not always installed. Running
278 <command>cc</command> leaves the system administrator free to decide
279 which C compiler to install:</para>
282 最後に、便利なシンボリックリンクを作成します。
283 プログラムやスクリプトの中には <command>gcc</command> ではなく <command>cc</command> を用いるものが結構あります。
284 シンボリックリンクを作ることで各種のプログラムを汎用的にすることができ、通常 GNU C コンパイラーがインストールされていない多くの UNIX システムでも利用できるものになります。
285 <command>cc</command> を利用することにすれば、システム管理者がどの C コンパイラーをインストールすべきかを判断する必要がなくなります。
290 % <para>At this point, it is imperative to stop and ensure that the basic
291 % functions (compiling and linking) of the new toolchain are working as
292 % expected. To perform a sanity check, run the following commands:</para>
295 % この時点で、構築したツールチェーンの基本的な (コンパイルやリンクなどの) 機能が正しく動作していることを確認する必要があります。
296 % 健全性検査 (sanity check) を行うために以下を実行してください。
301 % <para>If everything is working correctly, there should be no errors,
302 % and the output of the last command will be of the form:</para>
305 % 問題なく動作した場合はエラーがなかったということで、最後のコマンドから出力される結果は以下のようになるはずです。
310 % <para>Note that the dynamic linker will be /tools/lib/ld-linux.so.2
311 % for 32-bit machines.</para>
314 % 32 ビットマシンに対するダイナミックリンカーは /tools/lib/ld-linux.so.2 となります。
319 % <para>If the output is not shown as above or there was no output at all,
320 % then something is wrong. Investigate and retrace the steps to find out
321 % where the problem is and correct it. This issue must be resolved before
322 % continuing on. First, perform the sanity check again, using
323 % <command>gcc</command> instead of <command>cc</command>. If this works,
324 % then the <filename class="symlink">/tools/bin/cc</filename> symlink is
325 % missing. Install the symlink as per above.
326 % Next, ensure that the <envar>PATH</envar> is correct. This
327 % can be checked by running <command>echo $PATH</command> and verifying that
328 % <filename class="directory">/tools/bin</filename> is at the head of the
329 % list. If the <envar>PATH</envar> is wrong it could mean that you are not
330 % logged in as user <systemitem class="username">lfs</systemitem> or that
331 % something went wrong back in <xref linkend="ch-preps-settingenviron"
335 % コマンドの出力結果が上と異なっていたり、あるいは何も出力されなかった場合は、何かがおかしいことを意味します。
336 % どこに問題があるのか調査、再試行を行って解消してください。
337 % 解決せずにこの先に進まないでください。
338 % <command>cc</command> ではなく <command>gcc</command> を使って再度健全性検査を行ってみてください。
339 % これで解決したなら <filename class="symlink">/tools/bin/cc</filename> のシンボリックリンクが正しくないということです。
341 % また環境変数 <envar>PATH</envar> が正しいかどうかも確認してください。
342 % <command>echo $PATH</command> を実行して、実行パスリストの先頭が <filename class="directory">/tools/bin</filename> であるかどうか確認します。
343 % <envar>PATH</envar> が間違っていたなら、実はあなたは <systemitem
344 % class="username">lfs</systemitem> ユーザーでログインしていないのかもしれませんし <xref
345 % linkend="ch-preps-settingenviron" role=""/>での作業に間違いがあったのかもしれません。
350 % <para>Once all is well, clean up the test files:</para>
353 % すべてが終了したらテストファイルを削除します。
358 <para>Details on this package are located in
359 <xref linkend="contents-gcc" role="."/></para>
362 &Details1;<xref linkend="contents-gcc" role=""/>&Details2;