Re: JIT compiling with LLVM v11 - Mailing list pgsql-hackers

From Andres Freund
Subject Re: JIT compiling with LLVM v11
Date
Msg-id 20180305201729.cttrgtw5a3iyezhf@alap3.anarazel.de
Whole thread Raw
In response to Re: JIT compiling with LLVM v11  (Andres Freund <andres@anarazel.de>)
Responses Re: JIT compiling with LLVM v11  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Re: JIT compiling with LLVM v11  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hi,

On 2018-03-04 21:00:06 -0800, Andres Freund wrote:
> > Looking at llvm_get_function(), the function that raises that error, I
> > see that there are a few different paths here.  I don't have
> > HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN defined, and I don't have LLVM <
> > 5, so I should be getting the symbol address with
> > LLVMOrcGetSymbolAddress(llvm_opt0_orc, &addr, mangled) or
> > LLVMOrcGetSymbolAddress(llvm_opt3_orc, &addr, mangled), but clearly
> > those are returning NULL.
> 
> Yep. I wonder if this is some symbol naming issue or such, because
> emitting and relocating the object worked without an error.

Thanks to Thomas helping get access to an OSX machine I was able to
discover what the issue is.  OSX prepends, for reason unbeknownst to me,
a leading underscore to all function names.  That lead to two issues:
First JITed functions do not have that underscore (making us look up a
non-existing symbol, because llvm_get_function applied
mangling). Secondly, llvm_resolve_symbol failed looking up symbol names,
because for $reason dlsym() etc do *not* have the names prefixed by the
underscore.   Easily enough fixed.

After that I discovered another problem, the bitcode files for core pg /
contrib modules weren't installed. That turned out to be a make version
issue, I'd used
define install_llvm_module =
# body
but older make only like
define install_llvm_module
# body

Writing up a patch that I can actually push.  Thanks both to Thomas and
Peter for pointing me towards this issue!

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: select_parallel test failure: gather sometimes losing tuples(maybe during rescans)?
Next
From: Satyanarayana Narlapuram
Date:
Subject: RE: [HACKERS] Client Connection redirection support for PostgreSQL