crosscompile

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// WASIThreadedEmulator runs shared-memory modules with standard Wasm EH
	// and SIMD. Wasmer chooses an available backend; the pinned Windows CLI
	// uses V8 and supported Unix builds prefer Cranelift for these modules.
	// wasi-libc manages its own heap inside the module memory.
	// The runner resolves the working-directory preopen to an absolute path
	// before execution and also grants Go's default /tmp directory.
	WASIThreadedEmulator = `wasmer run --enable-exceptions --enable-simd --stack-size=1048576 --volume=. --volume=/tmp "{}"`

	WasmProfileNone WasmProfile = ""
	WasmProfileJ32  WasmProfile = "j32"
	WasmProfileJ64  WasmProfile = "j64"
	WasmProfileW32  WasmProfile = "w32"

	WasmProviderNone       WasmProvider = ""
	WasmProviderGoJS       WasmProvider = "gojs"
	WasmProviderEmscripten WasmProvider = "emscripten"
	WasmProviderWASI       WasmProvider = "wasi"
)

Variables

This section is empty.

Functions

func EnableWasmReflectLibffi added in v1.0.7

func EnableWasmReflectLibffi(export *Export) error

EnableWasmReflectLibffi keeps the JS closure replay entries outside Asyncify. The separately instrumented Go invocation resumes with the current buffers.

Types

type CRTFlavor added in v1.0.1

type CRTFlavor string
const (
	CRTFlavorUnknown CRTFlavor = ""
	CRTFlavorUCRT    CRTFlavor = "ucrt"
)

type CXXRuntimeFlavor added in v1.0.1

type CXXRuntimeFlavor string
const (
	CXXRuntimeUnknown CXXRuntimeFlavor = ""
	CXXRuntimeMSVC    CXXRuntimeFlavor = "msvc"
)

type DebugInfoCapability added in v1.0.7

type DebugInfoCapability uint8

DebugInfoCapability describes whether the selected linker and its linked output format can retain DWARF. Deployment formats such as bin, hex, and uf2 are derived later and do not affect this capability.

const (
	DebugInfoRetainable DebugInfoCapability = iota
	DebugInfoUnavailable
)

type DebugInfoPolicy

type DebugInfoPolicy struct {
	Capability        DebugInfoCapability
	OmitLinkFlags     []string
	PreserveLinkFlags []string
	// PreserveDriverFlags applies only to compiler-driver invocation paths.
	// Direct embedded linkers retain DWARF without these compiler options.
	PreserveDriverFlags []string
}

DebugInfoPolicy describes how a selected linker handles debug information. Build orchestration consumes this typed capability instead of inferring it from a target name or linker executable.

func (DebugInfoPolicy) CanRetain added in v1.0.7

func (p DebugInfoPolicy) CanRetain() bool

type DriverFlavor added in v1.0.1

type DriverFlavor string
const (
	DriverFlavorUnknown  DriverFlavor = ""
	DriverFlavorClangGNU DriverFlavor = "clang"
)

type Export

type Export struct {
	CC      string // C compiler executable
	CCArgs  []string
	CXX     string // C++ compiler executable
	CXXArgs []string
	CCFLAGS []string
	CFLAGS  []string
	LDFLAGS []string
	// CompilerIdentity values are stable version strings used to keep cached
	// packages separate when an explicit native toolchain changes.
	CCIdentity  string
	CXXIdentity string
	// Toolchain records the ABI and flag dialect selected for native-format
	// outputs. It is independent of the host shell and remains empty for named
	// embedded/WebAssembly targets that drive their linker directly.
	Toolchain NativeToolchain
	// WasmProfile is the selected memory/host ABI pair. WasmProvider identifies
	// the concrete host implementation without creating another source profile.
	// Both values participate in package-cache identity.
	WasmProfile  WasmProfile
	WasmProvider WasmProvider

	// Additional fields from target configuration
	BuildTags      []string
	GOOS           string
	GOARCH         string
	Libc           string
	Linker         string // Linker to use (e.g., "ld.lld", "avr-ld")
	LinkerArgs     []string
	LinkerIdentity string
	ExtraFiles     []string // Extra files to compile and link (e.g., .s, .c files)
	ClangRoot      string   // Root directory of custom clang installation
	ClangBinPath   string   // Path to clang binary directory

	LLVMTarget   string   // LLVM Target
	TargetABI    string   // RISC-V Target ABI (e.g., "lp64", "lp64d")
	BinaryFormat string   // Binary format (e.g., "elf", "esp", "uf2")
	FormatDetail string   // For uf2, it's uf2FamilyID
	Emulator     string   // Emulator command template (e.g., "qemu-system-arm -M {} -kernel {}")
	GDB          []string // GDB command candidates in preference order
	DebugInfo    DebugInfoPolicy
	WasmPostLink WasmPostLink
	WasmRuntime  WasmRuntime

	// Flashing/Debugging configuration
	Device flash.Device // Device configuration for flashing/debugging
}

