1 //===- support.go - Bindings for support ----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines bindings for the support component.
12 //===----------------------------------------------------------------------===//
17 #include "llvm-c/Support.h"
18 #include "SupportBindings.h"
28 // Loads a dynamic library such that it may be used as an LLVM plugin.
29 // See llvm::sys::DynamicLibrary::LoadLibraryPermanently.
30 func LoadLibraryPermanently(lib string) error {
32 libstr := C.CString(lib)
33 defer C.free(unsafe.Pointer(libstr))
34 C.LLVMLoadLibraryPermanently2(libstr, &errstr)
36 err := errors.New(C.GoString(errstr))
37 C.free(unsafe.Pointer(errstr))
43 // Parse the given arguments using the LLVM command line parser.
44 // See llvm::cl::ParseCommandLineOptions.
45 func ParseCommandLineOptions(args []string, overview string) {
46 argstrs := make([]*C.char, len(args))
47 for i, arg := range args {
48 argstrs[i] = C.CString(arg)
49 defer C.free(unsafe.Pointer(argstrs[i]))
51 overviewstr := C.CString(overview)
52 defer C.free(unsafe.Pointer(overviewstr))
53 C.LLVMParseCommandLineOptions(C.int(len(args)), &argstrs[0], overviewstr)