Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

[インデックス 12032] ファイルの概要

このコミットは、doc/gccgo_contribute.html ファイルの更新に関するものです。このファイルは、GCC の Go フロントエンドである gccgo への貢献方法について説明するドキュメントです。

コミット

  • コミットハッシュ: 253c139275d4997f466157dcfd0699bd6227751e
  • Author: Ian Lance Taylor iant@golang.org
  • Date: Sat Feb 18 11:15:52 2012 -0800
  • Subject: doc: update gccgo_contribute.html

GitHub上でのコミットページへのリンク

https://github.com/golang/go/commit/253c139275d4997f466157dcfd0699bd6227751e

元コミット内容

doc: update gccgo_contribute.html

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5673080

変更の背景

このコミットは、gccgo プロジェクトへの貢献に関するドキュメント gccgo_contribute.html を更新することを目的としています。時間の経過とともに、プロジェクトの構造、貢献プロセス、および関連するリポジトリ間の関係が進化するため、ドキュメントを最新の状態に保つことが不可欠です。特に、著作権規則、ソースコードのミラーリング方法、テスト手順、および変更の提出方法に関する記述が、実際の運用と乖離していたため、それらを修正し、より明確なガイドラインを提供するためにこの更新が行われました。これにより、新規貢献者がスムーズにプロジェクトに参加できるようになります。

前提知識の解説

gccgoとは

gccgo は、Go プログラミング言語のための GCC (GNU Compiler Collection) のフロントエンドです。コンパイラにおける「フロントエンド」とは、特定のプログラミング言語のソースコードを処理する部分を指します。これには、字句解析、構文解析、意味解析が含まれ、最終的に中間表現 (IR) を生成します。この IR は、その後、コンパイラの「ミドルエンド」(最適化)と「バックエンド」(特定のアーキテクチャ向けコード生成)に渡されます。

gccgo は、Go プログラムを GCC インフラストラクチャを使用してコンパイルすることを可能にし、GCC の広範な最適化機能と多様なプロセッサアーキテクチャのサポートから恩恵を受けます。

Goコンパイラの二つの主要な実装: gcgccgo

Go 言語には主に二つのコンパイラ実装があります。

  1. gc (標準 Go コンパイラ): これは Go ツールチェーンにデフォルトで含まれる公式のコンパイラです。Go 言語の新しい機能は通常、まず gc に実装されます。コンパイル速度は一般的に gccgo よりも高速です。
  2. gccgo: GCC の一部として提供される Go コンパイラです。gc と比較して、gccgo は GCC の強力な最適化機能を活用するため、より最適化されたコードを生成する傾向があります。また、GCC がサポートするすべてのプロセッサ(x86, ARM に加えて SPARC, MIPS, PowerPC, Alpha など)をサポートするため、より広範なアーキテクチャに対応できます。ただし、コンパイル速度は gc よりも遅くなることがあります。

gofrontendプロジェクトとGCCとの関係

gofrontend プロジェクトは、gccgo のコンパイラフロントエンドを提供する C++ で書かれた独立したプロジェクトです。このプロジェクトは、それ自体ではビルド可能ではなく、GCC と組み合わせてのみ機能します。gofrontend リポジトリで行われた変更は、定期的に gcc.gnu.org でホストされている GCC のソースコードリポジトリにミラーリングされます。

具体的には、gofrontend リポジトリの go ディレクトリは GCC リポジトリの gcc/go/gofrontend ディレクトリに、gofrontendlibgo ディレクトリは GCC の libgo ディレクトリにミラーリングされます。また、メインの Go リポジトリの test ディレクトリは、GCC リポジトリの gcc/testsuite/go.test/test ディレクトリにミラーリングされます。このミラーリングプロセスにより、gofrontend のマスターソースが常に GCC リポジトリの gccgo 関連コードの最新の状態を反映するようになっています。

技術的詳細

