Documentation ¶
Overview ¶
Package compileopts contains the configuration for a single to-be-built binary.
Index ¶
- type Config
- func (c *Config) BuildTags() []string
- func (c *Config) CFlags() []string
- func (c *Config) CPU() string
- func (c *Config) Debug() bool
- func (c *Config) DumpSSA() bool
- func (c *Config) ExtraFiles() []string
- func (c *Config) Features() []string
- func (c *Config) GC() string
- func (c *Config) GOARCH() string
- func (c *Config) GOOS() string
- func (c *Config) LDFlags() []string
- func (c *Config) NeedsStackObjects() bool
- func (c *Config) OpenOCDConfiguration() (args []string, err error)
- func (c *Config) PanicStrategy() string
- func (c *Config) Programmer() (method, openocdInterface string)
- func (c *Config) Scheduler() string
- func (c *Config) Triple() string
- func (c *Config) VerifyIR() bool
- type Options
- type TargetSpec
- type TestConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Options *Options Target *TargetSpec GoMinorVersion int ClangHeaders string // Clang built-in header include path TestConfig TestConfig }
Config keeps all configuration affecting the build in a single struct.
func (*Config) BuildTags ¶
BuildTags returns the complete list of build tags used during this build.
func (*Config) CFlags ¶
CFlags returns the flags to pass to the C compiler. This is necessary for CGo preprocessing.
func (*Config) CPU ¶
CPU returns the LLVM CPU name, like atmega328p or arm7tdmi. It may return an empty string if the CPU name is not known.
func (*Config) Debug ¶
Debug returns whether to add debug symbols to the IR, for debugging with GDB and similar.
func (*Config) DumpSSA ¶
DumpSSA returns whether to dump Go SSA while compiling (-dumpssa flag). Only enable this for debugging.
func (*Config) ExtraFiles ¶
ExtraFiles returns the list of extra files to be built and linked with the executable. This can include extra C and assembly files.
func (*Config) Features ¶
Features returns a list of features this CPU supports. For example, for a RISC-V processor, that could be ["+a", "+c", "+m"]. For many targets, an empty list will be returned.
func (*Config) GC ¶
GC returns the garbage collection strategy in use on this platform. Valid values are "none", "leaking", and "conservative".
func (*Config) GOARCH ¶
GOARCH returns the GOARCH of the target. This might not always be the actual archtecture: for example, the AVR target is not supported by the Go standard library so such targets will usually pretend to be linux/arm.
func (*Config) GOOS ¶
GOOS returns the GOOS of the target. This might not always be the actual OS: for example, bare-metal targets will usually pretend to be linux to get the standard library to compile.
func (*Config) LDFlags ¶
LDFlags returns the flags to pass to the linker. A few more flags are needed (like the one for the compiler runtime), but this represents the majority of the flags.
func (*Config) NeedsStackObjects ¶
NeedsStackObjects returns true if the compiler should insert stack objects that can be traced by the garbage collector.
func (*Config) OpenOCDConfiguration ¶
OpenOCDConfiguration returns a list of command line arguments to OpenOCD. This list of command-line arguments is based on the various OpenOCD-related flags in the target specification.
func (*Config) PanicStrategy ¶
PanicStrategy returns the panic strategy selected for this target. Valid values are "print" (print the panic value, then exit) or "trap" (issue a trap instruction).
func (*Config) Programmer ¶
Programmer returns the flash method and OpenOCD interface name given a particular configuration. It may either be all configured in the target JSON file or be modified using the -programmmer command-line option.
func (*Config) Scheduler ¶
Scheduler returns the scheduler implementation. Valid values are "coroutines" and "tasks".
type Options ¶
type Options struct { Target string Opt string GC string PanicStrategy string Scheduler string PrintIR bool DumpSSA bool VerifyIR bool Debug bool PrintSizes string CFlags []string LDFlags []string Tags string WasmAbi string HeapSize int64 TestConfig TestConfig Programmer string }
Options contains extra options to give to the compiler. These options are usually passed from the command line.
type TargetSpec ¶
type TargetSpec struct { Inherits []string `json:"inherits"` Triple string `json:"llvm-target"` CPU string `json:"cpu"` Features []string `json:"features"` GOOS string `json:"goos"` GOARCH string `json:"goarch"` BuildTags []string `json:"build-tags"` GC string `json:"gc"` Scheduler string `json:"scheduler"` Compiler string `json:"compiler"` Linker string `json:"linker"` RTLib string `json:"rtlib"` // compiler runtime library (libgcc, compiler-rt) CFlags []string `json:"cflags"` LDFlags []string `json:"ldflags"` LinkerScript string `json:"linkerscript"` ExtraFiles []string `json:"extra-files"` Emulator []string `json:"emulator"` FlashCommand string `json:"flash-command"` GDB string `json:"gdb"` PortReset string `json:"flash-1200-bps-reset"` FlashMethod string `json:"flash-method"` FlashVolume string `json:"msd-volume-name"` FlashFilename string `json:"msd-firmware-name"` OpenOCDInterface string `json:"openocd-interface"` OpenOCDTarget string `json:"openocd-target"` OpenOCDTransport string `json:"openocd-transport"` }
Target specification for a given target. Used for bare metal targets.
The target specification is mostly inspired by Rust: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html https://github.com/shepmaster/rust-arduino-blink-led-no-core-with-cargo/blob/master/blink/arduino.json
type TestConfig ¶
type TestConfig struct {
CompileTestBinary bool
}