GCCGO(1)
π¦ GCCGO(1) β the GNU manual, but make it make sense π
okay so picture this: you're holding the GCCGO(1) page from the GNU manual set, and it's about to be your new hyperfixation. sit down, bestie, we're learning gccgo together β¨
πΈ NAME πΈ
gccgo β a GCC-based compiler for the Go language. that's it, that's the whole vibe. Go code goes in, a compiler built on top of GCC does the work. iconic behaviour, no cap π
π SYNOPSIS π
gccgo [-c|-S]
[-g] [-pg] [-Olevel]
[-Idir...] [-Ldir...]
[-o outfile] infile...
lowkey important: only the most useful options are listed up here in the synopsis. see below for the remainder β and bestie, there is a remainder π
π§ DESCRIPTION π§
so the gccgo command is a frontend to gcc, and it supports many of the same options. like, lots of them. but this manual? this manual only documents the options specific to gccgo. so if you're looking for a general gcc flag, this is not the page for you, go read gcc(1) fr fr π«Ά
now, what does it actually do. the gccgo command may be used to compile Go source code into an object file, link a collection of object files together, or do both in sequence. three moods, one compiler. main character energy β¨
Go source code is compiled as packages. a package consists of one or more Go source files. and here's the rule that gets people every single time: all the files in a single package must be compiled together, by passing all the files as arguments to gccgo. one invocation of gccgo may only compile a single package. so no, you can't sneak two packages into one command. i know. i tried too π
one Go package may "import" a different Go package. the imported package must have already been compiled β gccgo will read the import data directly from the compiled package. and then, when this package is later linked, the compiled form of the package must be included in the link command. that's the whole chain, bestie, don't break it π
β οΈ big warning energy: 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. so likeβ¦ don't strip it? okay? please? π
β¨ OPTIONS β¨
here we go, the part you actually came for. buckle up π
-Idirβ specify a directory to use when searching for an import package at compile time. your import-search hangout spot π-Ldirβ when linking, specify a library search directory, as withgcc. same energy as thegccflag, just vibing at link time.-fgo-pkgpath=stringβ set the package path to use. this sets the value returned by thePkgPathmethod ofreflect.Typeobjects. it's 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. basically: tell it what it'll be called later, so future-you doesn't suffer π-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. (so yes, they're siblings and one of them is the favourite π )
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. so main stops being special and just becomesβ¦ one of the girls π
-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. relative imports found β¨-frequire-return-statement,-fno-require-return-statementβ by defaultgccgowill warn about functions which have one or more return parameters but lack an explicitreturnstatement. this warning may be disabled using-fno-require-return-statement. (the compiler is just looking out for you, ngl π₯Ί)-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. wrapping, but make it safe π-fno-go-optimize-allocsβ disable escape analysis, which tries to allocate objects on the stack rather than the heap. yeah, we're turning off the clever stack thing. it's a choice and i respect it π-fgo-debug-escapenβ output escape analysis debugging information. larger values ofngenerate more information. cranknup if you're nosy π-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. detective mode: activated π΅οΈββοΈ-fgo-debug-optimizationβ output optimization diagnostics. more info, more better β¨-fgo-c-header=fileβ write top-level named Go struct definitions tofileas C code. this is used when compiling the runtime package. cross-language slay π-fgo-compiling-runtimeβ apply special rules for compiling the runtime package. implicit memory allocation is forbidden. some additional compiler directives are supported. runtime rules are different rules, periodt π-fgo-embedcfg=fileβ identify a JSON file used to map patterns used with special//go:embedcomments 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 the go command to implement//go:embed. embed nation rise π-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 the go command. vendoring found its map πΊοΈ-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.
π so if you slam-g0and then wonder why"runtime.Callers"is acting brand new β that's why, bestie. that's literally why.
π₯ SEE ALSO π₯
gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gccgo and gcc.
like, go read all of them. or at least gcc(1). i'm not gonna gatekeep π«Ά
π COPYRIGHT π
Copyright (c) 2010-2026 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 page, bestie π this one's from the gcc-16 manual set, dated 2026-08-07, and it goes out to every single one of you still passing all your package files in one command. proud of you fr fr πβ¨π¦
π¦ where this page comes from
- opensuse-leap 16.0: gcc16-go 16.2.0+git9497-160000.2.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: gcc16-go 16.2.0+git9497-160000.2.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: gcc16-go 16.2.0+git9497-160000.2.1 Β· GPL-3.0-or-later
- opensuse-leap 16.0: gcc16-go 16.2.0+git9497-160000.2.1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms