GCCGO(1)
GCCGO(1) is the GNU manual page for gccgo, so let's get into it π
β¨ NAME β¨
gccgo is a GCC-based compiler for the Go language π§
β¨ SYNOPSIS β¨
gccgo [-c|-S]
[-g] [-pg] [-Olevel]
[-Idir...] [-Ldir...]
[-o outfile] infile...
Only the most useful options are listed here, so think of this as the highlights reel π The rest are down below, so keep scrolling bestie.
β¨ DESCRIPTION β¨
okay so gccgo is basically a frontend to gcc, and it shares a bunch of the same options with it π
This page only covers the options that are specific to gccgo.
You can use gccgo to compile Go source code into an object file, link a collection of object files together, or literally do both in sequence π¦
Go source code gets compiled as packages. A package is one or more Go source files. All the files in a single package have to be compiled together, which means you pass every file as an argument to gccgo. One invocation of gccgo can only compile a single package, no exceptions π
One Go package can "import" a different Go package. The imported package has to be compiled already, and gccgo reads the import data directly from that compiled package. Later, when the package gets linked, its compiled form has to be included in the link command π«Ά
Go programs generally need to be compiled with debugging information, and -g1 is the default, as explained further down.
Stripping a Go program will generally cause it to misbehave or fail. Do not strip your Go programs, bestie π
β¨ OPTIONS β¨
-Idirβ Tell it which directory to search when it's looking for an import package at compile time π-Ldirβ When linking, this sets a library search directory, just like with gcc πΈ-fgo-pkgpath=stringβ Sets the package path. This is the value returned by thePkgPathmethod ofreflect.Typeobjects, and it's also used for the names of globally visible symbols. The argument should normally be the string you'll use to import this package after it's installed, which is a pathname inside the directories given by the-Ioption πΊοΈ-fgo-prefix=stringβ An alternative to-fgo-pkgpath. The argument gets combined with the package name from the source file to make the package path. If you use-fgo-pkgpath, then-fgo-prefixgets ignored π
Go lets a single program include more than one package with the same name in the "package" clause of the source file, though the two packages obviously have to be imported using different pathnames. For this to work with gccgo, you must specify either -fgo-pkgpath or -fgo-prefix when compiling a package π
Using either -fgo-pkgpath or -fgo-prefix turns off the special treatment of the "main" package and lets that package be imported like any other π¦
-fgo-relative-import-path=dirβ A relative import is one that starts with./or../. If you use this option, gccgo usesdiras a prefix for the relative import when it searches for it π§-frequire-return-statement,-fno-require-return-statementβ By default, gccgo warns about functions that have one or more return parameters but are missing an explicit "return" statement. You can turn that warning off with-fno-require-return-statementβ οΈ-fgo-check-divide-zeroβ Adds explicit checks for division by zero. In Go, a division (or modulos) by zero causes a panic. On Unix systems this gets detected at runtime by catching the "SIGFPE" signal. Some processors, like PowerPC, don't generate a SIGFPE on division by zero, and some runtimes don't generate a signal that can be caught. On those systems, this option may be used. You can also remove the checks with-fno-go-check-divide-zero. This option is currently on by default, but in the future it may be off by default on systems that don't need it π₯-fgo-check-divide-overflowβ Adds explicit checks for division overflow. For example, division overflow happens when computingINT_MIN / -1. In Go this should wrap around and produceINT_MIN. Some processors, like x86, generate a trap on division overflow. On those systems, this option may be used. You can also remove the checks with-fno-go-check-divide-overflow. This option is currently on by default, but in the future it may be off by default on systems that don't require it π-fno-go-optimize-allocsβ Disables escape analysis, which is the thing that tries to allocate objects on the stack instead of the heap π§±-fgo-debug-escapenβ Outputs escape analysis debugging information. Bigger values ofngenerate more information π-fgo-debug-escape-hash=nβ A hash value for debugging escape analysis, wherenis a binary string. This runs escape analysis only on functions whose names hash to values that match the given suffixn. It's useful for binary searching across functions to uncover escape analysis bugs π΅οΈββοΈ-fgo-c-header=fileβ Writes top-level named Go struct definitions tofileas C code. This is used when compiling the runtime package π-fgo-compiling-runtimeβ Applies special rules for compiling the runtime package. Implicit memory allocation is forbidden here, and some additional compiler directives are supported π-gβ This is the standard gcc option, and it's mentioned here because gccgo turns on debugging information generation by default, which is the equivalent of the standard-g1. That's because Go programs need debugging information available in order to get backtrace information. You can use an explicit-g0to disable the generation of debugging information, but then certain standard library functions, likeruntime.Callers, won't operate correctly π
β¨ SEE ALSO β¨
gpl(7), gfdl(7), fsf-funding(7), gcc(1), and the Info entries for gccgo and gcc π
β¨ COPYRIGHT β¨
Copyright (c) 2010-2019 Free Software Foundation, Inc. π¦
You're allowed to copy, distribute, and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation. There are no Invariant Sections, the Front-Cover Texts are (a) (see below), and the Back-Cover Texts are (b) (see below). A copy of the license is included in the man page gfdl(7).
(a) The FSF's Front-Cover Text is: A GNU Manual
(b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.
That's the tea π«Ά This page came from gcc-9 and was dated 2022-05-27. Go write some packages, bestie ππΈ
π¦ where this page comes from
- ubuntu jammy: gccgo-9-powerpc64-linux-gnu 9.5.0-1ubuntu1~22.04cross1
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms