Re: JIT compiling with LLVM v10.0

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: JIT compiling with LLVM v10.0
Date: 2018-02-07 22:50:17
Message-ID: CAEepm=0+hm_cUx3ioY0tLDT1Liu-zNwaDxLGWj=9H+9=zYKGwA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 8, 2018 at 3:54 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> I've pushed v10.0. The big (and pretty painful to make) change is that
> now all the LLVM specific code lives in src/backend/jit/llvm, which is
> built as a shared library which is loaded on demand.
>
> The layout is now as follows:
>
> src/backend/jit/jit.c:
> Part of JITing always linked into the server. Supports loading the
> LLVM using JIT library.
>
> src/backend/jit/llvm/
> Infrastructure:
> llvmjit.c:
> General code generation and optimization infrastructure
> llvmjit_error.cpp, llvmjit_wrap.cpp:
> Error / backward compat wrappers
> llvmjit_inline.cpp:
> Cross module inlining support
> Code-Gen:
> llvmjit_expr.c
> Expression compilation
> llvmjit_deform.c
> Deform compilation

You are asking LLVM to dlopen(""), which doesn't work on my not-Linux,
explaining the errors I reported in the older thread. The portable
way to dlopen the main binary is dlopen(NULL), so I think you need to
pass NULL in to LLVMLoadLibraryPermanently(), even though that isn't
really clear from any LLVM documentation I've looked at.

diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index a1bc6449f7..874bddf81e 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -443,7 +443,7 @@ llvm_session_initialize(void)
cpu = NULL;

/* force symbols in main binary to be loaded */
- LLVMLoadLibraryPermanently("");
+ LLVMLoadLibraryPermanently(NULL);

llvm_opt0_orc = LLVMOrcCreateInstance(llvm_opt0_targetmachine);
llvm_opt3_orc = LLVMOrcCreateInstance(llvm_opt3_targetmachine);

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-02-07 22:52:09 Re: PDF Builds on borka (Debian/stretch) broken - 9.6
Previous Message Rafal Pietrak 2018-02-07 22:41:16 it's a feature, but it feels like a bug