OSDN Git Service

b768eb53840eb66c882d50d2265acd2888b37af5
[lfsbookja/lfsja-git.git] / src / chapter05 / gcc-pass1.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-pass1" role="wrap" xreflabel="gcc-pass1">
14 @y
15 <sect1 id="ch-tools-gcc-pass1" role="wrap" xreflabel="gcc 1 回め">
16 @z
17
18 @x
19   <title>GCC-&gcc-version; - Pass 1</title>
20 @y
21   <title>GCC-&gcc-version; - 1回め</title>
22 @z
23
24 @x
25   <indexterm zone="ch-tools-gcc-pass1">
26     <primary sortas="a-GCC">GCC</primary>
27     <secondary>tools, pass 1</secondary>
28   </indexterm>
29 @y
30   <indexterm zone="ch-tools-gcc-pass1">
31     <primary sortas="a-GCC">GCC</primary>
32     <secondary>&Tools;, 1回め</secondary>
33   </indexterm>
34 @z
35
36 @x
37     <title>Installation of Cross GCC</title>
38 @y
39     <title>&InstallationOf1;クロスコンパイル版 GCC&InstallationOf2;</title>
40 @z
41
42 @x
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
47     use them:</para>
48 @y
49     <para>
50     GCC は GMP、MPFR、MPC の各パッケージを必要とします。
51     これらのパッケージはホストシステムに含まれていないかもしれないため、以下を実行してビルドの準備をします。
52     個々のパッケージを GCC ソースディレクトリの中に伸張 (解凍) し、ディレクトリ名を変更します。
53     これは GCC のビルド処理においてそれらを自動的に利用できるようにするためです。
54     </para>
55 @z
56
57 @x
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>
63 @y
64     <note><para>
65     本節においては誤解が多く発生しています。
66     ここでの手順は他のものと同様であり、手順の概要 (<xref linkend='buildinstr'/>) は説明済です。
67     まず初めに gcc の tarball を伸張 (解凍) し、生成されたソースディレクトリに移動します。
68     それに加えて本節では、以下の手順を行うものとなります。
69     </para></note>
70 @z
71
72 %@x
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.
77 %    Issue:</para>
78 %@y
79 %    <para>
80 %    以下のコマンドは GCC のデフォルトのダイナミックリンカーの配置ディレクトリを、既にインストールされている <filename
81 %    class="directory">/tools</filename> とします。
82 %    また GCC のインクルードパスから <filename
83 %    class="directory">/usr/include</filename> を除きます。
84 %    </para>
85 %@z
86
87 %@x
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>
103 %@y
104 %    <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> を用いるのは、誤ってコマンドを二度起動したとしてもオリジナルファイルを壊さないようにするためです。
115 %    </para>
116 %@z
117
118 @x
119     <para>On x86_64 hosts, set the default directory name for
120     64-bit libraries to <quote>lib</quote>:</para>
121 @y
122     <para>
123     x86_64 ホストにおいて、64 ビットライブラリに対するデフォルトのディレクトリ名は<quote>lib</quote>です。
124     </para>
125 @z
126
127 %@x
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
130 %    command:</para>
131 %@y
132 %    <para>
133 %    GCC はスタックプロテクション (stack protection) を正しく検出しません。
134 %    このことは Glibc-&glibc-version; においてビルドする際には問題となります。
135 %    そこで以下のコマンドを実行することで解消します。
136 %    </para>
137 %@z
138
139 %@x
140 %    <para>Also fix a problem identified upstream:</para>
141 %@y
142 %    <para>
143 %    アップストリームが認識している問題を修正します。
144 %    </para>
145 %@z
146
147 @x
148     <para>The GCC documentation recommends building GCC
149     in a dedicated build directory:</para>
150 @y
151     <para>
152     GCC のドキュメントでは、専用のビルドディレクトリを作成することが推奨されています。
153     </para>
154 @z
155
156 @x
157     <para>Prepare GCC for compilation:</para>
158 @y
159     <para>&PreparePackage1;GCC&PreparePackage2;</para>
160 @z
161
162 @x
163       <title>The meaning of the configure options:</title>
164 @y
165       <title>&MeaningOfOption1;configure&MeaningOfOption2;</title>
166 @z
167
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
173           distro.</para>
174 @y
175           <para>
176           このオプションは、ターゲットにおいて用いられることになる glibc のバージョンを指定します。
177           これはホストディストリビューションにある libc のバージョンとは関係がありません。
178           1 回めの gcc によってコンパイルされるものは、すべて chroot 環境内で実行されるものであって、ホストにある libc とは切り離されているためです。
179           </para>
180 @z
181
182 @x --with-newlib
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>
186 @y
187           <para>
188           この時点では利用可能な C ライブラリがまだ存在しません。
189           したがって libgcc のビルド時に inhibit_libc 定数を定義します。
190           これを行うことで、libc サポートを必要とするコード部分をコンパイルしないようにします。
191           </para>
192 @z
193
194 @x --without-headers
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>
199 @y
200           <para>
201           完璧なクロスコンパイラーを構築するなら、GCC はターゲットシステムに互換性を持つ標準ヘッダーを必要とします。
202           本手順においては標準ヘッダーは必要ありません。
203           このスイッチは GCC がそういったヘッダーを探しにいかないようにします。
204           </para>
205 @z
206
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>
212 %@y
213 %          <para>
214 %          ローカルプリフックス (local prefix) は、GCC がローカルにインストールされているインクルードファイルを探しにいくディレクトリを意味します。
215 %          そのデフォルトは <filename>/usr/local</filename> です。
216 %          この設定を <filename>/tools</filename> とすることで、GCC が探し出すパスから <filename>/usr/local</filename> を除外します。
217 %          </para>
218 %@z
219
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
228 %          found.</para>
229 %@y
230 %          <para>
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回めのビルドでは、同じスイッチを用いて、ホストシステムのヘッダーは一切見つけ出さないようにします。
236 %          </para>
237 %@z
238
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
242           compiler.</para>
243 @y
244           <para>
245           このスイッチは内部データ構造を利用することを指示します。
246           クロスコンパイラーのビルド時にこれが必要になりますが、自動では設定されません。
247           </para>
248 @z
249
250 @x --disable-shared
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>
254 @y
255           <para>
256           このスイッチは内部ライブラリをスタティックライブラリとしてリンクすることを指示します。
257           共有ライブラリが glibc を必要としており、処理しているシステム上にはまだインストールされていないためです。
258           </para>
259 @z
260
261 @x --disable-multilib
262           <para>On x86_64, LFS does not support a multilib configuration.
263           This switch is harmless for x86.</para>
264 @y
265           <para>
266           x86_64 に対して LFS は multilib のサポートをしていません。
267           このオプション指定は x86 には無関係です。
268           </para>
269 @z
270
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>
277 @y
278           <para>
279           これらのオプションは順に、十進浮動小数点制御、スレッド処理、libatomic, libgomp, libquadmath, libssp, libvtv, C++ 標準ライブラリのサポートをいずれも無効にすることを指示します。
280           これらの機能を含めていると、クロスコンパイラーをビルドする際にはコンパイルに失敗します。
281           またクロスコンパイルによって一時的な libc ライブラリを構築する際には不要なものです。
282           </para>
283 @z
284
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>
288 @y
289           <para>
290           このオプションは C コンパイラーおよび C++ コンパイラーのみビルドすることを指示します。
291           この時点で必要なのはこの言語だけだからです。
292           </para>
293 @z
294
295 @x
296     <para>Compile GCC by running:</para>
297 @y
298     <para>GCC をコンパイルします。</para>
299 @z
300
301 %@x
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
306 %    replaced.</para>
307 %@y
308 %    <para>
309 %    コンパイルが終了しました。
310 %    この時点でもテストスイートを実行することはできます。
311 %    ただ前にも述べているように、テストスイートのフレームワークがまだ準備できていません。
312 %    さらにこの時点で生成されるプログラムは、すぐに次の生成作業によって置き換えられますから、この時点でテストを実行することはあまり意味がありません。
313 %    </para>
314 %@z
315
316 @x
317     <para>Install the package:</para>
318 @y
319     <para>&InstallThePackage;</para>
320 @z
321
322 % @x
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>
330 % @y
331 %     <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> の中にも含まれることになるからです。
336 %     </para>
337 % @z
338
339 @x
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>
351 @y
352     <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 ビルドが通常行っている方法と同じものです。
361     </para>
362 @z
363
364 @x
365     <para>Details on this package are located in
366     <xref linkend="contents-gcc" role="."/></para>
367 @y
368     <para>
369     &Details1;<xref linkend="contents-gcc" role=""/>&Details2;
370     </para>
371 @z