Exemple #1
0
/* llmodule -> llmodule -> Mode.t -> unit */
CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src, value Mode) {
  char* Message;

  if (LLVMLinkModules(Dst, Src, Int_val(Mode), &Message))
    llvm_raise(*caml_named_value("Llvm_linker.Error"), Message);

  return Val_unit;
}
Exemple #2
0
/* llmodule -> llmodule -> Mode.t -> unit
   raises Error msg on error */
CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src, value Mode) {
  char* Message;

  if (LLVMLinkModules(Dst, Src, Int_val(Mode), &Message))
    llvm_raise(llvm_linker_error_exn, Message);

  return Val_unit;
}
Exemple #3
0
bool codegen_merge_runtime_bitcode(compile_t* c)
{
  strlist_t* search = package_paths();
  char path[FILENAME_MAX];
  LLVMModuleRef runtime = NULL;

  for(strlist_t* p = search; p != NULL && runtime == NULL; p = strlist_next(p))
  {
    path_cat(strlist_data(p), "libponyrt.bc", path);
    runtime = LLVMParseIRFileInContext(c->context, path);
  }

  errors_t* errors = c->opt->check.errors;

  if(runtime == NULL)
  {
    errorf(errors, NULL, "couldn't find libponyrt.bc");
    return false;
  }

  if(c->opt->verbosity >= VERBOSITY_MINIMAL)
    fprintf(stderr, "Merging runtime\n");

#if PONY_LLVM >= 308
  // runtime is freed by the function.
  if(LLVMLinkModules2(c->module, runtime))
  {
    errorf(errors, NULL, "libponyrt.bc contains errors");
    return false;
  }
#else
  if(LLVMLinkModules(c->module, runtime, LLVMLinkerDestroySource /* unused */,
    NULL))
  {
    errorf(errors, NULL, "libponyrt.bc contains errors");
    LLVMDisposeModule(runtime);
    return false;
  }
#endif

  return true;
}