OSDN Git Service

7a46fbbd15deefb229e287257c7ab0525f790341
[lfsbookja/lfsja-git.git] / src / chapter06 / gcc-pass2.ch
1 %
2 % This is part of LFSbookja package.
3 %
4 % This is a CTIE change file for the original XML source of the LFSbook.
5 %
6 @x
7 <?xml version="1.0" encoding="ISO-8859-1"?>
8 @y
9 <?xml version="1.0" encoding="UTF-8"?>
10 @z
11
12 @x
13 <sect1 id="ch-tools-gcc-pass2" role="wrap" xreflabel="gcc-pass2">
14 @y
15 <sect1 id="ch-tools-gcc-pass2" role="wrap" xreflabel="GCC 2回め">
16 @z
17
18 @x
19   <title>GCC-&gcc-version; - Pass 2</title>
20 @y
21   <title>GCC-&gcc-version; - 2回め</title>
22 @z
23
24 @x
25   <indexterm zone="ch-tools-gcc-pass2">
26     <primary sortas="a-GCC">GCC</primary>
27     <secondary>tools, pass 2</secondary>
28   </indexterm>
29 @y
30   <indexterm zone="ch-tools-gcc-pass2">
31     <primary sortas="a-GCC">GCC</primary>
32     <secondary>&Tools;, 2回め</secondary>
33   </indexterm>
34 @z
35
36 @x
37     <title>Installation of GCC</title>
38 @y
39     <title>&InstallationOf1;GCC&InstallationOf2;</title>
40 @z
41
42 @x
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
45     names:</para>
46 @y
47     <para>
48     GCC の 1 回めのビルドと同様に、ここでも GMP、MPFR、MPC の各パッケージを必要とします。
49     tarball を解凍して、所定のディレクトリ名に移動させます。
50     </para>
51 @z
52
53 %@x
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>
57 %@y
58 %    <para>
59 %    もう一度、GCC のデフォルトのダイナミックリンカーの配置ディレクトリを、既にインストールされている <filename
60 %    class="directory">/tools</filename> とします。
61 %    </para>
62 %@z
63
64 @x
65     <para>If building on x86_64, change the default directory name for 64-bit
66     libraries to <quote>lib</quote>:</para>
67 @y
68     <para>
69     x86_64 上でビルドしている場合は、64ビットライブラリのデフォルトディレクトリ名を<quote>lib</quote>にします。
70     </para>
71 @z
72
73 %@x
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>
85 %@y
86 %    <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 ビルドシステムが通常行っている方法と同じようにするための、以下のコマンドを実行します。
94 %    </para>
95 %@z
96
97 %@x
98 %    <para>Fix an issue with GCC-10.1 when building with a cross
99 %    compiler:</para>
100 %@y
101 %    <para>
102 %    クロスコンパイラーを使ってビルドするにあたり、GCC-10.1 の問題を修正します。
103 %    </para>
104 %@z
105
106 @x
107     <para>Fix an issue causing failure cross-compiling libstdc++:</para>
108 @y
109     <para>
110     libstdc++ のクロスコンパイルができなくなっている問題を修正します。
111     </para>
112 @z
113
114 @x
115     <para>Override the building rule of libgcc and libstdc++ headers, to
116     allow building these libraries with POSIX threads support:</para>
117 @y
118     <para>
119     libgcc と libstdc++ のヘッダーのビルドルールを変更して、これらのライブラリに対して POSIX スレッドサポートを含めてビルドするようにします。
120     </para>
121 @z
122
123 @x
124     <para>Create a separate build directory again:</para>
125 @y
126     <para>
127     専用のディレクトリを再度生成します。
128     </para>
129 @z
130
131 @x
132     <para>Before starting to build GCC, remember to unset any environment
133     variables that override the default optimization flags.</para>
134 @y
135     <para>
136     GCC のビルドに入る前に、デフォルトの最適化フラグを上書きするような環境変数の設定がないことを確認してください。
137     </para>
138 @z
139
140 @x
141     <para>Now prepare GCC for compilation:</para>
142 @y
143     <para>&PreparePackage1;GCC&PreparePackage2;</para>
144 @z
145
146 @x
147       <title>The meaning of the new configure options:</title><!-- WIP -->
148 @y
149       <title>&MeaningOfOption1;configure&MeaningOfOption2;</title><!-- WIP -->
150 @z
151
152 %@x --enable-languages=c,c++
153 %          <para>This option ensures that both the C and C++ compilers are
154 %          built.</para>
155 %@y
156 %          <para>
157 %          C と C++ の両コンパイラーを生成することを指示します。
158 %          </para>
159 %@z
160
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>
165 %@y
166 %          <para>
167 %          <filename class="libraryfile">libstdc++</filename> に対してプリコンパイルヘッダー (pre-compiled header; PCH) をビルドしないように指示します。
168 %          これを含めてしまうとサイズが増えることになり、そもそも利用する必要がありません。
169 %          </para>
170 %@z
171
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> 
181 %@y
182 %          <para>
183 %          GCC のネイティブビルドを行うには、デフォルトでは "ブートストラップ" ビルドを行ないます。
184 %          これは単に GCC をコンパイルするのではなく、数回のコンパイルを繰り返します。
185 %          つまり一回めにビルドされたプログラムを使って二回め、三回めのコンパイルを行うものです。
186 %          二回め、三回めとコンパイルを繰り返すのは、これによって自分自身を再生成して完璧なものを作り出すためです。
187 %          このことによってコンパイルが正確に行われたことを暗に示すことにもなります。
188 %          しかし LFS のビルドでは、何度もブートストラップを行う必要のない、手堅い(solid) コンパイラーを作り出します。
189 %          </para>
190 %@z
191
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>
200 @y
201           <para>
202           通常は <parameter>--host</parameter> を用いれば、GCC ビルドにクロスコンパイラーが用いられ、参照すべきヘッダーやライブラリも <filename
203           class="directory">$LFS</filename> にあるものが用いられるように指示されます。
204           しかし今ビルドを行っているシステム上の GCC は別のツールを使っているので、上のような場所を認識できていません。
205           本スイッチは、必要なファイルをホスト内からではなく、<filename
206           class="directory">$LFS</filename> から探し出すようにします。
207           </para>
208 @z
209
210 @x --target=$LFS_TGT
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>
221 @y
222           <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回めの実行ファイルを使ってライブラリビルドを行うようにして、問題が発生しないようにします。
231           </para>
232 @z
233
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
239           handling.</para>
240 @y
241           <para>
242           GCC 1回めではスタティックバージョンの <filename
243           class="libraryfile">libgcc</filename> をビルドしていましたが、ここでは共有の <filename
244           class="libraryfile">libgcc</filename> をビルドするようにします。
245           これは C++ 例外処理のために必要となります。
246           </para>
247 @z
248
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>
253 @y
254           <para>
255           本オプションを指定すれば、自動的に x86 上のネイティブコンパイラーを使って、ネイティブコンパイラーをビルドするようにします。
256           しかしここではクロスコンパイラーを作り出すつもりでいます。
257           したがって明示的に本オプションへ指定が必要になります。
258           </para>
259 @z
260
261 @x
262     <para>Compile the package:</para>
263 @y
264     <para>&CompileThePackage;</para>
265 @z
266
267 @x
268     <para>Install the package:</para>
269 @y
270     <para>&InstallThePackage;</para>
271 @z
272
273 @x
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>
280 @y
281     <para>
282     最後に、便利なシンボリックリンクを作成します。
283     プログラムやスクリプトの中には <command>gcc</command> ではなく <command>cc</command> を用いるものが結構あります。
284     シンボリックリンクを作ることで各種のプログラムを汎用的にすることができ、通常 GNU C コンパイラーがインストールされていない多くの UNIX システムでも利用できるものになります。
285     <command>cc</command> を利用することにすれば、システム管理者がどの C コンパイラーをインストールすべきかを判断する必要がなくなります。
286     </para>
287 @z
288
289 %@x
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>
293 %@y
294 %    <para>
295 %    この時点で、構築したツールチェーンの基本的な (コンパイルやリンクなどの) 機能が正しく動作していることを確認する必要があります。
296 %    健全性検査 (sanity check) を行うために以下を実行してください。
297 %    </para>
298 %@z
299
300 %@x
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>
303 %@y
304 %    <para>
305 %    問題なく動作した場合はエラーがなかったということで、最後のコマンドから出力される結果は以下のようになるはずです。
306 %    </para>
307 %@z
308
309 %@x
310 %    <para>Note that the dynamic linker will be /tools/lib/ld-linux.so.2 
311 %    for 32-bit machines.</para>
312 %@y
313 %    <para>
314 %    32 ビットマシンに対するダイナミックリンカーは /tools/lib/ld-linux.so.2 となります。
315 %    </para>
316 %@z
317
318 %@x
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"
332 %    role="."/></para>
333 %@y
334 %    <para>
335 %    コマンドの出力結果が上と異なっていたり、あるいは何も出力されなかった場合は、何かがおかしいことを意味します。
336 %    どこに問題があるのか調査、再試行を行って解消してください。
337 %    解決せずにこの先に進まないでください。
338 %    <command>cc</command> ではなく <command>gcc</command> を使って再度健全性検査を行ってみてください。
339 %    これで解決したなら <filename class="symlink">/tools/bin/cc</filename> のシンボリックリンクが正しくないということです。
340 %    正しく生成し直してください。
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=""/>での作業に間違いがあったのかもしれません。
346 %    </para>
347 %@z
348
349 %@x
350 %    <para>Once all is well, clean up the test files:</para>
351 %@y
352 %    <para>
353 %    すべてが終了したらテストファイルを削除します。
354 %    </para>
355 %@z
356
357 @x
358     <para>Details on this package are located in
359     <xref linkend="contents-gcc" role="."/></para>
360 @y
361     <para>
362     &Details1;<xref linkend="contents-gcc" role=""/>&Details2;
363     </para>
364 @z