Documentation
¶
Index ¶
- Constants
- func Clean(patterns []string, conf *Config)
- func DefaultBuildTags(goarch, target string) string
- func IsFullRpathEnabled() bool
- func IsFuncInfoEnabled() bool
- func IsFuncInfoSitesEnabled() bool
- func IsOptimizeEnabled() bool
- func IsStdioNobuf() bool
- func IsTraceEnabled() bool
- func IsWasiThreadsEnabled() bool
- func Plan9ASMPkgs() string
- func ValidateBuildMode(mode string) error
- func WasmRuntime() string
- type AbiMode
- type BuildMode
- type Config
- type DWARFMode
- type Invocation
- type LinkOptions
- type Mode
- type ModuleHook
- type OutFmtDetails
- type OutFmts
- type OutputCfg
- type PCLNMode
- type Package
- type Rewrites
Constants ¶
const ( SHN_UNDEF = 0x0000 // Undefined section SHN_LORESERVE = 0xFF00 // Start of reserved indices SHN_ABS = 0xFFF1 // Absolute values SHN_COMMON = 0xFFF2 // Common symbols SHN_XINDEX = 0xFFFF // Escape value for extended section indices )
ELF special section indices (from ELF specification)
Variables ¶
This section is empty.
Functions ¶
func DefaultBuildTags ¶
DefaultBuildTags returns the build tags LLGo always enables for a target.
func IsFullRpathEnabled ¶
func IsFullRpathEnabled() bool
func IsFuncInfoEnabled ¶
func IsFuncInfoEnabled() bool
func IsFuncInfoSitesEnabled ¶
func IsFuncInfoSitesEnabled() bool
IsFuncInfoSitesEnabled controls the body-embedded site records independently of the funcinfo tables (LLGO_FUNCINFO_SITES=0 keeps the metadata but drops entry and PC-line inline-asm sites). Useful for isolating codegen perturbation caused by the in-body asm anchors.
func IsOptimizeEnabled ¶
func IsOptimizeEnabled() bool
func IsStdioNobuf ¶
func IsStdioNobuf() bool
func IsTraceEnabled ¶
func IsTraceEnabled() bool
func IsWasiThreadsEnabled ¶
func IsWasiThreadsEnabled() bool
func Plan9ASMPkgs ¶
func Plan9ASMPkgs() string
func ValidateBuildMode ¶
ValidateBuildMode checks if the build mode is valid
func WasmRuntime ¶
func WasmRuntime() string
Types ¶
type Config ¶
type Config struct {
Goos string
Goarch string
GO386 string // 386 floating-point implementation: sse2 or softfloat
GOAMD64 string // amd64 microarchitecture level: v1 through v4
GOARM string // arm architecture and floating-point implementation
GOARM64 string // arm64 ISA version and optional lse/crypto extensions
Target string // target name (e.g., "rp2040", "wasi") - takes precedence over Goos/Goarch
OptLevel optlevel.Level
LTO lto.Mode
LTOPlugin lto.PassPlugin
BinPath string
AppExt string // ".exe" on Windows, empty on Unix
OutFile string // output file, or directory for ModeBuild package executables
OutFmts OutFmts // Output format specifications (only for Target != "")
CompileOnly bool // compile test binary but do not run it (only valid for ModeTest)
Emulator bool // run in emulator mode
Port string // target port for flashing
BaudRate int // baudrate for serial communication
RunArgs []string
Mode Mode
BuildMode BuildMode // Build mode: exe, c-archive, c-shared
AbiMode AbiMode
GenExpect bool // only valid for ModeCmpTest
Verbose bool
PrintPackages bool // print package paths after successful compilation
PrintCommands bool
GenLL bool // generate pkg .ll files
DeadcodeDrop bool // enable Go dead code drop (development builds only)
CollectPackageMeta bool // collect package metadata without enabling dead code drop
CheckLLFiles bool // check .ll files valid
CheckLinkArgs bool // check linkargs valid
ForceEspClang bool // force to use esp-clang
ForceRebuild bool // force rebuilding of packages that are already up-to-date
Tags string
SizeReport bool // print size report after successful build
SizeFormat string // size report format: text,json (default text)
SizeLevel string // size aggregation level: full,module,package (default module)
CompilerHash string // metadata hash for the running compiler (development builds only)
GoVersion string // Go language version accepted by the frontend (for example, "go1.22")
NoErrorColumn bool // omit source columns from frontend diagnostics
// GoBuildFlags contains normalized raw Go build flags forwarded to
// go/packages. Callers use internal/goflags to parse supported compiler and
// linker semantics into typed Config fields before calling Do.
GoBuildFlags []string
// BuildParallelism is the package-level concurrency requested by Go's -p
// build flag. Zero uses the Go default, GOMAXPROCS.
BuildParallelism int
// BuildTrace is an optional Chrome Trace Event JSON output path. Relative
// paths are resolved from the build invocation directory.
BuildTrace string
LinkOptions LinkOptions
// OmitDWARFByDefault controls linked builds only when -w was not
// explicitly specified. Explicit -w and -w=false always win.
OmitDWARFByDefault bool
PCLNMode PCLNMode
// PCLNModeSet marks PCLNMode as authoritative. Command flags set it for
// explicit requests; Do sets it after resolving the legacy environment
// default.
PCLNModeSet bool
AllowNoBody bool // allow declarations without bodies, as go tool compile does
// DisableBoundsChecks disables index, slice, and slice-to-array conversion
// bounds checks while retaining required integer conversions and nil checks.
DisableBoundsChecks bool
// SaturatingFloatToUint32 enables Go's experimental converthash behavior
// for float-to-uint32 conversions.
SaturatingFloatToUint32 bool
// PthreadStackSize sets a custom stack size, in bytes, for pthread-backed
// goroutines. A zero value keeps the platform pthread default.
PthreadStackSize int64
// DisableGoGlobalDCE disables Go-specific global DCE metadata emission
// when it would otherwise be enabled by full LTO.
DisableGoGlobalDCE bool
// GlobalRewrites specifies compile-time overrides for global string variables.
// Keys are fully qualified package paths (e.g. "main" or "github.com/user/pkg").
// Each Rewrites entry maps variable names to replacement string values. Only
// string-typed globals are supported and "main" applies to all root main
// packages in the current build.
GlobalRewrites map[string]Rewrites
ModuleHook ModuleHook
Overlay map[string][]byte
// TestPythonPackage supplies the synthetic Python ABI root used by compiler
// fixtures that intentionally avoid importing github.com/goplus/lib/py.
// Production callers leave this nil; the provider is evaluated once per Do.
TestPythonPackage func() *types.Package
}
func NewDefaultConf ¶
type DWARFMode ¶
type DWARFMode uint8
DWARFMode records whether the command layer requested that the backend preserve or omit DWARF. DWARFDefault leaves the decision to other link options.
type Invocation ¶
type Invocation struct {
Args []string
Config *Config
Dir string
// contains filtered or unexported fields
}
Invocation contains the explicit inputs used by one build. An empty Dir uses the working directory captured when Build starts. Build inherits one snapshot of the process environment; per-invocation overrides are not supported.
type LinkOptions ¶
type LinkOptions struct {
// OmitSymbolTable records the requested -s intent. Phase one uses it for
// Go's implied -w rule; native symbol-table omission is implemented later.
OmitSymbolTable bool
DWARF DWARFMode
// ExternalLinker and ExternalLinkerFlags retain the Go linker's -extld
// command and -extldflags argument-list spelling. The native toolchain
// resolver applies Go's quoted command parsing after target selection.
ExternalLinker string
ExternalLinkerFlags string
}
LinkOptions is the typed linker intent consumed by the build backend. Command packages are responsible for parsing user-facing flag syntax into this representation.
func (LinkOptions) EffectiveOmitDWARF ¶
func (o LinkOptions) EffectiveOmitDWARF() bool
EffectiveOmitDWARF reports whether the backend should omit DWARF. As in cmd/link, an explicit -w value takes precedence; otherwise -s implies -w.
type ModuleHook ¶
type ModuleHook func(pkg Package)
ModuleHook observes a package module immediately after it is generated and before TransformModule mutates it. The callback runs synchronously and receives the live llvm.Module, so callers that need a stable snapshot should consume it immediately (for example, by calling mod.String() inside the hook).
type OutFmtDetails ¶
type OutFmtDetails struct {
Out string // Base output file path
PCLN string // PCLN sidecar output file path (.pclntab)
Bin string // Binary output file path (.bin)
Hex string // Intel hex output file path (.hex)
Img string // Image output file path (.img)
Uf2 string // UF2 output file path (.uf2)
Zip string // ZIP/DFU output file path (.zip)
}
OutFmtDetails contains detailed output file paths for each format
func (*OutFmtDetails) ToEnvMap ¶
func (details *OutFmtDetails) ToEnvMap() map[string]string
ToEnvMap converts OutFmtDetails to a map for template substitution
type OutFmts ¶
type OutFmts struct {
Bin bool // Generate binary output (.bin)
Hex bool // Generate Intel hex output (.hex)
Img bool // Generate image output (.img)
Uf2 bool // Generate UF2 output (.uf2)
Zip bool // Generate ZIP/DFU output (.zip)
}
OutFmts contains output format specifications for embedded targets
type OutputCfg ¶
type OutputCfg struct {
OutPath string // Final output file path
IntPath string // Intermediate file path (for two-stage conversion)
OutExt string // Output file extension
FileFmt string // File format (from conf.FileFormat or extracted from emulator)
BinFmt string // Binary format for firmware conversion (may have -img suffix)
NeedFwGen bool // Whether firmware image generation is needed
DirectGen bool // True if can generate firmware directly without intermediate file
}
OutputCfg contains the generated output paths and conversion configuration
type PCLNMode ¶
type PCLNMode uint8
PCLNMode controls how Go program counter and line metadata is packaged.
Source Files
¶
- build.go
- build_trace.go
- cache.go
- cgo.go
- cgo_pragmas.go
- clean.go
- cmptest.go
- collect.go
- dependencies.go
- fingerprint.go
- funcinfo_table.go
- init_order.go
- invocation.go
- link_options.go
- macho_size.go
- main_module.go
- multi_build.go
- outputs.go
- package_archive.go
- package_build.go
- pcln_mode.go
- pclntab_external.go
- pclntab_llvm.go
- plan9asm.go
- resolver.go
- run.go
- size_report.go
- source_patch.go
- ssa_order_fix.go