1GCCGO(1) GNU GCCGO(1)
2
3
4
6 gccgo - A GCC-based compiler for the Go language
7
9 gccgo [-c|-S]
10 [-g] [-pg] [-Olevel]
11 [-Idir...] [-Ldir...]
12 [-o outfile] infile...
13
14 Only the most useful options are listed here; see below for the
15 remainder.
16
18 The gccgo command is a frontend to gcc and supports many of the same
19 options. This manual only documents the options specific to gccgo.
20
21 The gccgo command may be used to compile Go source code into an object
22 file, link a collection of object files together, or do both in
23 sequence.
24
25 Go source code is compiled as packages. A package consists of one or
26 more Go source files. All the files in a single package must be
27 compiled together, by passing all the files as arguments to gccgo. A
28 single invocation of gccgo may only compile a single package.
29
30 One Go package may "import" a different Go package. The imported
31 package must have already been compiled; gccgo will read the import
32 data directly from the compiled package. When this package is later
33 linked, the compiled form of the package must be included in the link
34 command.
35
36 Go programs must generally be compiled with debugging information, and
37 -g1 is the default as described below. Stripping a Go program will
38 generally cause it to misbehave or fail.
39
41 -Idir
42 Specify a directory to use when searching for an import package at
43 compile time.
44
45 -Ldir
46 When linking, specify a library search directory, as with gcc.
47
48 -fgo-pkgpath=string
49 Set the package path to use. This sets the value returned by the
50 PkgPath method of reflect.Type objects. It is also used for the
51 names of globally visible symbols. The argument to this option
52 should normally be the string that will be used to import this
53 package after it has been installed; in other words, a pathname
54 within the directories specified by the -I option.
55
56 -fgo-prefix=string
57 An alternative to -fgo-pkgpath. The argument will be combined with
58 the package name from the source file to produce the package path.
59 If -fgo-pkgpath is used, -fgo-prefix will be ignored.
60
61 Go permits a single program to include more than one package with
62 the same name in the "package" clause in the source file, though
63 obviously the two packages must be imported using different
64 pathnames. In order for this to work with gccgo, either
65 -fgo-pkgpath or -fgo-prefix must be specified when compiling a
66 package.
67
68 Using either -fgo-pkgpath or -fgo-prefix disables the special
69 treatment of the "main" package and permits that package to be
70 imported like any other.
71
72 -fgo-relative-import-path=dir
73 A relative import is an import that starts with ./ or ../. If this
74 option is used, gccgo will use dir as a prefix for the relative
75 import when searching for it.
76
77 -frequire-return-statement
78 -fno-require-return-statement
79 By default gccgo will warn about functions which have one or more
80 return parameters but lack an explicit "return" statement. This
81 warning may be disabled using -fno-require-return-statement.
82
83 -fgo-check-divide-zero
84 Add explicit checks for division by zero. In Go a division (or
85 modulos) by zero causes a panic. On Unix systems this is detected
86 in the runtime by catching the "SIGFPE" signal. Some processors,
87 such as PowerPC, do not generate a SIGFPE on division by zero.
88 Some runtimes do not generate a signal that can be caught. On
89 those systems, this option may be used. Or the checks may be
90 removed via -fno-go-check-divide-zero. This option is currently on
91 by default, but in the future may be off by default on systems that
92 do not require it.
93
94 -fgo-check-divide-overflow
95 Add explicit checks for division overflow. For example, division
96 overflow occurs when computing "INT_MIN / -1". In Go this should
97 be wrapped, to produce "INT_MIN". Some processors, such as x86,
98 generate a trap on division overflow. On those systems, this
99 option may be used. Or the checks may be removed via
100 -fno-go-check-divide-overflow. This option is currently on by
101 default, but in the future may be off by default on systems that do
102 not require it.
103
104 -fno-go-optimize-allocs
105 Disable escape analysis, which tries to allocate objects on the
106 stack rather than the heap.
107
108 -fgo-debug-escapen
109 Output escape analysis debugging information. Larger values of n
110 generate more information.
111
112 -fgo-debug-escape-hash=n
113 A hash value to debug escape analysis. n is a binary string. This
114 runs escape analysis only on functions whose names hash to values
115 that match the given suffix n. This can be used to binary search
116 across functions to uncover escape analysis bugs.
117
118 -fgo-c-header=file
119 Write top-level named Go struct definitions to file as C code.
120 This is used when compiling the runtime package.
121
122 -fgo-compiling-runtime
123 Apply special rules for compiling the runtime package. Implicit
124 memory allocation is forbidden. Some additional compiler
125 directives are supported.
126
127 -g This is the standard gcc option. It is mentioned here because by
128 default gccgo turns on debugging information generation with the
129 equivalent of the standard option -g1. This is because Go programs
130 require debugging information to be available in order to get
131 backtrace information. An explicit -g0 may be used to disable the
132 generation of debugging information, in which case certain standard
133 library functions, such as "runtime.Callers", will not operate
134 correctly.
135
137 gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gccgo
138 and gcc.
139
141 Copyright (c) 2010-2018 Free Software Foundation, Inc.
142
143 Permission is granted to copy, distribute and/or modify this document
144 under the terms of the GNU Free Documentation License, Version 1.3 or
145 any later version published by the Free Software Foundation; with no
146 Invariant Sections, the Front-Cover Texts being (a) (see below), and
147 with the Back-Cover Texts being (b) (see below). A copy of the license
148 is included in the man page gfdl(7).
149
150 (a) The FSF's Front-Cover Text is:
151
152 A GNU Manual
153
154 (b) The FSF's Back-Cover Text is:
155
156 You have freedom to copy and modify this GNU Manual, like GNU
157 software. Copies published by the Free Software Foundation raise
158 funds for GNU development.
159
160
161
162gcc-8 2019-02-23 GCCGO(1)