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>
Subject: LLVM JITLink attempt II (WIP)
Date: 2025-09-18 05:05:47
Message-ID: CA+hUKGJBJx4fDGLv8zUtmsmg16Swry7DJbMr2_GNZcd6sgE0rg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

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.

While rebasing, I made it use JITLink for LLVM >= 19, but that's
arbitrary. Tested on FreeBSD/amd64 + LLVM 19, 20, 21. I haven't
tried other architectures or 32 bit, and support is clearly moving at
very different speeds with 32 bit support far behind. There is a
published table[1], but it may already be out of date and doesn't talk
about releases. Ideally I guess we'd put this change off as long as
possible and then cut over everywhere with a simple version threshold
just as RuntimeDyld is finally removed (which hopefully requires full
feature parity to happen first!), but the reality might be messier:
RISC-V doesn't work with RuntimeDyld[2] and it's reasonable to want
that to work sooner, and it might also be nice to drop the ugly ARM
workaround from commit 9044fc1d as soon as LLVM < 15 falls off our
radar.

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...

[1] https://llvm.org/docs/JITLink.html (bottom of page)
[2] https://www.postgresql.org/message-id/flat/20220829074622.2474104-1-alex.fan.q%40gmail.com

Attachment Content-Type Size
v1-0001-jit-Add-optional-LLVM-JITLink-support.patch application/octet-stream 6.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-09-18 05:07:36 Re: [WIP]Vertical Clustered Index (columnar store extension) - take2
Previous Message Corey Huinker 2025-09-18 05:02:17 Re: someone else to do the list of acknowledgments