<p>
This document is a quick outline of the unusual form of assembly language used by the <code>gc</code>
-suite of Go compilers (<code>6g</code>, <code>8g</code>, etc.).
+Go compiler.
The document is not comprehensive.
</p>
func main() {
println(3)
}
-$ go tool 6g -S x.go # or: go build -gcflags -S x.go
+$ go tool compile -S x.go # or: go build -gcflags -S x.go
--- prog list "main" ---
0000 (x.go:3) TEXT main+0(SB),$8-0
<p>
There are two Go compiler implementations, <code>gc</code>
-(the <code>6g</code> program and friends) and <code>gccgo</code>.
+and <code>gccgo</code>.
<code>Gc</code> uses a different calling convention and linker and can
therefore only be linked with C programs using the same convention.
There is such a C compiler but no C++ compiler.
<p>
There are two official Go compiler tool chains.
This document focuses on the <code>gc</code> Go
-compiler and tools (<code>6g</code>, <code>8g</code> etc.).
+compiler and tools.
For information on how to work on <code>gccgo</code>, a more traditional
compiler using the GCC back end, see
<a href="/doc/install/gccgo">Setting up and using gccgo</a>.
<li><code>$GO386</code> (for <code>386</code> only, default is auto-detected
if built on either <code>386</code> or <code>amd64</code>, <code>387</code> otherwise)
<p>
-This controls the code generated by 8g to use either the 387 floating-point unit
+This controls the code generated by gc 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>
the Go package big's integer type Int.
This is a syntactically valid Go program—it can be parsed with the Go
-parser and processed by godoc—but it is not compiled directly by 6g.
+parser and processed by godoc—but it is not compiled directly by gc.
Instead, a separate tool, cgo, processes it to produce three output
files. The first two, 6g.go and 6c.c, are a Go source file for 6g and
a C source file for 6c; both compile as part of the named package
// Testing rebuilding of shared libraries when they are stale is a bit more
// complicated that it seems like it should be. First, we make everything "old": but
-// only a few seconds old, or it might be older than 6g (or the runtime source) and
+// only a few seconds old, or it might be older than gc (or the runtime source) and
// everything will get rebuilt. Then define a timestamp slightly newer than this
// time, which is what we set the mtime to of a file to cause it to be seen as new,
// and finally another slightly even newer one that we can compare files against to
return fld
}
-// Struct conversion: return Go and (6g) C syntax for type.
+// Struct conversion: return Go and (gc) C syntax for type.
func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.StructType, csyntax string, align int64) {
// Minimum alignment for a struct is 1 byte.
align = 1
// TODO(rsc):
// Emit correct line number annotations.
-// Make 6g understand the annotations.
+// Make gc understand the annotations.
package main
var conf = printer.Config{Mode: printer.SourcePos, Tabwidth: 8}
-// writeDefs creates output files to be compiled by 6g and gcc.
-// (The comments here say 6g but the code applies to the 8 and 5 tools too.)
+// writeDefs creates output files to be compiled by gc and gcc.
func (p *Package) writeDefs() {
var fgo2, fc io.Writer
f := creat(*objDir + "_cgo_gotypes.go")
fatalf("cannot parse %s as ELF, Mach-O or PE", obj)
}
-// Construct a gcc struct matching the 6g argument frame.
+// Construct a gcc struct matching the gc argument frame.
// Assumes that in gcc, char is 1 byte, short 2 bytes, int 4 bytes, long long 8 bytes.
// These assumptions are checked by the gccProlog.
-// Also assumes that 6g convention is to word-align the
+// Also assumes that gc convention is to word-align the
// input and output parameters.
func (p *Package) structType(n *Name) (string, int64) {
var buf bytes.Buffer
fmt.Fprintf(fgo2, "}\n")
}
-// writeOutput creates stubs for a specific source file to be compiled by 6g
-// (The comments here say 6g but the code applies to the 8 and 5 tools too.)
+// writeOutput creates stubs for a specific source file to be compiled by gc
func (p *Package) writeOutput(f *File, srcfile string) {
base := srcfile
if strings.HasSuffix(base, ".go") {
if n.AddError {
fmt.Fprintf(fgcc, "\terrno = 0;\n")
}
- // We're trying to write a gcc struct that matches 6g's layout.
+ // We're trying to write a gcc struct that matches gc's layout.
// Use packed attribute to force no padding in this struct in case
// gcc has different packing requirements.
fmt.Fprintf(fgcc, "\t%s %v *a = v;\n", ctype, p.packedAttribute())
}
// packedAttribute returns host compiler struct attribute that will be
-// used to match 6g's struct layout. For example, on 386 Windows,
-// gcc wants to 8-align int64s, but 8g does not.
+// used to match gc's struct layout. For example, on 386 Windows,
+// gcc wants to 8-align int64s, but gc does not.
// Use __gcc_struct__ to work around http://gcc.gnu.org/PR52991 on x86,
// and http://golang.org/issue/5603.
func (p *Package) packedAttribute() string {
for _, exp := range p.ExpFunc {
fn := exp.Func
- // Construct a gcc struct matching the 6g argument and
+ // Construct a gcc struct matching the gc argument and
// result frame. The gcc struct will be compiled with
// __attribute__((packed)) so all padding must be accounted
// for explicitly.
}
fmt.Fprintf(fgcc, "}\n")
- // Build the wrapper function compiled by 6g.
+ // Build the wrapper function compiled by gc.
goname := exp.Func.Name.Name
if fn.Recv != nil {
goname = "_cgoexpwrap" + cPrefix + "_" + fn.Recv.List[0].Names[0].Name + "_" + goname
// a cross-compiled compiler expects to compile for its own target
// system. That is, if on a Mac you do:
//
-// GOOS=linux GOARCH=ppc64 go build cmd/9g
+// GOOS=linux GOARCH=ppc64 go build cmd/compile
//
// the resulting compiler will default to generating linux/ppc64 object files.
// This is more useful than having it default to generating objects for the
gcargs[1] = "main"
}
if p.Standard && p.ImportPath == "runtime" {
- // runtime compiles with a special 6g flag to emit
+ // runtime compiles with a special gc flag to emit
// additional reflect type data.
gcargs = append(gcargs, "-+")
}
}
func Getgo386() string {
- // Validated by cmd/8g.
+ // Validated by cmd/compile.
return envOr("GO386", defaultGO386)
}
return
}
-// TODO(rsc): 6g supplies these, but they are not
+// TODO(rsc): gc supplies these, but they are not
// as efficient as they could be: they have commonType
// as the receiver instead of *rtype.
func (t *rtype) NumMethod() int {
/*
* We still need to save all callee save register as before, and then
* push 2 args for fn (R1 and R2).
- * Also note that at procedure entry in 5c/5g world, 4(R13) will be the
+ * Also note that at procedure entry in gc world, 4(R13) will be the
* first arg, so we must push another dummy reg (R0) for 0(R13).
* Additionally, runtime·load_g will clobber R0, so we need to save R0
* nevertheless.
/*
* We still need to save all callee save register as before, and then
* push 2 args for fn (R1 and R2).
- * Also note that at procedure entry in 7g world, 8(RSP) will be the
+ * Also note that at procedure entry in gc world, 8(RSP) will be the
* first arg.
* TODO(minux): use LDP/STP here if it matters.
*/
/*
* void crosscall1(void (*fn)(void), void (*setg_gcc)(void *g), void *g)
*
- * Calling into the 7g tool chain, where all registers are caller save.
+ * Calling into the gc tool chain, where all registers are caller save.
* Called from standard ARM EABI, where x19-x29 are callee-save, so they
* must be saved explicitly, along with x30 (LR).
*/
/*
* void crosscall_ppc64(void (*fn)(void), void *g)
*
- * Calling into the 9g tool chain, where all registers are caller save.
+ * Calling into the gc tool chain, where all registers are caller save.
* Called from standard ppc64 C ABI, where r2, r14-r31, f14-f31 are
* callee-save, so they must be saved explicitly.
*/
// Compiler is the name of the compiler toolchain that built the
// running binary. Known toolchains are:
//
-// gc The 5g/6g/8g compiler suite at go.googlesource.com/go.
+// gc Also known as cmd/compile.
// gccgo The gccgo front end, part of the GCC compiler suite.
//
const Compiler = "gc"
a := new(arg)
// Generate each test as a separate function to avoid
- // hitting the 6g optimizer with one enormous function.
+ // hitting the gc optimizer with one enormous function.
// If we name all the functions init we don't have to
// maintain a list of which ones to run.
do := func(t *template.Template) {
isfalse(ic != d)
isfalse(ie != e)
- // 6g used to let this go through as true.
+ // gc used to let this go through as true.
var g uint64 = 123
var h int64 = 123
var ig interface{} = g
$cmd = join(' ', @ARGV);
open(CMD, "exec $cmd </dev/null 2>&1 |") || die "BUG: errchk: run $cmd: $!";
-# 6g error messages continue onto additional lines with leading tabs.
+# gc error messages continue onto additional lines with leading tabs.
# Split the output at the beginning of each line that doesn't begin with a tab.
$out = join('', <CMD>);
@out = split(/^(?!\t)/m, $out);
package main
func main() {
- if func() bool { return true }() {} // 6g used to say this was a syntax error
+ if func() bool { return true }() {} // gc used to say this was a syntax error
if (func() bool { return true })() {}
if (func() bool { return true }()) {}
}
}
func main() {
- // 6g, 8g, 5g all used to evaluate g() before f().
+ // gc used to evaluate g() before f().
if f() < g() {
panic("wrong answer")
}
thisPass := 0
if c == "c" && (a == "a" || a == "pa" || n == "n" || i == "i64big" || i == "i64bigger" || i == "huge" || i == "fbad") {
if i == "huge" {
- // Due to a detail of 6g's internals,
+ // Due to a detail of gc's internals,
// the huge constant errors happen in an
// earlier pass than the others and inhibits
// the next pass from running.
}
func splitOutput(out string) []string {
- // 6g error messages continue onto additional lines with leading tabs.
+ // gc error messages continue onto additional lines with leading tabs.
// Split the output at the beginning of each line that doesn't begin with a tab.
// <autogenerated> lines are impossible to match so those are filtered out.
var res []string