GCCGO(1)

πŸ“¦
version 14-20240412 Β· 5 versions
, in ubuntu noble

πŸ’– 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 β€” tells gccgo which directory to search when 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 returned by 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 string you'll use to import this package after it's installed, which means a pathname within the directories specified by the -I option ✨
  • -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-pkgpath is used, -fgo-prefix gets 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-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 lets that package be imported like any other πŸ‘‘
  • -fgo-relative-import-path=dir β€” a relative import is one that starts with ./ or ../. with this option, gccgo uses dir as a prefix for the relative import when searching 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 modulos) by zero causes a panic. on Unix systems this gets detected 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 computing INT_MIN / -1. in Go this should wrap around to produce INT_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 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. 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 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 here, and some additional compiler directives are supported 🌈
  • -fgo-embedcfg=file β€” identifies a JSON file that maps 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 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 the go command 🫢
  • -g β€” this is the standard gcc option, and 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 information to be available in order to get backtrace information. an explicit -g0 can disable debugging information generation, but then certain standard library functions, such as runtime.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 (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