GCCGO(1)
β¨ NAME β¨
gccgo π is a GCC-based compiler for the Go language, and it's literally so good. π¦
π SYNOPSIS π
gccgo [-c|-S]
[-g] [-pg] [-Olevel]
[-Idir...] [-Ldir...]
[-o outfile] infile...
Only the most useful options are listed up there, so scroll down for the rest π
π DESCRIPTION π
okay so gccgo is basically a frontend to gcc πΈ and it supports a lot of the same options gcc does. this page only covers the gccgo-specific ones, because that's the tea we need.
gccgo can compile Go source code into an object file, link a bunch of object files together, or do both back-to-back β¨
Go source code gets compiled as packages. A package is one or more Go source files, and all the files in a single package have to be compiled together, so pass every file in as an argument to gccgo. One invocation of gccgo can only compile a single package π§
One Go package can "import" a different Go package. The imported package must already be compiled, and gccgo reads the import data straight from the compiled package. When the importing package gets linked later, the compiled form of the imported package has to be included in the link command π
Go programs generally need to be compiled with debugging information, and -g1 is the default (more on that below) π Stripping a Go program will usually make it misbehave or fail.
π bestie, stripping a Go program will generally cause it to misbehave or fail. Don't do it!
β¨ OPTIONS β¨
-Idirβ tells gccgo which directory to hunt through when it's looking for an import package at compile time π-Ldirβ when linking, adds a library search directory, just like with gcc π§-fgo-pkgpath=stringβ sets the package path. This is the value handed back by thePkgPathmethod ofreflect.Typeobjects, and it also shapes the names of globally visible symbols. The argument should normally be the same string you'd use to import this package after it's installed, aka a pathname inside the directories given by-I.-fgo-prefix=stringβ the alternative to-fgo-pkgpath. The argument gets combined with the package name from the source file to make the package path. If-fgo-pkgpathis used,-fgo-prefixgets ignored.- Go lets one program include more than one package with the same name in the
"package"clause, though the two packages obviously need to be imported using different pathnames. For that to work with gccgo, you have to specify either-fgo-pkgpathor-fgo-prefixwhen compiling a package π - Using either
-fgo-pkgpathor-fgo-prefixturns off the special treatment of the"main"package and lets it be imported like any other package π
- Go lets one program include more than one package with the same name in the
-fgo-relative-import-path=dirβ a relative import starts with./or../. With this option, gccgo usesdiras 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, dividing (or taking the modulo) by zero causes a panic. On Unix systems this gets detected at runtime by catching theSIGFPEsignal. 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 this option can be used. The checks can also 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 need it π-fgo-check-divide-overflowβ adds explicit checks for division overflow. For example, overflow happens when computingINT_MIN / -1. In Go this should wrap around to produceINT_MIN. Some processors, like x86, generate a trap on division overflow, and 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 it may be off by default on systems that don't require it π-fno-go-optimize-allocsβ disables escape analysis, which tries to allocate objects on the stack instead of the heap π§±-fgo-debug-escapenβ outputs escape analysis debugging information. Larger values ofngenerate more information π-fgo-debug-escape-hash=nβ a hash value for debugging escape analysis.nis a binary string. This runs escape analysis only on functions whose names hash to values matching the given suffixn. It's super handy 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 tofileas 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 here, but some additional compiler directives are supported π-fgo-embedcfg=fileβ identifies a JSON file that maps patterns used with special//go:embedcomments 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 implement//go:embedπ¦-gβ the standard gcc option, mentioned here because by default gccgo turns on debugging information generation with the equivalent of the standard option-g1. This is because Go programs need debugging information available in order to get backtrace information. An explicit-g0can disable the generation of debugging information, but then certain standard library functions, such asruntime.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 π
Copyright (c) 2010-2022 Free Software Foundation, Inc. π
okay the legal bit, but make it cute: you're allowed to copy, distribute and/or modify this document under 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. π«Ά
π§ source: gcc-12, dated 2022-03-02, all about GCCGO(1). ily bestie, now go compile something iconic π π
π¦ where this page comes from
- ubuntu jammy: gccgo-12-riscv64-linux-gnu 12-20220302-1ubuntu1cross1
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms