GCCGO(1)

๐Ÿ“ฆ
version 16-20260322 ยท 2 versions
, in ubuntu resolute

GCCGO(1) ๐ŸŽ€ the GNU manual page, bestie, and it's about the Go compiler ๐Ÿ’…

โœจ NAME โœจ

okay so gccgo is a GCC-based compiler for the Go language ๐Ÿ”ฅ it's giving "compiler that actually works with Go" and I'm obsessed

โœจ SYNOPSIS โœจ

gccgo [-c|-S]
      [-g] [-pg] [-Olevel]
      [-Idir...] [-Ldir...]
      [-o outfile] infile...

only the most useful options are listed up there ๐Ÿฆ‹ scroll down for the rest, babe

โœจ DESCRIPTION โœจ

the gccgo command is a frontend to gcc and it supports a lot of the same options ๐Ÿ’– this manual only covers the gccgo-specific ones, so don't stress about the rest

gccgo can compile Go source code into an object file, link a bunch of object files together, or do both in sequence โœจ main character energy

Go source code gets compiled as packages ๐Ÿ“ฆ a package is one or more Go source files. all the files in a single package have to be compiled together, which means you pass every single file as an argument to gccgo ๐Ÿซถ one invocation of gccgo can only compile a single package, no cap

one Go package can "import" a different Go package ๐ŸŒธ the imported one 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 has to be in the link command too ๐Ÿ”—

Go programs generally need to be compiled with debugging info, and -g1 is the default (more on that below) ๐Ÿงš

stripping a Go program will generally make it misbehave or fail ๐Ÿ’€ so don't do it, bestie

โœจ OPTIONS โœจ

  • -Idir โ€” tells gccgo where to look for an import package at compile time ๐Ÿ”
  • -Ldir โ€” when linking, adds a library search directory, just like gcc does ๐Ÿ“š
  • -fgo-pkgpath=string โ€” sets the package path โœจ this is the value you get back from the PkgPath method of reflect.Type objects, and it's also used for the names of globally visible symbols. the argument should normally be the same string you'll use to import this package after it's installed, aka a pathname inside the directories you gave with -I ๐Ÿ›ค๏ธ
  • -fgo-prefix=string โ€” an 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-pkgpath too, then -fgo-prefix gets ignored

Go lets one program include more than one package with the same name in the "package" clause ๐Ÿ™ˆ the two packages obviously have to be imported using different pathnames though. for this to work with gccgo, you need either -fgo-pkgpath or -fgo-prefix when compiling a package. using either one also turns off the special treatment of the "main" package and lets it be imported like any other ๐Ÿ‘‘

  • -fgo-relative-import-path=dir โ€” a relative import is one that starts with ./ or ../ ๐Ÿงญ if you use this option, gccgo uses dir as a prefix for the relative import when it searches for it
  • -frequire-return-statement, -fno-require-return-statement โ€” by default gccgo warns about functions that have one or more return parameters but no 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 modulus) by zero causes a panic. on Unix systems the runtime catches that by catching the "SIGFPE" signal. some processors, like PowerPC, don't generate a SIGFPE on division by zero, and some runtimes don't generate a signal that can be caught. on those systems, use this option. or you can remove the checks with -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 need it
  • -fgo-check-divide-overflow โ€” adds explicit checks for division overflow ๐Ÿงฎ for example, overflow happens when computing INT_MIN / -1. in Go that should wrap around to INT_MIN. some processors, like x86, trap on division overflow, so on those systems you can use this option. or remove the checks with -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 info ๐Ÿ•ต๏ธโ€โ™€๏ธ larger values of n generate more info
  • -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 binary search across functions with this 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 that maps the patterns used with special "//go:embed" comments to the files named by those 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 meant for the go command to use when it implements "//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 a package path to the files containing export data. this option is meant for the go command
  • -g โ€” this is the standard gcc option, and it's mentioned here because gccgo turns on debugging info generation by default, which is the equivalent of the standard -g1 ๐Ÿ› that's because Go programs need debugging info to get backtrace info. you can use an explicit -g0 to disable debugging info generation, but then certain standard library functions, like "runtime.Callers", won't operate correctly ๐Ÿฅฒ

โœจ SEE ALSO โœจ

gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gccgo and gcc ๐Ÿ“–

Copyright (c) 2010-2026 Free Software Foundation, Inc.

okay the legal part, but make it cute ๐ŸŽ€ you're allowed to copy and 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.

that's the whole tea, bestie ๐Ÿ’œ this page is from gcc-16, dated 2026-03-22, and you're officially a gccgo expert now ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from