このコミットは、doc/gccgo_contribute.html ドキュメントの複数のセクションにわたる重要な更新を含んでいます。

  1. 著作権規則の明確化:

    • 以前は、gccgo への変更はすべて Go の著作権規則に従うとされていました。
    • 更新後、gccgo フロントエンドと関連する libgo ライブラリへの変更は Go の著作権規則に従う必要がある一方で、GCC の一部であるコードは一般的な GCC の貢献規則に従う必要があることが明確にされました。これは、gccgo が Go プロジェクトと GCC プロジェクトの両方のエコシステムにまたがる性質を反映しています。
  2. ソースコードのミラーリングプロセスの詳細化:

    • 以前は、gofrontend の変更が「ルーチン的に gcc.gnu.org のソースコードにマージされる」と漠然と記述されていました。
    • 更新後、gofrontend のマスターソースがそれ自体ではビルドできず、GCC と組み合わせてのみ機能することが明記されました。
    • gofrontend リポジトリの特定のディレクトリ (golibgo) が、GCC リポジトリの対応するディレクトリ (gcc/go/gofrontendlibgo) にどのようにミラーリングされるかが詳細に説明されました。
    • メインの Go リポジトリの test ディレクトリが、GCC リポジトリの gcc/testsuite/go.test/test ディレクトリにミラーリングされることも追記されました。
    • 最も重要な変更点として、「これらのディレクトリへの変更は常にマスターソースから GCC リポジトリに流れる。ファイルはマスターソースで変更され、ミラーリングされる以外は GCC リポジトリで変更されるべきではない」という、一方向のミラーリングポリシーが強調されました。
  3. C++ コーディング標準とコードの独立性:

    • 以前は、フロントエンドが C++ で書かれているため GNU コーディング標準が完全に適用されない可能性があり、周囲のコードのフォーマットに従うべきだとされていました。また、将来的に gccgo をより独立させる計画があり、GCC 固有のコードは gcc-interface サブディレクトリに移行すべきだとされていました。
    • 更新後、gccgo フロントエンドが C++ で書かれており、C++ に適用される範囲で GNU コーディング標準に従うことが明記されました。
    • 「最終的にすべての GCC 固有のコードは、フロントエンド本体から GCC 本体に移行する」という計画がより具体的に示され、GCC ソース内では gcc/go/gofrontend から gcc/go へのコード移動を意味することが追記されました。これは、gccgo のコアロジックと GCC 固有の統合部分を明確に分離しようとする意図を示しています。
  4. ランタイムライブラリ (libgo) のマージプロセス:

    • 以前は、libgo がメインの Go リポジトリから定期的に gofrontend および GCC リポジトリにコピーされると記述されていました。
    • 更新後、libgo がメインの Go リポジトリから gofrontendlibgo/go ディレクトリ、そして GCC リポジトリに、libgo/merge.sh というシェルスクリプトを使用して定期的にマージされることが詳細に説明されました。
    • libgo/go 以外のファイルは gccgo 固有のものであること、そして libgo/runtime の一部のファイルがメインの Go リポジトリの src/pkg/runtime のファイルに基づいていることが追記されました。
  5. テスト手順の更新:

    • 以前は、コンパイラテスト (make check-go) とライブラリテスト (make check-target-libgo) が別々に記述されていました。
    • 更新後、make check-go を実行することで、gcc/testsuite/go.* のテストと libgo テストスイートの両方が実行されることが明確にされました。これにより、テスト実行のコマンドが簡素化され、より包括的なテストが一度に実行されるようになりました。
    • 新しいテストはほとんどの場合、メインの Go リポジトリに提出され、その後 GCC リポジトリにミラーリングされるべきであるという方針が再確認されました。gccgo 固有のテストが必要な場合は、gcc/testsuite/go.go-torture または gcc/testsuite/go.dg ディレクトリに配置されるべきであるとされています。

これらの変更は、gccgo プロジェクトの貢献ガイドラインをより正確で、詳細かつ最新の状態に保つことを目的としています。

