builder

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 41 Imported by: 0

Documentation

Overview

Package builder is the compiler driver of TinyGo. It takes in a package name and an output path, and outputs an executable. It manages the entire compilation pipeline in between.

Index

Constants

This section is empty.

Variables

View Source
var CompilerRT = Library{
	// contains filtered or unexported fields
}

CompilerRT is a library with symbols required by programs compiled with LLVM. These symbols are for operations that cannot be emitted with a single instruction or a short sequence of instructions for that target.

For more information, see: https://compiler-rt.llvm.org/

View Source
var MinGW = Library{
	// contains filtered or unexported fields
}
View Source
var Musl = Library{
	// contains filtered or unexported fields
}
View Source
var Picolibc = Library{
	// contains filtered or unexported fields
}

Picolibc is a C library for bare metal embedded devices. It was originally based on newlib.

Functions

func Build

func Build(pkgName, outpath string, config *compileopts.Config, action func(BuildResult) error) error

Build performs a single package to executable Go build. It takes in a package name, an output path, and set of compile options and from that it manages the whole compilation process.

The error value may be of type *MultiError. Callers will likely want to check for this case and print such errors individually.

func LookupCommand added in v0.21.0

func LookupCommand(name string) (string, error)

LookupCommand looks up the executable name for a given LLVM tool such as clang or wasm-ld. It returns the (relative) command that can be used to invoke the tool or an error if it could not be found.

func NewConfig

func NewConfig(options *compileopts.Options) (*compileopts.Config, error)

NewConfig builds a new Config object from a set of compiler options. It also loads some information from the environment while doing that. For example, it uses the currently active GOPATH (from the goenv package) to determine the Go version to use.

func ReadBuildID added in v0.22.0

func ReadBuildID() ([]byte, error)

ReadBuildID reads the build ID from the currently running executable.

func RunTool added in v0.13.0

func RunTool(tool string, args ...string) error

RunTool runs the given tool (such as clang).

This version doesn't actually run the tool: TinyGo has not been compiled by statically linking to LLVM.

Types

type BuildResult added in v0.15.0

type BuildResult struct {
	// The executable directly from the linker, usually including debug
	// information. Used for GDB for example.
	Executable string

	// A path to the output binary. It will be removed after Build returns, so
	// if it should be kept it must be copied or moved away.
	// It is often the same as Executable, but differs if the output format is
	// .hex for example (instead of the usual ELF).
	Binary string

	// The directory of the main package. This is useful for testing as the test
	// binary must be run in the directory of the tested package.
	MainDir string

	// The root of the Go module tree.  This is used for running tests in emulator
	// that restrict file system access to allow them to grant access to the entire
	// source tree they're likely to need to read testdata from.
	ModuleRoot string

	// ImportPath is the import path of the main package. This is useful for
	// correctly printing test results: the import path isn't always the same as
	// the path listed on the command line.
	ImportPath string
}

BuildResult is the output of a build. This includes the binary itself and some other metadata that is obtained while building the binary.

type Library added in v0.13.0

type Library struct {
	// contains filtered or unexported fields
}

Library is a container for information about a single C library, such as a compiler runtime or libc.

func (*Library) Load added in v0.13.0

func (l *Library) Load(config *compileopts.Config, tmpdir string) (dir string, err error)

Load the library archive, possibly generating and caching it if needed. The resulting directory may be stored in the provided tmpdir, which is expected to be removed after the Load call.

type MultiError

type MultiError struct {
	Errs []error
}

MultiError is a list of multiple errors (actually: diagnostics) returned during LLVM IR generation.

func (*MultiError) Error

func (e *MultiError) Error() string

Jump to

Keyboard shortcuts

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