1 //===- support.go - Bindings for support ----------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines bindings for the support component.
11 //===----------------------------------------------------------------------===//
16 #include "llvm-c/Support.h"
17 #include "SupportBindings.h"
27 // Loads a dynamic library such that it may be used as an LLVM plugin.
28 // See llvm::sys::DynamicLibrary::LoadLibraryPermanently.
29 func LoadLibraryPermanently(lib
string) error
{
31 libstr
:= C
.CString(lib
)
32 defer C
.free(unsafe
.Pointer(libstr
))
33 C
.LLVMLoadLibraryPermanently2(libstr
, &errstr
)
35 err
:= errors
.New(C
.GoString(errstr
))
36 C
.free(unsafe
.Pointer(errstr
))
42 // Parse the given arguments using the LLVM command line parser.
43 // See llvm::cl::ParseCommandLineOptions.
44 func ParseCommandLineOptions(args
[]string, overview
string) {
45 argstrs
:= make([]*C
.char
, len(args
))
46 for i
, arg
:= range args
{
47 argstrs
[i
] = C
.CString(arg
)
48 defer C
.free(unsafe
.Pointer(argstrs
[i
]))
50 overviewstr
:= C
.CString(overview
)
51 defer C
.free(unsafe
.Pointer(overviewstr
))
52 C
.LLVMParseCommandLineOptions(C
.int(len(args
)), &argstrs
[0], overviewstr
)