コアとなるコードの変更箇所

--- a/doc/gccgo_contribute.html
+++ b/doc/gccgo_contribute.html
@@ -5,90 +5,95 @@
 <h2>Introduction</h2>
 
 <p>
-These are some notes on contributing to the <code>gccgo</code>
-frontend for GCC.  For information on contributing to parts of Go other
-than <code>gccgo</code>, see <a href=\"contribute.html\">Contributing to
-the Go project</a>.  For information on building <code>gccgo</code>
-for yourself, see <a href=\"gccgo_install.html\">Setting up and using
-gccgo</a>.\n+These are some notes on contributing to the gccgo frontend for GCC.\n+For information on contributing to parts of Go other than gccgo,\n+see <a href=\"contribute.html\">Contributing to the Go project</a>.  For\n+information on building gccgo for yourself,\n+see <a href=\"gccgo_install.html\">Setting up and using gccgo</a>.\n </p>
 
 <h2>Legal Prerequisites</h2>
 
 <p>
  You must follow the <a href=\"contribute.html#copyright\">Go copyright\n-rules.</a>\n+rules</a> for all changes to the gccgo frontend and the associated\n+libgo library.  Code that is part of GCC rather than gccgo must follow\n+the general <a href=\"http://gcc.gnu.org/contribute.html\">GCC\n+contribution rules</a>.\n </p>
 
 <h2>Code</h2>
 
 <p>
-The source code for the <code>gccgo</code> frontend may be found at\n+The master sources for the gccgo frontend may be found at\n <a href=\"http://code.google.com/p/gofrontend\">http://code.google.com/p/gofrontend</a>.\n-Changes made to that project are routinely merged into the source code\n-hosted at <code>gcc.gnu.org</code>.  The <code>gofrontend</code>\n-project includes only the Go frontend proper.  These are the files\n-which in the <code>gcc</code> sources may be found in the\n-directories <code>gcc/go</code> and <code>libgo</code>.\n-The <code>gcc</code> sources also include a copy of\n-the <code>test</code> directory\n-from <a href=\"http://code.google.com/p/go\">the main Go repository</a>.\n+The master sources are not buildable by themselves, but only in\n+conjunction with GCC (in the future, other compilers may be\n+supported).  Changes made to the gccgo frontend are also applied to\n+the GCC source code repository hosted at <code>gcc.gnu.org</code>.  In\n+the <code>gofrontend</code> repository, the <code>go</code> directory\n+is mirrored to the <code>gcc/go/gofrontend</code> directory in the GCC\n+repository, and the <code>gofrontend</code> <code>libgo</code>\n+directory is mirrored to the GCC <code>libgo</code> directory.  In\n+addition, the <code>test</code> directory\n+from <a href=\"http://code.google.com/p/go\">the main Go repository</a>\n+is mirrored to the <code>gcc/testsuite/go.test/test</code> directory\n+in the GCC repository.\n </p>
 
 <p>
-The frontend is written in C++ and as such the GNU coding standards do\n-not entirely apply; in writing code for the frontend, follow the\n-formatting of the surrounding code.  Although the frontend is\n-currently closely tied to the rest of the <code>gcc</code> codebase,\n-we plan to make it more independent.  Any new code that uses other\n-parts of <code>gcc</code> should be placed in an appropriate file,\n-such as <code>gogo-tree.cc</code>.  Eventually\n-all <code>gcc</code>-specific code should migrate to\n-a <code>gcc-interface</code> subdirectory.\n+Changes to these directories always flow from the master sources to\n+the GCC repository.  The files should never be changed in the GCC\n+repository except by changing them in the master sources and mirroring\n+them.\n </p>
 
 <p>
-The run-time library for <code>gccgo</code> is mostly the same as the\n-library in <a href=\"http://code.google.com/p/go\">the main Go\n-repository</a>.  The library code in the Go repository is periodically\n-copied into the <code>gofrontend</code> and the <code>gcc</code>\n-repositories.  Accordingly, most library changes should be made in the\n-main Go repository.  Changes to the few <code>gccgo</code>-specific\n-parts of the library should follow the process described here.\n-The <code>gccgo</code>-specific parts of the library are everything in\n-the <code>libgo</code> directory except for the <code>libgo/go</code>\n-subdirectory.\n+The gccgo frontend is written in C++.  It follows the GNU coding\n+standards to the extent that they apply to C++.  In writing code for\n+the frontend, follow the formatting of the surrounding code.  Although\n+the frontend is currently tied to the rest of the GCC codebase, we\n+plan to make it more independent.  Eventually all GCC-specific code\n+will migrate out of the frontend proper and into GCC proper.  In the\n+GCC sources this will generally mean moving code\n+from <code>gcc/go/gofrontend</code> to <code>gcc/go</code>.\n </p>
 
-<h2>Testing</h2>
-\n <p>
-All patches must be tested.  There are two test suites.  A patch that\n-introduces new failures is not acceptable.\n+The run-time library for gccgo is mostly the same as the library\n+in <a href=\"http://code.google.com/p/go\">the main Go repository</a>.\n+The library code in the Go repository is periodically merged into\n+the <code>libgo/go</code> directory of the <code>gofrontend</code> and\n+then the GCC repositories, using the shell\n+script <code>libgo/merge.sh</code>.  Accordingly, most library changes\n+should be made in the main Go repository.  The files outside\n+of <code>libgo/go</code> are gccgo-specific; that said, some of the\n+files in <code>libgo/runtime</code> are based on files\n+in <code>src/pkg/runtime</code> in the main Go repository.\n </p>
 
+<h2>Testing</h2>
+
 <p>
-To run the compiler test suite, run <code>make check-go</code> in the\n-<code>gcc</code> subdirectory of your build directory.  This will run\n-various tests underneath <code>gcc/testsuite/go.*</code>.  This\n-includes a copy of the tests in the main Go repository, which are run\n-using the DejaGNU script found in\n-in <code>gcc/testsuite/go.test/go-test.exp</code>.  Many of the\n-compiler tests may be run without the Go library, but some do require\n-the library to built first.\n+All patches must be tested.  A patch that introduces new failures is\n+not acceptable.\n </p>
 
 <p>
-To run the library test suite, run <code>make\n-check-target-libgo</code> in the top level of your build directory.\n+To run the gccgo test suite, run <code>make check-go</code> in your\n+build directory.  This will run various tests\n+under <code>gcc/testsuite/go.*</code> and will also run\n+the <code>libgo</code> testsuite.  This copy of the tests from the\n+main Go repository is run using the DejaGNU script found in\n+in <code>gcc/testsuite/go.test/go-test.exp</code>.\n </p>
 
 <p>
-Most new tests should be submitted to the main Go repository for\n-copying into the <code>gccgo</code> repository.  If there is a need\n-for specific tests for <code>gccgo</code>, they should go in\n+Most new tests should be submitted to the main Go repository for later\n+mirroring into the GCC repository.  If there is a need for specific\n+tests for gccgo, they should go in\n the <code>gcc/testsuite/go.go-torture</code>\n-or <code>gcc/testsuite/go.dg</code> directories in\n-the <code>gcc.gnu.org</code> repository.\n+or <code>gcc/testsuite/go.dg</code> directories in the GCC repository.\n </p>
 
 <h2>Submitting Changes</h2>
@@ -97,5 +102,5 @@ the <code>gcc.gnu.org</code> repository.\n Changes to the Go frontend should follow the same process as for the\n main Go repository, only for the <code>gofrontend</code> project\n rather than the <code>go</code> project.  Those changes will then be\n-merged into the <code>gcc</code> sources.\n+merged into the GCC sources.\n </p>

コアとなるコードの解説

