Re: JIT compiling with LLVM v11

From: Andres Freund <andres(at)anarazel(dot)de>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Pierre Ducroquet <p(dot)psql(at)pinaraf(dot)info>
Subject: Re: JIT compiling with LLVM v11
Date: 2018-03-05 20:17:30
Message-ID: 20180305201729.cttrgtw5a3iyezhf@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Satyanarayana Narlapuram 2018-03-05 20:18:38 RE: [HACKERS] Client Connection redirection support for PostgreSQL
Previous Message Robert Haas 2018-03-05 20:17:16 Re: select_parallel test failure: gather sometimes losing tuples (maybe during rescans)?