compiler

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: BSD-3-Clause Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTargetMachine added in v0.13.0

func NewTargetMachine(config *compileopts.Config) (llvm.TargetMachine, error)

NewTargetMachine returns a new llvm.TargetMachine based on the passed-in configuration. It is used by the compiler and is needed for machine code emission.

Types

type CompilerOutput added in v0.15.0

type CompilerOutput struct {
	// The LLVM module that contains the compiled but not optimized LLVM module
	// for all the Go code in the program.
	Mod llvm.Module

	// ExtraFiles is a list of C source files included in packages that should
	// be built and linked together with the main executable to form one
	// program. They can be used from CGo, for example.
	ExtraFiles []string

	// ExtraLDFlags are linker flags obtained during CGo processing. These flags
	// must be passed to the linker which links the entire executable.
	ExtraLDFlags []string

	// MainDir is the absolute directory path to the directory of the main
	// package. This is useful for testing: tests must be run in the package
	// directory that is being tested.
	MainDir string
}

CompilerOutput is returned from the Compile() call. It contains the compile output and information necessary to continue to compile and link the program.

func Compile added in v0.13.0

func Compile(pkgName string, machine llvm.TargetMachine, config *compileopts.Config) (output CompilerOutput, errors []error)

Compile the given package path or .go file path. Return an error when this fails (in any stage). If successful it returns the LLVM module and a list of extra C files to be compiled. If not, one or more errors will be returned.

The fact that it returns a list of filenames to compile is a layering violation. Eventually, this Compile function should only compile a single package and not the whole program, and loading of the program (including CGo processing) should be moved outside the compiler package.

Directories

Path Synopsis
Package ircheck implements a checker for LLVM IR, that goes a bit further than the regular LLVM IR verifier.
Package ircheck implements a checker for LLVM IR, that goes a bit further than the regular LLVM IR verifier.
Package llvmutil contains utility functions used across multiple compiler packages.
Package llvmutil contains utility functions used across multiple compiler packages.

Jump to

Keyboard shortcuts

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