このコミットは、doc/gccgo_contribute.html ファイル内の以下の主要なセクションを更新しています。

  1. Legal Prerequisites (法的要件):

    • 変更前: gccgo へのすべての変更は Go の著作権規則に従うとされていました。
    • 変更後: gccgo フロントエンドと libgo ライブラリへの変更は Go の著作権規則に従う必要がある一方で、GCC の一部であるコードは一般的な GCC の貢献規則に従う必要があることが明確にされました。これは、gccgo が Go と GCC の両方のプロジェクトにまたがる性質を反映しています。
  2. Code (コード):

    • 変更前: gofrontend のソースが http://code.google.com/p/gofrontend にあり、その変更が gcc.gnu.org にルーチン的にマージされると記述されていました。また、gofrontend が Go フロントエンド本体のみを含み、gcc ソースの gcc/golibgo ディレクトリに相当するとされていました。
    • 変更後: gofrontend のマスターソースがそれ自体ではビルドできず、GCC と組み合わせてのみ機能することが明記されました。gofrontendgo ディレクトリが GCC の gcc/go/gofrontend に、libgo ディレクトリが GCC の libgo にミラーリングされることが詳細に説明されました。さらに、メインの Go リポジトリの test ディレクトリが GCC の gcc/testsuite/go.test/test にミラーリングされることも追記されました。
    • 最も重要な追加として、これらのディレクトリへの変更は常にマスターソースから GCC リポジトリに流れること、そしてファイルはマスターソースで変更され、ミラーリングされる以外は GCC リポジトリで変更されるべきではないという、一方向のミラーリングポリシーが強調されました。
  3. C++ コーディング標準とコードの独立性 (Code - 2番目の段落):

    • 変更前: フロントエンドが C++ で書かれているため GNU コーディング標準が完全に適用されない可能性があり、周囲のコードのフォーマットに従うべきだとされていました。また、将来的に gccgo をより独立させる計画があり、GCC 固有のコードは gcc-interface サブディレクトリに移行すべきだとされていました。
    • 変更後: gccgo フロントエンドが C++ で書かれており、C++ に適用される範囲で GNU コーディング標準に従うことが明記されました。また、GCC 固有のコードが最終的にフロントエンド本体から GCC 本体に移行する計画がより具体的に示され、GCC ソース内では gcc/go/gofrontend から gcc/go へのコード移動を意味することが追記されました。
  4. ランタイムライブラリ (libgo) のマージプロセス (Code - 3番目の段落):

    • 変更前: libgo がメインの Go リポジトリから定期的に gofrontend および gcc リポジトリにコピーされると記述されていました。
    • 変更後: libgo がメインの Go リポジトリから gofrontendlibgo/go ディレクトリ、そして GCC リポジトリに、libgo/merge.sh というシェルスクリプトを使用して定期的にマージされることが詳細に説明されました。libgo/go 以外のファイルは gccgo 固有のものであること、そして libgo/runtime の一部のファイルがメインの Go リポジトリの src/pkg/runtime のファイルに基づいていることが追記されました。
  5. Testing (テスト):

    • 変更前: コンパイラテスト (make check-go) とライブラリテスト (make check-target-libgo) が別々に記述されていました。
    • 変更後: make check-go を実行することで、gcc/testsuite/go.* のテストと libgo テストスイートの両方が実行されることが明確にされました。これにより、テスト実行のコマンドが簡素化され、より包括的なテストが一度に実行されるようになりました。
    • 新しいテストはほとんどの場合、メインの Go リポジトリに提出され、その後 GCC リポジトリにミラーリングされるべきであるという方針が再確認されました。gccgo 固有のテストが必要な場合は、gcc/testsuite/go.go-torture または gcc/testsuite/go.dg ディレクトリに配置されるべきであるとされています。

これらの変更は、gccgo プロジェクトへの貢献に関するドキュメントをより正確で、詳細かつ最新の状態に保つことを目的としています。

関連リンク

参考にした情報源リンク