func Use

func Use(goos, goarch, targetName string, forceEspClang bool, level optlevel.Level, ltoMode lto.Mode, goGlobalDCE bool) (export Export, err error)

Use extends the original Use function to support target-based configuration If targetName is provided, it takes precedence over goos/goarch

func UseTarget

func UseTarget(targetName string, level optlevel.Level, ltoMode lto.Mode) (export Export, err error)

UseTarget loads configuration from a target name (e.g., "rp2040", "wasi")

func UseWithGOARM added in v1.0.1

func UseWithGOARM(goos, goarch, goarm, targetName string, forceEspClang bool, level optlevel.Level, ltoMode lto.Mode, goGlobalDCE bool) (export Export, err error)

UseWithGOARM is Use with an explicit Go ARM architecture setting. The setting affects native GOARCH=arm clang and linker triples; named targets retain their target configuration's LLVM triple.

func UseWithGOARMAndToolchain added in v1.0.1

func UseWithGOARMAndToolchain(goos, goarch, goarm, targetName string, forceEspClang bool, level optlevel.Level, ltoMode lto.Mode, goGlobalDCE bool, nativeInput NativeToolchainInput) (export Export, err error)

UseWithGOARMAndToolchain is UseWithGOARM with explicit Go-compatible native compiler commands. Named -target configurations intentionally ignore these host commands and preserve their existing toolchain selection.

type LinkerFlavor added in v1.0.1

type LinkerFlavor string
const (
	LinkerFlavorUnknown  LinkerFlavor = ""
	LinkerFlavorELFLLD   LinkerFlavor = "ld.lld"
	LinkerFlavorMachO    LinkerFlavor = "ld64.lld"
	LinkerFlavorCOFFLLD  LinkerFlavor = "lld-link"
	LinkerFlavorMinGWLLD LinkerFlavor = "mingw-lld"
)

type NativeToolchain added in v1.0.1

type NativeToolchain struct {
	ABI            PlatformABI
	ObjectFormat   ObjectFormat
	Driver         DriverFlavor
	Linker         LinkerFlavor
	TargetTriple   string
	CRT            CRTFlavor
	CXXRuntime     CXXRuntimeFlavor
	SDKVersion     string
	CRTVersion     string
	ToolsetVersion string
}

NativeToolchain describes the externally visible ABI and the tools used to produce a native object. Keep these choices explicit: in particular, a Windows host does not imply either the MSVC or MinGW ABI.

type NativeToolchainInput added in v1.0.1

type NativeToolchainInput struct {
	CC             []string
	CXX            []string
	ExternalLinker []string
	ExternalFlags  []string
	Dir            string
	Environ        []string
	// ResolveWindows selects a Windows native-format toolchain when linked
	// output is produced for another architecture or from a non-Windows host.
	// Pure IR generation leaves it false so multi-target golden tests do not
	// depend on an installed compiler's architecture or ABI profile.
	ResolveWindows bool
}

NativeToolchainInput contains Go-compatible native compiler command prefixes and external-linker flags. CC, CXX, and ExternalLinker are parsed command prefixes: element zero is the executable and the remainder are arguments that must precede LLGo's generated flags. ExternalFlags is the plain flag list parsed from -extldflags.

type ObjectFormat added in v1.0.1

type ObjectFormat string
const (
	ObjectFormatUnknown ObjectFormat = ""
	ObjectFormatELF     ObjectFormat = "elf"
	ObjectFormatMachO   ObjectFormat = "macho"
	ObjectFormatCOFF    ObjectFormat = "coff"
)

type PlatformABI added in v1.0.1

type PlatformABI string
const (
	PlatformABIUnknown PlatformABI = ""
	PlatformABIGNU     PlatformABI = "gnu"
	PlatformABIDarwin  PlatformABI = "darwin"
	PlatformABIMsvc    PlatformABI = "msvc"
)
type WasmPostLink struct {
	Asyncify bool
}

WasmPostLink describes transformations required after the core module is linked. Build orchestration owns tool discovery and atomic output handling.

type WasmProfile added in v1.0.4

type WasmProfile string

WasmProfile is a hosted memory ABI and host ABI pair. C interoperability is a capability of the profile rather than a separate profile family.

type WasmProvider added in v1.0.4

type WasmProvider string

WasmProvider selects imports, host glue, and packaging for a profile.

type WasmRuntime added in v1.0.7

type WasmRuntime struct {
	// RunMainTask asks the host-provided entry point to invoke LLGo's logical
	// Go main task. Emscripten's PROXY_TO_PTHREAD owns main in worker mode.
	RunMainTask bool
}

WasmRuntime describes entry behavior implemented by the selected runtime.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL