GCCGO(1)
πΈ GCCGO π
okay bestie, so you know the manual page for gccgo? It lives in the GNU manual set, and we're gonna walk through the whole thing together, no skips, no shortcuts. Every flag, every warning, every lil detail. Let's go. β¨
β¨ NAME β¨
gccgo β a GCC-based compiler for the Go language π¦
π SYNOPSIS π
gccgo [-c|-S]
[-g] [-pg] [-Olevel]
[-Idir...] [-Ldir...]
[-o outfile] infile...
ngl, that's only the most useful options listed up there. The rest? They're down in OPTIONS, keep scrolling. π
π DESCRIPTION π
The gccgo command is a frontend to gcc, and it supports many of the same options. Just so we're clear: this manual only documents the options that are specific to gccgo. Everything else? That's a gcc situation.
You can use the gccgo command to compile Go source code into an object file, to link a bunch of object files together, or to do both, one after the other. Multi-tasking icon behavior. π
Go source code gets compiled as packages. A package is made of one or more Go source files. And here's the thing β all the files in a single package must be compiled together, so you pass every single one of them as arguments to gccgo. Also, a single invocation of gccgo can only compile a single package. No sneaking a second one in there. π«
One Go package may "import" a different Go package. That imported package has to have already been compiled β gccgo reads the import data straight from the compiled package. And when this package gets linked later, the compiled form of the package has to be included in the link command. Fr fr, don't forget it. π
Go programs generally need to be compiled with debugging information, and -g1 is the default, as described below. And listen β stripping a Go program will generally cause it to misbehave or fail. So don't do that. Not the vibe. π
β OPTIONS β
-Idirβ tell it a directory to search when it's looking for an import package at compile time. π-Ldirβ when linking, this specifies a library search directory, just like withgcc.-fgo-pkgpath=stringβ sets the package path to use. This sets the value returned by thePkgPathmethod ofreflect.Typeobjects, and it's also used for the names of globally visible symbols. Normally, the argument you pass here should be the string that'll be used to import this package after it's installed β in other words, a pathname inside the directories you specified with the-Ioption. π¦-fgo-prefix=stringβ an alternative to-fgo-pkgpath. The argument gets combined with the package name from the source file to produce the package path. And heads up: if-fgo-pkgpathis used,-fgo-prefixgets ignored. Bye. π
Go lets a single program include more than one package with the same name in the "package" clause in the source file β though obviously those two packages have to be imported using different pathnames. For that to work with gccgo, you must specify either -fgo-pkgpath or -fgo-prefix when compiling a package.
Using either -fgo-pkgpath or -fgo-prefix disables 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 an import that starts with./or../. If you use this option,gccgowill use dir as a prefix for the relative import when searching for it. π-frequire-return-statement,-fno-require-return-statementβ by default,gccgowarns about functions that have one or more return parameters but lack 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, dividing (or modulo-ing) by zero causes a panic. On Unix systems, this gets detected in the runtime by catching the"SIGFPE"signal. But some processors β PowerPC, for example β don't generate aSIGFPEon division by zero, and some runtimes don't generate a signal that can be caught. On those systems, you may use this option. Or the checks can be removed via-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 require it. π-fgo-check-divide-overflowβ adds explicit checks for division overflow. For example, division overflow happens when computing"INT_MIN / -1". In Go this should be wrapped, to produce"INT_MIN". Some processors, like x86, generate a trap on division overflow. On those systems, you may use this option. Or the checks can be removed via-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 of n generate more information. π-fgo-debug-escape-hash=nβ a hash value to debug escape analysis. n is a binary string. This runs escape analysis only on functions whose names hash to values that match the given suffix n. Super useful for binary searching across functions to uncover escape analysis bugs. π§-fgo-debug-optimizationβ outputs optimization diagnostics.-fgo-c-header=fileβ writes top-level named Go struct definitions to file as 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, and some additional compiler directives are supported. π€-fgo-embedcfg=fileβ identifies a JSON file used to map patterns used with special"//go:embed"comments to the files named by the patterns. The JSON file should have two components:"Patterns"maps each pattern to a list of file names, and"Files"maps each file name to a full path to the file. This option is intended for use by thegocommand to implement"//go:embed". π-fgo-importcfg=fileβ identifies a file that provides mappings for import package paths found in the Go source files. The file can contain two commands:"importpath"to rename import paths for vendoring, and"packagefile"to map from package path to files containing export data. This option is intended for use by thegocommand. π«Ά-gβ this is the standardgccoption, but it's mentioned here because by defaultgccgoturns on debugging information generation with the equivalent of the standard option-g1. Why? Because Go programs require debugging information to be available in order to get backtrace information. You can use an explicit-g0to disable the generation of debugging information β but in that case, certain standard library functions, like"runtime.Callers", will not operate correctly. β οΈ
okay this one matters bestie, don't just yeet your debug info and then wonder why your backtraces are giving nothing. π
π SEE ALSO π
gpl(7), gfdl(7), fsf-funding(7), gcc(1) β and the Info entries for gccgo and gcc. π
π COPYRIGHT π
Copyright (c) 2010-2024 Free Software Foundation, Inc.
Permission is granted 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; with no Invariant Sections, the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (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.
and that's a wrap, bestie π this whole thing is from gcc-14, dated 2024-09-08 β go forth and compile, you absolute main character πβ¨
π¦ where this page comes from
- ubuntu noble: gccgo-14-mips64-linux-gnuabi64 14.2.0-4ubuntu2~24.04cross1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms