...

为gccgo做贡献

Introduction

引言

These are some notes on contributing to the gccgo frontend for GCC. For information on contributing to parts of Go other than gccgo, see Contributing to the Go project. For information on building gccgo for yourself, see Setting up and using gccgo. For more of the gritty details on the process of doing development with the gccgo frontend, see the file HACKING in the gofrontend repository.

本文档为如何向GCC的gccgo前端做贡献的注记。欲获取为Go的其它部分做贡献的信息,请访问 为Go项目做贡献。有关如何自己构建gccgo的信息, 请访问设置并使用gccgo.

Legal Prerequisites

合法前提

You must follow the Go copyright rules for all changes to the gccgo frontend and the associated libgo library. Code that is part of GCC rather than gccgo must follow the general GCC contribution rules.

你对gccgo前端及其关联libgo库的一切更改,都必须遵循 Go版权条例。 非gccgo的GCC部分代码必须遵循通用 GCC贡献规则

Code

代码

The master sources for the gccgo frontend may be found at http://code.google.com/p/gofrontend. The master sources are not buildable by themselves, but only in conjunction with GCC (in the future, other compilers may be supported). Changes made to the gccgo frontend are also applied to the GCC source code repository hosted at gcc.gnu.org. In the gofrontend repository, the go directory is mirrored to the gcc/go/gofrontend directory in the GCC repository, and the gofrontend libgo directory is mirrored to the GCC libgo directory. In addition, the test directory from the main Go repository is mirrored to the gcc/testsuite/go.test/test directory in the GCC repository.

gccgo前端的主源码可从 http://code.google.com/p/gofrontend找到。主源码不可通过其本身构建, 只能与GCC结合使用(将来或许会支持其它编译器)。 对gccgo前端的更改也可应用于托管在 gcc.gnu.org 上的GCC源码库中, go 目录镜像到了GCC仓库的 gcc/go/gofrontend 目录,而 gofrontend libgo 目录镜像到了GCC仓库的 libgo 目录。另外,主Go仓库中的 test镜像到了GCC仓库的 gcc/testsuite/go.test/test 目录。

Changes to these directories always flow from the master sources to the GCC repository. The files should never be changed in the GCC repository except by changing them in the master sources and mirroring them.

对这些目录的更改总是从主源到GCC仓库的。在GCC仓库中的文件绝不能更改, 除非通过在主源中更改并镜像它们。

The gccgo frontend is written in C++. It follows the GNU coding standards to the extent that they apply to C++. In writing code for the frontend, follow the formatting of the surrounding code. Although the frontend is currently tied to the rest of the GCC codebase, we plan to make it more independent. Eventually all GCC-specific code will migrate out of the frontend proper and into GCC proper. In the GCC sources this will generally mean moving code from gcc/go/gofrontend to gcc/go.

The gccgo frontend is written in C++. It follows the GNU coding standards to the extent that they apply to C++. In writing code for the frontend, follow the formatting of the surrounding code. Although the frontend is currently tied to the rest of the GCC codebase, we plan to make it more independent. Eventually all GCC-specific code will migrate out of the frontend proper and into GCC proper. In the GCC sources this will generally mean moving code from gcc/go/gofrontend to gcc/go. gccgo前端使用C++编写。它遵循适用于C++的GNU编码标准范围。在为该前端编写代码时, 需遵循外围代码的格式。尽管该前端当前依赖于GCC代码库,但我们计划使它更独立。 最终,所有GCC特有的代码将完全移出该前端并进入GCC中。在GCC源中,这通常意味着将代码从 gcc/go/gofrontend 移动到 gcc/go 中。

The run-time library for gccgo is mostly the same as the library in the main Go repository. The library code in the Go repository is periodically merged into the libgo/go directory of the gofrontend and then the GCC repositories, using the shell script libgo/merge.sh. Accordingly, most library changes should be made in the main Go repository. The files outside of libgo/go are gccgo-specific; that said, some of the files in libgo/runtime are based on files in src/runtime in the main Go repository.

gccgo运行时库大部分与主Go仓库中的库相同。 Go仓库中的库代码定期合并到 gofrontendlibgo/go 目录中,接着使用shell脚本 libgo/merge.sh 将其合并到GCC仓库中。 因此,大部分库的更改应当在主Go仓库中进行。libgo/go 之外的文件为gccgo特有的,也就是说,libgo/runtime 中的一些文件基于主Go仓库内 src/pkg/runtime 中的文件。

Testing

测试

All patches must be tested. A patch that introduces new failures is not acceptable.

所有补丁都必须经过测试,引入新的失败的补丁是不被接受的。

To run the gccgo test suite, run make check-go in your build directory. This will run various tests under gcc/testsuite/go.* and will also run the libgo testsuite. This copy of the tests from the main Go repository is run using the DejaGNU script found in gcc/testsuite/go.test/go-test.exp.

要运行gccgo测试套件,需在你的构建目录中运行 make check-go。 这将在 gcc/testsuite/go.* 下运行各种测试,也会运行 libgo 测试套件。来自主Go仓库中的此测试副本通过DejaGNU脚本查找 gcc/testsuite/go.test/go-test.exp 来运行。

Most new tests should be submitted to the main Go repository for later mirroring into the GCC repository. If there is a need for specific tests for gccgo, they should go in the gcc/testsuite/go.go-torture or gcc/testsuite/go.dg directories in the GCC repository.

大多数新的测试都应当被提交到主Go仓库,以镜像到GCC仓库中。若需提交gccgo的特殊测试, 它们应当进入GCC仓库的 gcc/testsuite/go.go-torturegcc/testsuite/go.dg 目录中。

Submitting Changes

提交更改

Changes to the Go frontend should follow the same process as for the main Go repository, only for the gofrontend project and the gofrontend-dev@googlegroups.com mailing list rather than the go project and the golang-dev@googlegroups.com mailing list. Those changes will then be merged into the GCC sources.

对 Go 前端的更改流程应当遵循与主 Go 源码库相同的流程,只对 gofrontend 项目和 gofrontend-dev@googlegroups.com 邮件列表进行更改,而非 go 项目和 golang-dev@googlegroups.com 邮件列表。 那些更改将被合并到 GCC 源中。