GCCGO(1)
β¨ GCCGO(1) β¨
okay bestie, sit down, hydrate, because we're about to talk about the GNU gccgo compiler page π (it's from the GNU manual, and it's genuinely iconic)
πΈ 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 greatest-hits list. the rest is further down, keep scrolling bestie π
π¦ DESCRIPTION π¦
So gccgo is a frontend to gcc, which means it speaks a lot of the same options as gcc does. But this manual? This manual is only about the options that are special to gccgo. the exclusive club, the VIP section π
gccgo can do three little jobs and honestly it slays at all of them: compile Go source code into an object file, link a bunch of object files together, or do both, back to back, in sequence π₯
Now here's the vibe of Go: source code gets compiled as packages. A package = one or more Go source files. And the rule is ALL the files in one package must be compiled together, meaning you pass every single one of them as arguments to gccgo. Also β and this is important β a single invocation of gccgo may only compile a single package. one compiler call, one package, periodt β
One Go package can "import" a different Go package. But bestie, that imported package has to have already been compiled. gccgo reads the import data directly from the compiled package. And later, when you link this package, the compiled form of the imported package has to be included in the link command too. no skipping steps π
β οΈ Go programs must generally be compiled with debugging information, and -g1 is the default (more on that below, iykyk). Stripping a Go program will generally cause it to misbehave or fail. like, it'll just start acting unhinged. don't do it π
π OPTIONS π
-Idirβ tellsgccgowhich directory to look in when it's searching for an import package at compile time π-Ldirβ when you're linking, this is how you specify a library search directory. same energy as gcc π-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. The argument here should normally be the string you'd use to import this package after it's been installed β in other words, a pathname within the directories specified by 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-prefixwill be ignored. π
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. β¨
Also: using either -fgo-pkgpath or -fgo-prefix disables the special treatment of the "main" package and lets that package be imported like any other. main character no longer getting special treatment, it's just one of the girls now π
-fgo-relative-import-path=dirβ a relative import is an import that starts with./or../. If you use this option,gccgowill usediras a prefix for the relative import when it goes searching for it. π-frequire-return-statement-fno-require-return-statementβ by default,gccgowill warn about functions which 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, like PowerPC, don't generate a SIGFPE on division by zero, and some runtimes don't generate a signal that can even be caught. On those systems, you use this option. Or you can remove the checks with-fno-go-check-divide-zero. Currently this option is 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. Example: overflow happens when you compute"INT_MIN / -1". In Go this should be wrapped, producing"INT_MIN". Some processors, like x86, generate a trap on division overflow, so on those systems you'd use this option. Or remove the checks with-fno-go-check-divide-overflow. Currently on by default, but in the future 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. Larger values of n generate more information. (more chaos, more data, love that for us) π-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. You can use this to binary search across functions to uncover escape analysis bugs. detective mode activated πβ¨-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. 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 those patterns. That 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 the go command to implement"//go:embed". π«Ά-gβ this is the standard gcc option. 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. An explicit-g0may be used to disable generation of debugging information, in which case certain standard library functions, such as"runtime.Callers", will not operate correctly. so like... don't π
π SEE ALSO π
gpl(7), gfdl(7), fsf-funding(7), gcc(1) β and the Info entries for gccgo and gcc π
π COPYRIGHT π
Copyright (c) 2010-2022 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 the whole page bestie!! π«Ά this came from the gcc-12 era, dated 2024-07-11 β so go forth, compile responsibly, and keep your debugging info on. love u, bye πβ¨ππ¦
π¦ where this page comes from
- ubuntu noble: gccgo-12-mipsel-linux-gnu 12.4.0-2ubuntu1~24.04cross8
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms