8

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

Community
  • 1
  • 1
Mobius
  • 2,871
  • 1
  • 19
  • 29

2 Answers2

6

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;
Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
nak1114
  • 61
  • 1
  • 2
4

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);
Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
sergey
  • 152
  • 5
  • Thanks. I should mention that I was able to solve my issue by just building the latest zips from source (version 3.8.something), but this is good information as well. – Mobius Aug 09 '16 at 18:22