Re: [PATCH] jit: fix build with LLVM-21

Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>

From: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Holger Hoffstätte <holger@applied-asynchrony.com>, pgsql-hackers@postgresql.org
Date: 2025-09-18T07:44:28Z
Lists: pgsql-hackers
Hi,

I've tested the patch: it fixes the compilation on arm and I'm
correctly linked to llvm21:

ldd /var/lib/postgresql/.local/lib/llvmjit.so | grep libLLVM
        libLLVM.so.21.1 => /lib/aarch64-linux-gnu/libLLVM.so.21.1
(0x0000ec34112d0000)

Testing the query that used to trigger the jit segfault, the llvm
backport is working as expected.

pgbench -i --partitions=256
psql options=-cjit_above_cost=0 -c 'SELECT count(bid) from pgbench_accounts;'
 count
--------
 100000

As a comparison, if I forcefully disable
USE_LLVM_BACKPORT_SECTION_MEMORY_MANAGER, I have the expected crash as
the issue is still present in LLVM (the fix would be to switch to
JITLink).

psql options=-cjit_above_cost=0 -c 'SELECT count(bid) from pgbench_accounts;'
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
connection to server was lost