On Thu, Sep 18, 2025 at 5:05 PM Thomas Munro <thomas.munro@gmail.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