Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding against LLVM 3.8.4 no getGlobalContext

I am attempting to follow the https://github.com/lsegal/my_toy_compiler, but even though it has been updated for LLVM 3.8.0, I am unable to get it to compile using LLVM 3.8.4 from brew with --with-clang --with-lld --with-jit --with-python. Specifically I get the following error, use of undeclared identifier 'getGlobalContext'.

Additionally the symbol getGlobalContext does not appear in the /usr/local/opt/llvm/include/llvm/IR/LLVMContext.h or indeed anywhere in the /usr/local/opt/llvm/include directory.

I expect that either this function has been deprecated recently, (for which I have not been able to find any evidence), or that I am not building it correctly.

Any tips would be appreciated.

NOTE I have seen Trouble linking against LLVM with project including Flex and Bison and it did not resolve my particular problem

like image 447
Mobius Avatar asked Jul 26 '16 01:07

Mobius


2 Answers

I also encountered the same problem with llvm 4.0. My solution is as follows.

old:

LLVMContext *llvmcx;
llvmcx = &getGlobalContext();

new:

LLVMContext *llvmcx;
static LLVMContext MyGlobalContext;
llvmcx = &MyGlobalContext;
like image 185
nak1114 Avatar answered Nov 16 '22 15:11

nak1114


I have the same problem with 4.0.0 version built from svn. I've found the following commit 266379 with the removing all occurrences of getGlobalConfig()

https://reviews.llvm.org/rL266379

This commit changes examples either defining internal context variable:
Was:

static IRBuilder<> Builder(getGlobalContext());

Become:

static LLVMContext TheContext;
static IRBuilder<> Builder(TheContext);
like image 36
sergey Avatar answered Nov 16 '22 15:11

sergey