Binding against LLVM 3.8.4 no getGlobalContext

廉价感情. 提交于 2020-01-03 09:00:16

问题


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


回答1:


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;



回答2:


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);


来源:https://stackoverflow.com/questions/38579802/binding-against-llvm-3-8-4-no-getglobalcontext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!