2014-10-31 09:19:03 +00:00
|
|
|
/*===-- linker_ocaml.c - LLVM OCaml Glue ------------------------*- C++ -*-===*\
|
2013-11-03 08:27:32 +00:00
|
|
|
|* *|
|
|
|
|
|* The LLVM Compiler Infrastructure *|
|
|
|
|
|* *|
|
|
|
|
|* This file is distributed under the University of Illinois Open Source *|
|
|
|
|
|* License. See LICENSE.TXT for details. *|
|
|
|
|
|* *|
|
|
|
|
|*===----------------------------------------------------------------------===*|
|
|
|
|
|* *|
|
|
|
|
|* This file glues LLVM's OCaml interface to its C interface. These functions *|
|
|
|
|
|* are by and large transparent wrappers to the corresponding C functions. *|
|
|
|
|
|* *|
|
|
|
|
|* Note that these functions intentionally take liberties with the CAMLparamX *|
|
|
|
|
|* macros, since most of the parameters are not GC heap objects. *|
|
|
|
|
|* *|
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
#include "llvm-c/Linker.h"
|
|
|
|
#include "caml/alloc.h"
|
|
|
|
#include "caml/memory.h"
|
|
|
|
#include "caml/fail.h"
|
2014-10-29 08:15:54 +00:00
|
|
|
#include "caml/callback.h"
|
2013-11-03 08:27:32 +00:00
|
|
|
|
2014-10-30 08:29:29 +00:00
|
|
|
void llvm_raise(value Prototype, char *Message);
|
2013-11-03 08:27:32 +00:00
|
|
|
|
2014-12-23 19:16:45 +00:00
|
|
|
/* llmodule -> llmodule -> unit */
|
|
|
|
CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src) {
|
2013-11-03 08:27:32 +00:00
|
|
|
char* Message;
|
|
|
|
|
2014-12-23 19:16:45 +00:00
|
|
|
if (LLVMLinkModules(Dst, Src, 0, &Message))
|
2014-10-29 08:15:54 +00:00
|
|
|
llvm_raise(*caml_named_value("Llvm_linker.Error"), Message);
|
2013-11-03 08:27:32 +00:00
|
|
|
|
|
|
|
return Val_unit;
|
|
|
|
}
|