GCCGO(1)
π gccgo π
okay bestie, this is the GNU manual for gccgo, the GCC-based compiler for Go. it's giving compiler main character energy β¨
π NAME π
gccgo - A GCC-based compiler for the Go language π
that's the whole identity right there, periodt.
π¦ SYNOPSIS π¦
gccgo [-c|-S]
[-g] [-pg] [-Olevel]
[-Idir...] [-Ldir...]
[-o outfile] infile...
Only the most useful options are listed here, bestie. the rest are down in OPTIONS π«Ά
πΈ DESCRIPTION πΈ
okay so gccgo is a frontend to gcc and it shares a lot of the same options π§ this manual only covers the options that are special to gccgo.
The gccgo command can compile Go source code into an object file, link a collection of object files together, or do both in sequence. lowkey so versatile π
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, so pass every file as an argument to gccgo. A single invocation of gccgo can only compile a single package, no exceptions π
One Go package can "import" a different Go package. the imported package must already be compiled, and gccgo reads the import data directly from the compiled package. when this 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) π
π Warning: stripping a Go program will generally cause it to misbehave or fail. do not strip your Go program, bestie.
π OPTIONS π
-Idirβ tellsgccgowhich directory to search when looking for an import package at compile time π-Ldirβ when linking, adds a library search directory, just like withgccπ-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 you'll use to import this package after it's installed, which means a pathname within the directories specified by the-Ioption β¨-fgo-prefix=stringβ an alternative to-fgo-pkgpath. the argument gets combined with the package name from the source file to produce the package path. if-fgo-pkgpathis used,-fgo-prefixgets ignored π- Go lets a single program include more than one package with the same name in the "package" clause of the source file, though the two packages obviously must be imported using different pathnames. for this to work with
gccgo, either-fgo-pkgpathor-fgo-prefixmust be specified when compiling a package π«Ά - using either
-fgo-pkgpathor-fgo-prefixdisables the special treatment of the "main" package and lets that package be imported like any other π
- Go lets a single program include more than one package with the same name in the "package" clause of the source file, though the two packages obviously must be imported using different pathnames. for this to work with
-fgo-relative-import-path=dirβ a relative import is one that starts with./or../. with this option,gccgousesdiras a prefix for the relative import when searching for it π¦-frequire-return-statement,-fno-require-return-statementβ by defaultgccgowarns 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 modulos) by zero causes a panic. on Unix systems this gets detected at runtime by catching theSIGFPEsignal. some processors, like PowerPC, don't generate aSIGFPEon 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 wrap around to produceINT_MIN. some processors, like x86, generate a trap on division overflow. on those systems, use this option. or remove the checks 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 need 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 that match the given suffixn. it can be used to binary search 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, and 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 thegocommand to implement//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 package path to files containing export data. this option is meant for thegocommand π«Ά-gβ this is the standard gcc option, and it's mentioned here because by defaultgccgoturns on debugging information generation with the equivalent of the standard option-g1. Go programs need debugging information to be available in order to get backtrace information. an explicit-g0can disable debugging information generation, but then certain standard library functions, such asruntime.Callers, will not 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-2024 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 tea, bestie π«Ά this page is from gcc-14, dated 2024-04-12, and it's GCCGO(1) all the way. go compile something iconic πβ¨
π¦ where this page comes from
- ubuntu noble: gccgo-14-powerpc64-linux-gnu 14-20240412-0ubuntu1cross1
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms