Documentation ¶
Index ¶
- Constants
- Variables
- func CheckDefer(f func() error)
- func Compile(args []string, compiler string) (exitCode int)
- func Extract(args []string) (exitCode int)
- func FetchEnvironment()
- func GetCompilerExecName(compiler string) string
- func IsObjectFileForOS(objectFile string, operatingSys string) (ok bool, err error)
- func IsPlainFile(objectFile string) (ok bool)
- func PrintEnvironment()
- func ResetEnvironment()
- func SanityCheck()
- type BinaryType
- type ExtractionArgs
- type ParserResult
Constants ¶
const ( //ELFSectionName is the name of our ELF section of "bitcode paths". ELFSectionName = ".llvm_bc" //DarwinSegmentName is the name of our MACH-O segment of "bitcode paths". DarwinSegmentName = "__WLLVM" //DarwinSectionName is the name of our MACH-O section of "bitcode paths". DarwinSectionName = "__llvm_bc" )
Variables ¶
var LLVMARName string
LLVMARName is the user configured name of the llvm-ar.
var LLVMBitcodeStorePath string
LLVMBitcodeStorePath is the user configured location of the bitcode archive.
var LLVMCCName string
LLVMCCName is the user configured name of the clang compiler.
var LLVMCXXName string
LLVMCXXName is the user configured name of the clang++ compiler.
var LLVMConfigureOnly string
LLVMConfigureOnly is the user configured flag indicating a single pass mode is required.
var LLVMLINKName string
LLVMLINKName is the user configured name of the llvm-link.
var LLVMLd string
LLVMLd is the path to the ld executable used to attach the bitcode on OSX.
var LLVMLoggingFile string
LLVMLoggingFile is the path to the optional logfile (useful when configuring)
var LLVMLoggingLevel string
LLVMLoggingLevel is the user configured logging level: ERROR, WARNING, INFO, DEBUG.
var LLVMLtoLDFLAGS []string
LLVMLtoLDFLAGS is the list of extra flags to pass to the linking steps, when under -flto
var LLVMObjcopy string
LLVMObjcopy is the path to the objcopy executable used to attach the bitcode on *nix.
var LLVMToolChainBinDir string
LLVMToolChainBinDir is the user configured directory holding the LLVM binary tools.
var LLVMbcGen []string
LLVMbcGen is the list of args to pass to clang during the bitcode generation step.
var LogDebug = makeLogger(debugV)
LogDebug logs to the configured stream if the logging level is DEBUG.
var LogError = makeLogger(errorV)
LogError logs to the configured stream if the logging level is ERROR or lower.
var LogInfo = makeLogger(infoV)
LogInfo logs to the configured stream if the logging level is INFO or lower.
var LogWarning = makeLogger(warningV)
LogWarning logs to the configured stream if the logging level is WARNING or lower.
var LogWrite = makeLogger(-1)
LogWrite writes to the logging stream, irregardless of levels.
Functions ¶
func CheckDefer ¶
func CheckDefer(f func() error)
CheckDefer is used to check the return values of defers
func FetchEnvironment ¶ added in v1.2.6
func FetchEnvironment()
FetchEnvironment is used in initializing our globals, it is also used in testing
func GetCompilerExecName ¶
GetCompilerExecName returns the full path of the executable
func IsObjectFileForOS ¶ added in v1.2.9
IsObjectFileForOS returns true if the given file is an object file for the given OS, using the debug/elf and debug/macho packages.
func IsPlainFile ¶ added in v1.3.0
IsPlainFile returns true if the file is stat-able (i.e. exists etc), and is not a directory, else it returns false.
func PrintEnvironment ¶ added in v1.2.6
func PrintEnvironment()
PrintEnvironment is used for printing the aspects of the environment that concern us
func ResetEnvironment ¶ added in v1.2.6
func ResetEnvironment()
ResetEnvironment resets the globals, it is only used in testing
func SanityCheck ¶
func SanityCheck()
SanityCheck performs the environmental sanity check.
Performs the following checks in order: 0. Check the logging 1. Check that the OS is supported. 2. Checks that the compiler settings make sense. 3. Checks that the needed LLVM utilities exists. 4. Check that the store, if set, exists.
Types ¶
type BinaryType ¶ added in v1.2.9
type BinaryType uint32
BinaryType is the 'intersection' of elf.Type and macho.Type and partitions the binary world into categories we are most interested in. Missing is ARCHIVE but that is because it is not an elf format, so we cannot entirely eliminate the use of the 'file' utility (cf getFileType below).
const ( //BinaryUnknown signals that the file does not fit into our three simple minded categories BinaryUnknown BinaryType = 0 //BinaryObject is the type of an object file, the output unit of compilation BinaryObject BinaryType = 1 //BinaryExecutable is the type of an executable file BinaryExecutable BinaryType = 2 BinaryShared BinaryType = 3 )
func ElfFileType ¶ added in v1.2.9
func ElfFileType(objectFile string) (code BinaryType, err error)
ElfFileType returns the elf.Type of the given file name
func GetBinaryType ¶ added in v1.3.0
func GetBinaryType(path string) (bt BinaryType)
GetBinaryType gets the binary type of the given path
func MachoFileType ¶ added in v1.2.9
func MachoFileType(objectFile string) (code BinaryType, err error)
MachoFileType returns the macho.Type of the given file name
func (BinaryType) String ¶ added in v1.3.0
func (bt BinaryType) String() string
type ExtractionArgs ¶ added in v1.2.6
type ExtractionArgs struct { Failure bool // indicates failure in parsing the cmd line args Verbose bool // inform the user of what is going on WriteManifest bool // write a manifest of bitcode files used SortBitcodeFiles bool // sort the arguments to linking and archiving (debugging too) BuildBitcodeModule bool // buld an archive rather than a module KeepTemp bool // keep temporary linking folder StrictExtract bool // turn extraction failures into errors LinkArgSize int // maximum size of a llvm-link command line InputType int ObjectTypeInArchive int // Type of file that can be put into an archive InputFile string OutputFile string LlvmLinkerName string LlvmArchiverName string ArchiverName string ArArgs []string Extractor func(string) ([]string, bool) }
ExtractionArgs encapsulate the results of parsing the commandline options
func ParseSwitches ¶ added in v1.2.6
func ParseSwitches(args []string) (ea ExtractionArgs)
ParseSwitches parses the command line into an ExtractionArgs object.
func (ExtractionArgs) String ¶ added in v1.2.6
func (ea ExtractionArgs) String() string
for printing out the parsed arguments, some have been skipped.
type ParserResult ¶ added in v1.2.8
type ParserResult struct { InputList []string InputFiles []string ObjectFiles []string OutputFilename string CompileArgs []string LinkArgs []string ForbiddenFlags []string IsVerbose bool IsDependencyOnly bool IsPreprocessOnly bool IsAssembleOnly bool IsAssembly bool IsCompileOnly bool IsEmitLLVM bool IsLTO bool IsPrintOnly bool }
ParserResult is the result of parsing and partioning the command line arguments.
func Parse ¶ added in v1.2.8
func Parse(argList []string) ParserResult
Parse analyzes the command line aruguments and returns the result of that analysis.
func (*ParserResult) SkipBitcodeGeneration ¶ added in v1.2.8
func (pr *ParserResult) SkipBitcodeGeneration() bool
SkipBitcodeGeneration indicates whether or not we should generate bitcode for these command line options.
func (*ParserResult) String ¶ added in v1.2.8
func (pr *ParserResult) String() string