github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/cmd/gc/doc.go (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build ignore 6 7 /* 8 9 Gc is the generic label for the family of Go compilers 10 that function as part of the (modified) Plan 9 tool chain. The C compiler 11 documentation at 12 13 http://plan9.bell-labs.com/sys/doc/comp.pdf (Tools overview) 14 http://plan9.bell-labs.com/sys/doc/compiler.pdf (C compiler architecture) 15 16 gives the overall design of the tool chain. Aside from a few adapted pieces, 17 such as the optimizer, the Go compilers are wholly new programs. 18 19 The compiler reads in a set of Go files, typically suffixed ".go". They 20 must all be part of one package. The output is a single intermediate file 21 representing the "binary assembly" of the compiled package, ready as input 22 for the linker (6l, etc.). 23 24 The generated files contain type information about the symbols exported by 25 the package and about types used by symbols imported by the package from 26 other packages. It is therefore not necessary when compiling client C of 27 package P to read the files of P's dependencies, only the compiled output 28 of P. 29 30 Command Line 31 32 Usage: 33 go tool 6g [flags] file... 34 The specified files must be Go source files and all part of the same package. 35 Substitute 6g with 8g or 5g where appropriate. 36 37 Flags: 38 -o file 39 output file, default file.6 for 6g, etc. 40 -e 41 normally the compiler quits after 10 errors; -e prints all errors 42 -p path 43 assume that path is the eventual import path for this code, 44 and diagnose any attempt to import a package that depends on it. 45 -D path 46 treat a relative import as relative to path 47 -L 48 show entire file path when printing line numbers in errors 49 -I dir1 -I dir2 50 add dir1 and dir2 to the list of paths to check for imported packages 51 -N 52 disable optimizations 53 -S 54 write assembly language text to standard output (code only) 55 -S -S 56 write assembly language text to standard output (code and data) 57 -u 58 disallow importing packages not marked as safe 59 -V 60 print the compiler version 61 -race 62 compile with race detection enabled 63 64 There are also a number of debugging flags; run the command with no arguments 65 to get a usage message. 66 67 Compiler Directives 68 69 The compiler accepts two compiler directives in the form of // comments at the 70 beginning of a line. To distinguish them from non-directive comments, the directives 71 require no space between the slashes and the name of the directive. However, since 72 they are comments, tools unaware of the directive convention or of a particular 73 directive can skip over a directive like any other comment. 74 75 //line path/to/file:linenumber 76 77 The //line directive specifies that the source line that follows should be recorded 78 as having come from the given file path and line number. Successive lines are 79 recorded using increasing line numbers, until the next directive. This directive 80 typically appears in machine-generated code, so that compilers and debuggers 81 will show lines in the original input to the generator. 82 83 //go:noescape 84 85 The //go:noescape directive specifies that the next declaration in the file, which 86 must be a func without a body (meaning that it has an implementation not written 87 in Go) does not allow any of the pointers passed as arguments to escape into the 88 heap or into the values returned from the function. This information can be used as 89 during the compiler's escape analysis of Go code calling the function. 90 */ 91 package main