Fix LLVMLinkModules for LLVM-3.1

This commit is contained in:
Siu Kwan Lam 2013-01-17 18:59:20 -06:00
commit 206d512c10
3 changed files with 14 additions and 21 deletions

View file

@ -278,8 +278,8 @@ _wLLVMLinkModules(PyObject *self, PyObject *args)
const LLVMModuleRef dest = pycap_get<LLVMModuleRef>(dest_obj ) ;
const LLVMModuleRef src = pycap_get<LLVMModuleRef>(src_obj) ;
PyObject *ret;
char *errmsg;
PyObject *ret = NULL;
char *errmsg = NULL;
if (LLVMLinkModules(dest, src, (LLVMLinkerMode)mode, &errmsg)) {
if (errmsg) {
ret = PyUnicode_FromString(errmsg);

View file

@ -1191,21 +1191,15 @@ LLVMModuleRef LLVMGetModuleFromBitcode(const char *bitcode, unsigned bclen,
}
#if LLVM_VERSION_MAJOR <= 3 && LLVM_VERSION_MINOR < 2
unsigned LLVMLinkModules(LLVMModuleRef dest, LLVMModuleRef src, unsigned int mode,
char **out)
{
llvm::Module *sourcep = llvm::unwrap(src);
assert(sourcep);
llvm::Module *destinationp = llvm::unwrap(dest);
assert(destinationp);
std::string msg;
if (llvm::Linker::LinkModules(destinationp, sourcep, mode, &msg)) {
*out = strdup(msg.c_str());
return 0;
}
return 1;
// Shamelessly copy from LLVM-3.2
unsigned LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
int Mode, char **OutMessages) {
std::string Messages;
unsigned Result = Linker::LinkModules(unwrap(Dest), unwrap(Src), Mode,
OutMessages? &Messages : 0);
if (OutMessages)
*OutMessages = strdup(Messages.c_str());
return Result;
}
#endif

View file

@ -46,10 +46,9 @@
#endif
#include "llvm-c/Transforms/PassManagerBuilder.h"
#include "llvm_c_extra.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -578,8 +577,8 @@ LLVMModuleRef LLVMGetModuleFromBitcode(const char *bc, unsigned bclen,
/* Wraps llvm::Linker::LinkModules(). Returns 0 on failure (with errmsg
* filled in) and 1 on success. Dispose error message after use with
* LLVMDisposeMessage(). */
unsigned LLVMLinkModules(LLVMModuleRef dest, LLVMModuleRef src,
unsigned int, char **errmsg);
unsigned LLVMLinkModules(LLVMModuleRef dest, LLVMModuleRef src, int mode,
char **errmsg);
#endif
/* Returns pointer to a heap-allocated block of `*len' bytes containing bit code
* for the given module. NULL on error. */