GCCGO(1)
π GCCGO(1) Β· gccgo π
okay bestie, this is the manual for gccgo, and it's giving GCC-powered Go compiler energy β¨
π§ NAME π§
gccgo is the GCC-based compiler for the Go language. no cap, it's iconic π
π SYNOPSIS π
gccgo [-c|-S]
[-g] [-pg] [-Olevel]
[-Idir...] [-Ldir...]
[-o outfile] infile...
only the most useful options are listed up here, so check below for the rest ππΈ
π DESCRIPTION π
okay so gccgo is a frontend to gcc and it supports a lot of the same options π«Ά this page only covers the stuff that's specific to gccgo, so you don't have to relearn all of gcc π
the gccgo command 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 one package have to be compiled together, so pass every file as an argument to gccgo. a single invocation of gccgo can only compile a single package, so don't try to be extra π
one Go package can "import" a different Go package. the imported package has to be compiled already, and gccgo reads the import data straight from the compiled package π§ when this package gets linked later, the compiled form of that package has to be 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 generally cause it to misbehave or fail. do not strip your Go programs, bestie π
π¦ OPTIONS π¦
-Idirβ pick a directory to search when hunting for an import package at compile time π-Ldirβ when linking, set a library search directory, same as with gcc π-fgo-pkgpath=stringβ sets the package path β¨ this is the value returned by thePkgPathmethod ofreflect.Typeobjects, and it's also used for the names of globally visible symbols. the argument should normally be the string that gets used to import this package after it's installed, which is basically a pathname inside the directories given by the-Ioption π£οΈ-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-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 have to be imported using different pathnames. for this to work with gccgo, you need to specify either-fgo-pkgpathor-fgo-prefixwhen 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 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 caught at runtime 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, division overflow happens when computingINT_MIN / -1. in Go this should be wrapped to produceINT_MIN. some processors, like x86, generate a trap on division overflow, so on those systems 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 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 information.-fgo-debug-escape-hash=nβ a hash value for debugging 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 and 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, and some additional compiler directives are supported.-fgo-embedcfg=fileβ identifies a JSON file that maps patterns used with the 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 use when it implements//go:embed.-gβ this is the standard gcc option, but it's mentioned here because by default gccgo turns on debugging information generation with the equivalent of the standard option-g1πͺ² Go programs need debugging info to get backtrace information. an explicit-g0disables debugging info generation, but then certain standard library functions, like "runtime.Callers", won't work 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. π·
Permission is granted 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.
that's a wrap, bestie π¦π this page is from gcc-12 and was dated 2022-02-22. go compile something iconic πβ¨
π¦ where this page comes from
- ubuntu jammy: gccgo-12-powerpc64le-linux-gnu 12-20220222-1ubuntu1cross1
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms