Re: LLVM JITLink attempt II (WIP)

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Gregory Burd <greg(at)burd(dot)me>, Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Subject: Re: LLVM JITLink attempt II (WIP)
Date: 2026-01-03 03:09:47
Message-ID: CA+hUKGKu8mm0uHw1gMhm2wnYZg6=EZi-2v4gGiKT7An6x4HKug@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 18, 2025 at 5:05 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> Here's a short unfinished but semi-working patch to try out JITLink
> instead of RuntimeDyld, since Greg expressed an interest in it. I'm
> not actively working on this myself right now, but in case it helps, I
> think the main things to do next are probably: try out the recently
> added debugger and perf plugins (I hope these are the equivalents of
> the JITEventListener stuff we use), figure out how and when we can
> actually cut over, tidy/refactor and possibly consider upstreaming
> some C wrappers if we want to minimise the C++ glue we carry. See
> patch for a few more details.

LLVMOrcCreateObjectLinkingLayerWithInProcessMemoryManager() has been
upstreamed into LLVM 22[1], so this patch became shorter.

We could optionally photocopy that function into our llvm_wrap.cpp
file if we have a need to use JITLink with older LLVM versions. The
motivations for that might be that it is needed for RISC-V and we want
that to work on current Debian et al without waiting ages, or that we
want to kill off our llvm::backport::SectionMemoryManager sooner
without having to wait for LLVM 22 (which has finally fixed the
underlying problem[2]) to be our minimum version. Someone said this
is also needed for Windows, and I read somewhere that Visual Studio
ships a copy of LLVM these days and it could be a few releases behind,
so that might also provide a motivation, IDK.

I still don't know how to enable GDB and Perf support with JITLink...

> With LLVM 22 (bleeding edge main branch) it builds and runs simple
> things, but I get a SIGBUS crash in the regression tests even on
> unpatched master, something to look into separately...

That turned out to be not our bug, and has been fixed.

[1] https://github.com/llvm/llvm-project/commit/2222cfe7e11ff3e0434bc696856629199ef0da7c
[2] https://www.postgresql.org/message-id/flat/CA%2BhUKGJTumad75o8Zao-LFseEbt%3DenbUFCM7LZVV%3Dc8yg2i7dg%40mail.gmail.com

Attachment Content-Type Size
v2-0001-jit-Use-JITLink-for-LLVM-22.patch text/x-patch 2.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2026-01-03 03:12:39 Re: Speed up ICU case conversion by using ucasemap_utf8To*()
Previous Message zengman 2026-01-03 03:05:24 Re: Speed up ICU case conversion by using ucasemap_utf8To*()