1//===- linker.go - Bindings for linker ------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines bindings for the linker component.
11//
12//===----------------------------------------------------------------------===//
13
14package llvm
15
16/*
17#include "llvm-c/Linker.h"
18#include <stdlib.h>
19*/
20import "C"
21import "errors"
22
23func LinkModules(Dest, Src Module) error {
24	var cmsg *C.char
25	failed := C.LLVMLinkModules(Dest.C, Src.C, C.LLVMLinkerDestroySource, &cmsg)
26	if failed != 0 {
27		err := errors.New(C.GoString(cmsg))
28		C.LLVMDisposeMessage(cmsg)
29		return err
30	}
31	return nil
32}
33