GCCGO(1)

πŸ“¦
version 11.5.0 Β· 5 versions
, in ubuntu questing, ubuntu resolute, ubuntu stonking

✨ GCCGO(1) β€” gccgo πŸ’–

πŸ’… NAME

okay so gccgo is a GCC-based compiler for the Go language and it is literally iconic πŸ”₯


πŸŽ€ SYNOPSIS

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

Only the most useful options are listed here; see below for the remainder. 🌸


πŸ¦‹ DESCRIPTION

bestie, the gccgo command is a frontend to gcc and it supports many of the same options 🧚 This manual only documents the options specific to gccgo, so no need to panic πŸ’œ

The gccgo command can compile Go source code into an object file, link a collection of object files together, or do both in sequence. ✨

Go source code gets compiled as packages. A package is one or more Go source files, and all the files in a single package must be compiled together by passing every file as an argument to gccgo. A single invocation of gccgo may only compile a single package, so one at a time, periodt πŸ’…

One Go package may "import" a different Go package. The imported package must have already been compiled, and gccgo reads the import data directly from the compiled package. When this package is later linked, the compiled form of the package must be included in the link command. 🫢

Go programs must generally be compiled with debugging information, and -g1 is the default as described below. Stripping a Go program will generally cause it to misbehave or fail. > πŸ’€ Do NOT strip your Go program, it will get messy fr fr.


πŸ‘‘ OPTIONS

  • -Idir β€” tell gccgo which directory to search when it's looking for an import package at compile time πŸ—ΊοΈ
  • -Ldir β€” when linking, specify a library search directory, same as 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 that will be used to import this package after it's installed, so basically a pathname inside the directories given by -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 -fgo-pkgpath is used, -fgo-prefix gets ignored, so pick one πŸŽ€

Go lets a single program include more than one package with the same name in the package clause, though the two packages obviously have to 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 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 is 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. 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, trap on division overflow, so on those systems use this option. You can 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 need it. πŸ”₯
  • -fno-go-optimize-allocs β€” disables escape analysis, which tries to allocate objects on the stack rather than the heap. 🌸
  • -fgo-debug-escapen β€” outputs escape analysis debugging information. Larger values of n generate more info πŸ”
  • -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 matching 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 patterns used with special //go:embed comments to the files named by those patterns. The JSON file should have two parts: "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 gccgo turns on debugging info generation by default, the equivalent of the standard -g1. Go programs need debugging info to be available so they can produce backtrace info. You can pass 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-2021 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.


bestie that's the whole page, gcc-11 vibes from 2024-07-19 and you're officially a gccgo expert now πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from