GCCGO(1)
โจ gccgo โจ
okay bestie, this is the GNU manual page for gccgo ๐ Let's get into it ๐
โจ NAME โจ
gccgo โ a GCC-based compiler for the Go language ๐
๐ฆ SYNOPSIS ๐ฆ
gccgo [-c|-S]
[-g] [-pg] [-Olevel]
[-Idir...] [-Ldir...]
[-o outfile] infile...
Heads up ๐ this only shows the most useful options. The rest are down in OPTIONS, so keep scrolling ๐ซถ
๐ธ DESCRIPTION ๐ธ
Okay so gccgo is a frontend to gcc and it supports a bunch of the same options ๐
This page only covers the options that are specific to gccgo, so you're not reading the same stuff twice โจ
You can use gccgo to compile Go source code into an object file, link a collection of object files together, or do both in one go. Main character energy ๐
Go source code gets compiled as packages ๐ฆ A package is made of one or more Go source files. All the files in one package have to be compiled together, so you pass every file as an argument to gccgo. A single 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 straight from the compiled package. When you link this package later, the compiled form of the imported package needs to be in the link command too, or it's giving broken ๐
๐จ Go programs generally need to be compiled with debugging information, and -g1 is the default (more on that below). Stripping a Go program will generally make it misbehave or fail entirely, so please don't do it, bestie ๐ญ
๐ OPTIONS ๐
-Idirโ tell it which directory to check when searching for an import package at compile time ๐-Ldirโ when linking, add a library search directory, just like withgcc๐-fgo-pkgpath=stringโ sets the package path ๐ฃ๏ธ This is the value that thePkgPathmethod ofreflect.Typeobjects returns, and it's also used for the names of globally visible symbols. Normally the argument should be the same string you'd use to import this package once it's installed. In other words, it's a pathname inside the directories you gave to the-Ioption.-fgo-prefix=stringโ the 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-pkgpathtoo, then-fgo-prefixgets ignored, so-fgo-pkgpathwins ๐- A single program can include more than one package with the same name in the
"package"clause, obviously as long as the two packages get imported using different pathnames ๐ - For that to work with
gccgo, you must specify either-fgo-pkgpathor-fgo-prefixwhen compiling a package ๐ซถ - Using either
-fgo-pkgpathor-fgo-prefixturns off the special treatment of the"main"package, so that package can be imported like any other one ๐
- A single program can include more than one package with the same name in the
-fgo-relative-import-path=dirโ a relative import is one that starts with./or../๐งญ If you use this option,gccgousesdiras a prefix for the relative import when it goes searching for it.-frequire-return-statement,-fno-require-return-statementโ by default,gccgowarns you about functions that have one or more return parameters but don't have 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, the runtime catches this by catching theSIGFPEsignal. Some processors, like PowerPC, don't generate aSIGFPEon division by zero, and some runtimes don't generate a signal that can even be caught. On those systems, use this option. You can also remove the checks with-fno-go-check-divide-zero. This option is currently on by default, but in the future it might be off by default on systems that don't need it ๐ฎ-fgo-check-divide-overflowโ adds explicit checks for division overflow ๐งฎ For example, overflow happens when computingINT_MIN / -1. In Go, that should wrap around and produceINT_MIN. Some processors, like x86, generate a trap on division overflow. On those systems, use this option. Or you can remove the checks with-fno-go-check-divide-overflow. Right now it's on by default, but in the future it might 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 ๐ Larger values ofngenerate more information, so go big or go home ๐ฅ-fgo-debug-escape-hash=nโ a hash value for debugging escape analysis ๐งฉnis a binary string. This runs escape analysis only on functions whose names hash to values that match the given suffixn. You can use it to binary search across functions and uncover escape analysis bugs ๐ต๏ธโโ๏ธ-fgo-c-header=fileโ writes the top-level named Go struct definitions tofileas C code ๐ This gets used when compiling the runtime package.-fgo-compiling-runtimeโ applies special rules for compiling the runtime package ๐ Implicit memory allocation is forbidden here ๐ โโ๏ธ A few extra compiler directives are supported too.-gโ this is the standardgccoption, and it's mentioned here becausegccgoturns on debugging information generation by default, which is the equivalent of the standard option-g1๐ Go programs need debugging information so they can get backtrace information, which is why it's on by default. You can use an explicit-g0to disable generating debugging information, but then certain standard library functions, likeruntime.Callers, won't work correctly ๐
โ ๏ธ Using-g0meansruntime.Callerswill not operate correctly. Don't say I didn't warn you ๐
๐ง 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 can 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.
Okay that's the whole tea โ๐ธ This page is from gcc-9, dated 2022-05-27, so go compile something cute, bestie ๐ฆ๐
๐ฆ where this page comes from
- ubuntu noble: gccgo-9-powerpc64le-linux-gnu 9.5.0-6ubuntu2.1cross1
- ubuntu noble: gccgo-9-powerpc64le-linux-gnu 9.5.0-6ubuntu2cross1
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms