[インデックス 16516] ファイルの概要
このコミットは、Go言語のソースからのインストール方法を説明する公式ドキュメント doc/install-source.html
の更新に関するものです。具体的には、Goコンパイラがサポートするアーキテクチャとオペレーティングシステムの組み合わせ、およびクロスコンパイルに関連する環境変数(特にARMと386アーキテクチャ向け)に関する情報が修正・追記されています。
コミット
- コミットハッシュ:
177191237e7400d5f277405f7340bd95d9b09676
- 作者: Shenghou Ma minux.ma@gmail.com
- コミット日時: 2013年6月9日 日曜日 23:15:39 +0800
- コミットメッセージの要約:
doc/install-source.html: recent ARM and 386 updates
GitHub上でのコミットページへのリンク
https://github.com/golang/go/commit/177191237e7400d5f277405f7340bd95d9b09676
元コミット内容
doc/install-source.html: recent ARM and 386 updates
R=golang-dev, dave, adg, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/6845083
変更の背景
このコミットの背景には、Go言語がサポートするプラットフォームの拡大と、それらのプラットフォーム上でのGoのビルドおよび実行に関するドキュメントの正確性を保つ必要性があります。特に、ARMおよび386アーキテクチャに対するGoのサポートが進化し、FreeBSDやNetBSDといった新たなOSでのARMサポート、そしてPlan 9のサポートが追加されたことを反映しています。
Go言語は、その設計思想の一つとして、多様なプラットフォームへの対応を重視しています。そのため、新しいOSやアーキテクチャへの移植が進むにつれて、公式ドキュメントもそれに合わせて更新される必要があります。このコミットは、Goのクロスコンパイル機能がより堅牢になり、特定のアーキテクチャ(ARM、386)における浮動小数点演算の扱いなど、より詳細な制御が可能になったことをユーザーに伝えるためのものです。
また、ドキュメントのフォーマット改善も行われており、環境変数の説明がより読みやすいリスト形式に変更されています。これは、ユーザーエクスペリエンスの向上を目的とした継続的なドキュメント整備の一環と考えられます。
前提知識の解説
このコミットを理解するためには、Go言語のビルドシステムとクロスコンパイルに関する以下の環境変数についての知識が不可欠です。
$GOROOT
: Goのインストールルートディレクトリを示します。Goのソースコードや標準ライブラリ、ツールなどが配置されています。通常、Goをビルドする際に自動的に設定されますが、複数のGoバージョンを切り替える場合などに手動で設定することがあります。$GOROOT_FINAL
: ビルドされたGoバイナリが最終的に配置されるパスを定義します。これは、ビルド時と実行時で$GOROOT
のパスが異なる場合に特に有用です。例えば、一時的なディレクトリでGoをビルドし、その後別の永続的な場所に移動させるようなシナリオで使われます。$GOOS
: ターゲットとなるオペレーティングシステムを指定します。例えば、linux
、windows
、darwin
(macOS)、freebsd
、netbsd
、plan9
などがあります。$GOARCH
: ターゲットとなるCPUアーキテクチャを指定します。例えば、amd64
(64-bit x86)、386
(32-bit x86)、arm
などがあります。$GOHOSTOS
: Goをビルドするホスト(現在のシステム)のオペレーティングシステムを指定します。通常は自動検出されます。$GOHOSTARCH
: Goをビルドするホスト(現在のシステム)のCPUアーキテクチャを指定します。通常は自動検出されます。$GOBIN
: Goのコマンド(go install
などでインストールされるバイナリ)が配置されるディレクトリを指定します。デフォルトは$GOROOT/bin
です。$GOARM
: ARMアーキテクチャ向けのビルドにおいて、ランタイムがターゲットとするARM浮動小数点コプロセッサのバージョンを指定します。これは、異なるARMプロセッサの浮動小数点ユニット(FPU)の有無やバージョンに対応するために重要です。GOARM=5
: ソフトウェア浮動小数点を使用します。FPUを持たないCPU向けです。GOARM=6
: VFPv1を使用します。クロスコンパイル時のデフォルトで、ARM11以降のコアでサポートされます。GOARM=7
: VFPv3を使用します。Cortex-Aコアなどで使用されます。
$GO386
: 386アーキテクチャ向けのビルドにおいて、浮動小数点演算に387コプロセッサを使用するか、SSE2命令を使用するかを制御します。GO386=387
: x87浮動小数点演算を使用します。Pentium MMX以降のすべてのx86チップをサポートします。GO386=sse2
: SSE2浮動小数点演算を使用します。387よりもパフォーマンスが優れていますが、Pentium 4/Opteron/Athlon 64以降のCPUでのみ利用可能です。
これらの環境変数は、Goのクロスコンパイルを行う際に、特定のターゲット環境に合わせたバイナリを生成するために非常に重要です。
技術的詳細
このコミットは、doc/install-source.html
という単一のHTMLドキュメントに対する変更であり、Goのビルドシステムそのもののコード変更ではなく、そのドキュメントの更新です。しかし、その内容はGoのクロスコンパイル能力とプラットフォームサポートに関する重要な技術的詳細を反映しています。
主な変更点は以下の通りです。
-
ARMアーキテクチャのサポート範囲の拡大:
- 以前は「Linuxバイナリのみをサポート」と記載されていたARMのサポートが、「Linux、FreeBSD、NetBSDバイナリをサポート」に更新されました。これは、GoがこれらのOS上でのARMアーキテクチャを公式にサポートするようになったことを示しています。
$GOOS
と$GOARCH
の有効な組み合わせの表に、freebsd/arm
とnetbsd/arm
が追加されました。これにより、これらの組み合わせでのクロスコンパイルが可能であることが明示されました。
-
Plan 9のサポート追加:
- Goコンパイラがターゲットとするオペレーティングシステムのリストに「Plan 9」が追加されました。
- 有効な
$GOOS
と$GOARCH
の組み合わせの表に、plan9/amd64
が追加されました。これは、GoがPlan 9上でのAMD64アーキテクチャをサポートすることを示しています。
-
環境変数説明のフォーマット変更:
$GOROOT
、$GOROOT_FINAL
、$GOOS
と$GOARCH
、$GOHOSTOS
と$GOHOSTARCH
、$GOBIN
といった環境変数の説明が、<p>
タグの連続から<ul>
と<li>
タグを用いたリスト形式に変更されました。これにより、ドキュメントの可読性が向上しています。
-
$GO386
環境変数の新規追加と詳細説明:- 386アーキテクチャ向けのビルドにおける浮動小数点演算の制御に関する
$GO386
環境変数が新たに導入され、その詳細な説明が追加されました。 GO386=387
(x87 FPU使用)とGO386=sse2
(SSE2命令使用)の2つのオプションが説明され、それぞれの互換性とパフォーマンス特性が明記されました。これは、386アーキテクチャの多様なCPUにおける浮動小数点演算の最適化を可能にします。
- 386アーキテクチャ向けのビルドにおける浮動小数点演算の制御に関する
-
$GOARM
環境変数の詳細説明の拡充:- 既存の
$GOARM
環境変数について、より詳細な説明が追加されました。 GOARM=5
、GOARM=6
、GOARM=7
の各値が具体的にどのARM浮動小数点コプロセッサのバージョンに対応するのか、そしてそれぞれの用途(ソフトウェア浮動小数点、VFPv1、VFPv3)が明確にされました。- クロスコンパイル時のデフォルト値や、ターゲットシステムでビルドする場合の自動検出についても言及されています。
- GoコミュニティWikiのGoARMページへのリンクも追加され、さらなる情報源が提供されました。
- 既存の
これらの変更は、Go言語がより多くの組み込みシステムやレガシーシステム、あるいは特定のサーバー環境に対応するための継続的な努力の一環を示しています。特に、ARMと386アーキテクチャにおける浮動小数点演算の細かな制御は、パフォーマンスが重要となるアプリケーションや、特定のハードウェア要件を持つ環境でのGoの利用を促進します。
コアとなるコードの変更箇所
このコミットは、doc/install-source.html
という単一のHTMLファイルに対する変更です。
--- a/doc/install-source.html
+++ b/doc/install-source.html
@@ -57,7 +57,7 @@ architectures.
<code>arm</code> (a.k.a. <code>ARM</code>); <code>5g,5l,5c,5a</code>
</dt>
<dd>
- Supports only Linux binaries. Less widely used than the other ports and therefore not as thoroughly tested.
+ Supports Linux, FreeBSD and NetBSD binaries. Less widely used than the other ports.
</dd>
</dl>
@@ -69,7 +69,7 @@ goroutines, such as stacks that grow and shrink on demand.\n </p>\n \n <p>\n-The compilers can target the FreeBSD, Linux, NetBSD, OpenBSD, OS X (Darwin),\n+The compilers can target the FreeBSD, Linux, NetBSD, OpenBSD, OS X (Darwin), Plan 9,\n and Windows operating systems.\n The full set of supported combinations is listed in the discussion of\n <a href=\"#environment\">environment variables</a> below.\n@@ -273,9 +273,8 @@ The Go compilation environment can be customized by environment variables.\n to override the defaults.\n </p>\n \n-<blockquote>\n-\n-<p><code>$GOROOT</code></p>\n+<ul>\n+<li><code>$GOROOT</code>\n <p>\n The root of the Go tree, often <code>$HOME/go</code>.\n Its value is built into the tree when it is compiled, and\n@@ -284,7 +283,7 @@ There is no need to set this unless you want to switch between multiple\n local copies of the repository.\n </p>\n \n-<p><code>$GOROOT_FINAL</code></p>\n+<li><code>$GOROOT_FINAL</code>\n <p>\n The value assumed by installed binaries and scripts when\n <code>$GOROOT</code> is not set explicitly.\n@@ -294,7 +293,7 @@ but move it elsewhere after the build, set\n <code>$GOROOT_FINAL</code> to the eventual location.\n </p>\n \n-<p><code>$GOOS</code> and <code>$GOARCH</code></p>\n+<li><code>$GOOS</code> and <code>$GOARCH</code>\n <p>\n The name of the target operating system and compilation architecture.\n These default to the values of <code>$GOHOSTOS</code> and\n@@ -311,7 +310,7 @@ Choices for <code>$GOARCH</code> are\n The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:\n <table cellpadding=\"0\">\n <tr>\n-<th width=\"50\"><th align=\"left\" width=\"100\"><code>$GOOS</code></th> <th align=\"left\" width=\"100\"><code>$GOARCH</code></th> <th align=\"left\"></th>\n+<th width=\"50\"></th><th align=\"left\" width=\"100\"><code>$GOOS</code></th> <th align=\"left\" width=\"100\"><code>$GOARCH</code></th>\n </tr>\n <tr>\n <td></td><td><code>darwin</code></td> <td><code>386</code></td>\n@@ -326,6 +325,9 @@ The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:\n <td></td><td><code>freebsd</code></td> <td><code>amd64</code></td>\n </tr>\n <tr>\n+<td></td><td><code>freebsd</code></td> <td><code>arm</code></td>\n+</tr>\n+<tr>\n <td></td><td><code>linux</code></td> <td><code>386</code></td>\n </tr>\n <tr>\n@@ -341,6 +343,9 @@ The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:\n <td></td><td><code>netbsd</code></td> <td><code>amd64</code></td>\n </tr>\n <tr>\n+<td></td><td><code>netbsd</code></td> <td><code>arm</code></td>\n+</tr>\n+<tr>\n <td></td><td><code>openbsd</code></td> <td><code>386</code></td>\n </tr>\n <tr>\n@@ -350,6 +355,9 @@ The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:\n <td></td><td><code>plan9</code></td> <td><code>386</code></td>\n </tr>\n <tr>\n+<td></td><td><code>plan9</code></td> <td><code>amd64</code></td>\n+</tr>\n+<tr>\n <td></td><td><code>windows</code></td> <td><code>386</code></td>\n </tr>\n <tr>\n@@ -357,7 +365,7 @@ The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are:\n </tr>\n </table>\n \n-<p><code>$GOHOSTOS</code> and <code>$GOHOSTARCH</code></p>\n+<li><code>$GOHOSTOS</code> and <code>$GOHOSTARCH</code>\n <p>\n The name of the host operating system and compilation architecture.\n These default to the local system\'s operating system and\n@@ -372,7 +380,7 @@ For example, you should not set <code>$GOHOSTARCH</code> to\n <code>arm</code> on an x86 system.\n </p>\n \n-<p><code>$GOBIN</code>\n+<li><code>$GOBIN</code>\n <p>\n The location where Go binaries will be installed.\n The default is <code>$GOROOT/bin</code>.\n@@ -382,15 +390,38 @@ If <code>$GOBIN</code> is set, the <a href=\"/cmd/go\">go command</a>\n installs all commands there.\n </p>\n \n-<p><code>$GOARM</code> (arm, default=6)</p>\n+<li><code>$GO386</code> (for <code>386</code> only, default is auto-detected\n+if built natively, <code>387</code> if not)\n+<p>\n+This controls the code generated by 8g to use either the 387 floating-point unit\n+(set to <code>387</code>) or SSE2 instructions (set to <code>sse2</code>) for\n+floating point computations.\n+</p>\n+<ul>\n+\t<li><code>GO386=387</code>: use x87 for floating point operations; should support all x86 chips (Pentium MMX or later).\n+\t<li><code>GO386=sse2</code>: use SSE2 for floating point operations; has better performance than 387, but only available on Pentium 4/Opteron/Athlon 64 or later.\n+</ul>\n+\n+<li><code>$GOARM</code> (for <code>arm</code> only; default is auto-detected if building\n+on the target processor, 6 if not)\n+<p>\n+This sets the ARM floating point co-processor architecture version the run-time\n+should target. If you are compiling on the target system, its value will be auto-detected.\n+</p>\n+<ul>\n+\t<li><code>GOARM=5</code>: use software floating point; when CPU doesn\'t have VFP co-processor\n+\t<li><code>GOARM=6</code>: use VFPv1 only; default if cross compiling; usually ARM11 or better cores (VFPv2 or better is also supported)\n+\t<li><code>GOARM=7</code>: use VFPv3; usually Cortex-A cores\n+</ul>\n <p>\n-The ARM architecture version the run-time libraries should target.\n-Setting <code>$GOARM</code> to 5 causes the linker to emit calls\n-to a software floating point implementation instead of using\n-hardware floating point support.\n+If in doubt, leave this variable unset, and adjust it if required\n+when you first run the Go executable.\n+The <a href=\"http://code.google.com/p/go-wiki/wiki/GoArm\">GoARM</a> page\n+on the <a href=\"http://code.google.com/p/go-wiki/w/list\">Go community wiki</a>\n+contains further details regarding Go\'s ARM support.\n </p>\n \n-</blockquote>\n+</ul>\n```
## コアとなるコードの解説
上記の差分から、以下の主要な変更点とその意味を解説します。
1. **ARMサポートの記述変更 (行 57-60)**:
* `- Supports only Linux binaries. Less widely used than the other ports and therefore not as thoroughly tested.`
* `+ Supports Linux, FreeBSD and NetBSD binaries. Less widely used than the other ports.`
* これは、GoのARMポートがLinuxだけでなく、FreeBSDとNetBSDもサポートするようになったことを明確に示しています。これにより、Goがより多くの組み込みシステムやネットワーク機器で利用可能になったことを意味します。
2. **ターゲットOSリストへのPlan 9の追加 (行 69-72)**:
* `- The compilers can target the FreeBSD, Linux, NetBSD, OpenBSD, OS X (Darwin),`
* `+ The compilers can target the FreeBSD, Linux, NetBSD, OpenBSD, OS X (Darwin), Plan 9,`
* GoコンパイラがPlan 9オペレーティングシステムをターゲットにできるようになったことを示しています。Plan 9はベル研究所で開発された分散オペレーティングシステムであり、Goがその環境でも動作するようになったことを意味します。
3. **環境変数セクションのフォーマット変更 (行 273-276, 284-287, 294-297, 357-360, 372-375)**:
* `<blockquote>`タグと`<p>`タグの組み合わせから、`<ul>`と`<li>`タグの組み合わせに変更されています。これは、HTMLのセマンティクスを改善し、環境変数のリストをより構造化された形で表現するための変更です。これにより、ドキュメントの可読性とアクセシビリティが向上します。
4. **`$GOOS`と`$GOARCH`の組み合わせ表のヘッダー変更 (行 311-314)**:
* `- <th width="50"><th align="left" width="100"><code>$GOOS</code></th> <th align="left" width="100"><code>$GOARCH</code></th> <th align="left"></th>`
* `+ <th width="50"></th><th align="left" width="100"><code>$GOOS</code></th> <th align="left" width="100"><code>$GOARCH</code></th>`
* テーブルヘッダーの不要な`<th>`タグが削除され、より簡潔な記述になっています。
5. **`$GOOS`と`$GOARCH`の組み合わせ表への新規エントリ追加 (行 326-329, 341-344, 350-353)**:
* `+ <td></td><td><code>freebsd</code></td> <td><code>arm</code></td>`
* `+ <td></td><td><code>netbsd</code></td> <td><code>arm</code></td>`
* `+ <td></td><td><code>plan9</code></td> <td><code>amd64</code></td>`
* これらの行は、GoがFreeBSD/ARM、NetBSD/ARM、およびPlan 9/AMD64の組み合わせを正式にサポートするようになったことを明示しています。これは、Goのクロスコンパイルターゲットが拡大したことを示す重要な情報です。
6. **`$GO386`環境変数の新規追加と説明 (行 382-390)**:
* `+ <li><code>$GO386</code> (for <code>386</code> only, default is auto-detected if built natively, <code>387</code> if not)`
* `+ <p>This controls the code generated by 8g to use either the 387 floating-point unit (set to <code>387</code>) or SSE2 instructions (set to <code>sse2</code>) for floating point computations.</p>`
* `+ <ul>`
* `+ <li><code>GO386=387</code>: use x87 for floating point operations; should support all x86 chips (Pentium MMX or later).`
* `+ <li><code>GO386=sse2</code>: use SSE2 for floating point operations; has better performance than 387, but only available on Pentium 4/Opteron/Athlon 64 or later.`
* 386アーキテクチャ向けのビルドにおいて、浮動小数点演算にx87 FPUを使用するか、SSE2命令を使用するかを選択できるようになったことを示しています。これにより、特定の386プロセッサの特性に合わせて、生成されるコードのパフォーマンスを最適化することが可能になります。
7. **`$GOARM`環境変数の詳細説明の拡充 (行 392-410)**:
* 既存の`$GOARM`の説明が大幅に拡張され、`GOARM=5`、`GOARM=6`、`GOARM=7`の各値が具体的にどのARM浮動小数点コプロセッサのバージョンに対応するのか、そしてそれぞれの用途が詳細に説明されています。
* クロスコンパイル時のデフォルト値や、ターゲットシステムでビルドする場合の自動検出についても言及されています。
* GoコミュニティWikiのGoARMページへのリンクも追加され、ユーザーがさらに詳細な情報を得られるようになりました。これは、ARMベースのデバイスが多様であるため、ユーザーが適切な設定を選択できるようにするための重要な情報です。
これらの変更は、Go言語が多様なハードウェアとOSの組み合わせに対応し、特に組み込みシステムや特定のサーバー環境での利用を強化するための継続的な取り組みを反映しています。
## 関連リンク
* **Go Change List**: [https://golang.org/cl/6845083](https://golang.org/cl/6845083)
* **GoARM Wiki Page**: [http://code.google.com/p/go-wiki/wiki/GoArm](http://code.google.com/p/go-wiki/wiki/GoArm)
* **Go Community Wiki List**: [http://code.google.com/p/go-wiki/w/list](http://code.google.com/p/go-wiki/w/list)
## 参考にした情報源リンク
* この解説は、提供されたコミット情報(`./commit_data/16516.txt`)のdiffとコミットメッセージに基づいて作成されました。
* Go言語の公式ドキュメントにおける`GOOS`、`GOARCH`、`GOARM`、`GO386`などの環境変数に関する一般的な知識。
* HTMLのセマンティクスとタグ(`<blockquote>`, `<p>`, `<ul>`, `<li>`)に関する一般的な知識。
* クロスコンパイルと浮動小数点演算の概念に関する一般的な知識。