GCCGO(1)
π NAME π
gccgo β a GCC-based compiler for the Go language, and yes bestie, it's giving "Go but make it GNU" β¨
π SYNOPSIS π
gccgo [-c|-S]
[-g] [-pg] [-Olevel]
[-Idir...] [-Ldir...]
[-o outfile] infile...
Not me showing you only the most useful options up here π the rest are literally right below, scroll a lil', iykyk.
π DESCRIPTION π
Okay so here's the tea β the gccgo command is a frontend to gcc, and it supports soooo many of the same options. But this manual? It only documents the options that are specific to gccgo. Everything else you know and love from gcc still slays, we're just not re-explaining it here.
The gccgo command can do three things, your choice, main character energy:
- compile Go source code into an object file π οΈ
- link a whole collection of object files together π
- or do both in sequence, back to back, no breaks π
Go source code gets compiled as packages. A package consists of one or more Go source files. And THE RULE: all the files in a single package must be compiled together, by passing all the files as arguments to gccgo. A single invocation of gccgo may only compile a single package. That's it, one package per glow-up session, periodt.
One Go package may "import" a different Go package. But listen β the imported package must have already been compiled. gccgo will read the import data directly from the compiled package, no detours. And when this package is later linked, the compiled form of the package must be included in the link command. Don't forget it, it's giving "forgot my keys" energy if you do π
Go programs must generally be compiled with debugging information, and -g1 is the default, as described below. Stripping a Go program will generally cause it to misbehave or fail. Not a vibe. Do not strip. π«
β¨ OPTIONS β¨
-Idirβ point at a directory to use when searching for an import package at compile time. Basically "look here bestie" for imports π-Ldirβ when linking, specify a library search directory, as withgcc.-fgo-pkgpath=stringβ set the package path to use. This sets the value returned by thePkgPathmethod ofreflect.Typeobjects. It is also used for the names of globally visible symbols. The argument to this option should normally be the string that will be used to import this package after it has been installed; in other words, a pathname within the directories specified by the-Ioption. π·οΈ-fgo-prefix=stringβ an alternative to-fgo-pkgpath. The argument will be combined with the package name from the source file to produce the package path. If-fgo-pkgpathis used,-fgo-prefixwill be ignored. (Rude, but that's the rule π)
Go permits a single program to include more than one package with the same name in the "package" clause in the source file, though obviously the two packages must be imported using different pathnames. In order for this to work with gccgo, either -fgo-pkgpath or -fgo-prefix must be specified when compiling a package.
Using either -fgo-pkgpath or -fgo-prefix disables the special treatment of the "main" package and permits that package to be imported like any other.
-fgo-relative-import-path=dirβ a relative import is an import that starts with./or../. If this option is used,gccgowill usediras a prefix for the relative import when searching for it. π§-frequire-return-statement/-fno-require-return-statementβ by defaultgccgowill warn about functions which have one or more return parameters but lack an explicit"return"statement. This warning may be disabled using-fno-require-return-statement. π€-fgo-check-divide-zeroβ add explicit checks for division by zero. In Go a division (or modulos) by zero causes a panic. On Unix systems this is detected in the runtime by catching the"SIGFPE"signal. Some processors, such as PowerPC, do not generate aSIGFPEon division by zero. Some runtimes do not generate a signal that can be caught. On those systems, this option may be used. Or the checks may be removed via-fno-go-check-divide-zero. This option is currently on by default, but in the future may be off by default on systems that do not require it. βπ¨-fgo-check-divide-overflowβ add explicit checks for division overflow. For example, division overflow occurs when computing"INT_MIN / -1". In Go this should be wrapped, to produce"INT_MIN". Some processors, such as x86, generate a trap on division overflow. On those systems, this option may be used. Or the checks may be removed via-fno-go-check-divide-overflow. This option is currently on by default, but in the future may be off by default on systems that do not require it. π΅π«-fno-go-optimize-allocsβ disable escape analysis, which tries to allocate objects on the stack rather than the heap. π§ β‘οΈπ¦-fgo-debug-escapenβ output escape analysis debugging information. Larger values ofngenerate more information. (Moren, more lore π)-fgo-debug-escape-hash=nβ a hash value to debug escape analysis.nis a binary string. This runs escape analysis only on functions whose names hash to values that match the given suffixn. This can be used to binary search across functions to uncover escape analysis bugs. π΅οΈβοΈ-fgo-debug-optimizationβ output optimization diagnostics.-fgo-c-header=fileβ write top-level named Go struct definitions tofileas C code. This is used when compiling the runtime package. π¨-fgo-compiling-runtimeβ apply special rules for compiling the runtime package. Implicit memory allocation is forbidden. Some additional compiler directives are supported. π«π§±-fgo-embedcfg=fileβ identify 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β identify 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. It is mentioned here because by defaultgccgoturns on debugging information generation with the equivalent of the standard option-g1. This is because Go programs require debugging information to be available in order to get backtrace information. An explicit-g0may be used to disable the generation of debugging information, in which case certain standard library functions, such as"runtime.Callers", will not operate correctly. β οΈ
Real talk: stripping a Go program will generally cause it to misbehave or fail. Keep your debug info, bestie, it's not clutter, it's β¨contentβ¨.
π SEE ALSO π
gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gccgo and gcc. Go read those too, they're iconic fr fr π
Β©οΈ COPYRIGHT Β©οΈ
Copyright (c) 2010-2025 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.
okay that's the whole entire page, no skips, no crumbs left behind π
this was gcc-15, dated 2026-09-15, and bestie you just read the whole GCCGO(1) from the GNU fam π«Ά now go compile something cute, bye πβ¨
π¦ where this page comes from
- ubuntu stonking: gccgo-15-powerpc64le-linux-gnu 15.3.0-4ubuntu1cross1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms