Version: v0.19.0 Latest Latest

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

Go to latest
Published: Jun 30, 2021 License: BSD-3-Clause Imports: 33 Imported by: 0



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.



This section is empty.


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:

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.


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 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 RunTool

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.


type BuildResult

type BuildResult struct {
	// 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.
	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

	// 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

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

func (l *Library) Load(target, tmpdir string) (path string, err error)

Load the library archive, possibly generating and caching it if needed. The resulting file is 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