[llvm-dev] ORC v2 question

Dibyendu Majumdar via llvm-dev
Fri, 16 Aug 2019 20:39:47 -0000

Hi Lang,

> On Wed, 14 Aug 2019 at 21:53, Dibyendu Majumdar <mobile at
majumdar.org.uk> wrote:
> > > There are two ways you could tackle this:
> > > (1) Write your own generator that calls
sys::DynamicLibrary::SearchforAddressOfSymbol, or
> > > (2) Add the symbols up-front using the absoluteSymbols function.
> > >
> > > I would be inclined to do the latter: it's more explicit, and
easier to limit searches to exactly the symbols you want.
> > >
> >
> > Okay I will look into this. Thank you for all the help.
> >
>
> Looks the documented approach in http://llvm.org/docs/ORCv2.html
> doesn't work in LLVM 8.
>

Here is what I am ended up doing.

  auto &JD = ES->getMainJITDylib();
  llvm::orc::MangleAndInterner mangle(*ES, *this->DL);
  llvm::orc::SymbolMap Symbols;
  for (int i = 0; global_syms[i].name != nullptr; i++) {
    Symbols.insert( { mangle(global_syms[i].name),

llvm::JITEvaluatedSymbol(llvm::pointerToJITTargetAddress(global_syms[i].address),

llvm::JITSymbolFlags(llvm::JITSymbolFlags::FlagNames::Exported)) });
  }
  llvm::cantFail(JD.define(llvm::orc::absoluteSymbols(Symbols)),
"Failed to install extern symbols");


global_symbols is an array with name and function address.
Works on Linux but not on Windows. So I must be missing something else?

Thanks and Regards
Dibyendu