| From: | Greg Burd <greg(at)burd(dot)me> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Cc: | Henson Choi <assam258(at)gmail(dot)com>, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Andres Freund <andres(at)anarazel(dot)de>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
| Subject: | configure picks a clang that doesn't match LLVM_CONFIG |
| Date: | 2026-10-30 13:25:34 |
| Message-ID: | auSY2R_CXuj0L-I3@floki |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello again hackers,
I've been toying with LLVM-related code recently while I finished up
a new extension [1] that also uses the LLVM. That led me to this
finding.
configure finds clang only through PATH, independently of the LLVM
installation chosen with LLVM_CONFIG. On Debian 13, which ships LLVM 19
by default with 21 in trixie-backports, this goes wrong in both
directions:
* LLVM_CONFIG=llvm-config-21, unversioned clang on PATH is clang-19:
configure succeeds, bitcode comes from clang-19, llvmjit.so links
LLVM 21. That combination happens to work.
* LLVM_CONFIG=llvm-config-19, clang on PATH is clang-21: configure
succeeds, and every JIT compilation then ends the backend:
error: Unknown attribute kind (102) (Producer: 'LLVM21.1.8' Reader: 'LLVM 19.1.7')
(That's LLVM's default diagnostic handler calling exit(1) while
reading llvmjit_types.bc, so it shows up as a backend exiting with
status 1 rather than a crash.)
* LLVM_CONFIG=llvm-config-21 and no unversioned clang on PATH:
configure fails, although /usr/lib/llvm-21/bin/clang is right there.
The meson build has always used the clang from llvm-config --bindir,
falling back to PATH. The attached patch makes configure do the same,
in the order Andres suggested in [1]: an explicit CLANG wins, then the
clang in llvm-config --bindir, then PATH. An explicit CLANG is still
the way to use a faster clang when building against an assertion-enabled
LLVM, which was Andres's concern about always using the bundled one.
Tested on Debian 13 with all three cases above, plus an explicit
CLANG="ccache clang-19", which is kept as given.
Since this changes which compiler configure picks, I haven't marked it
for backpatching; it applies to 17 through 19 if a committer thinks it
should go back.
This has come up before ([2], Heikki in 2018, and in [3]), and Jelte hit
the same mismatch more recently while testing typeof_unqual.
best.
-greg
[1] https://codeberg.org/gregburd/pg_pure
[2] https://postgr.es/m/2eda6b0f-cf08-b847-c33a-cb0e746d21ef%40iki.fi
[3] https://postgr.es/m/C5C97974-FB47-45AF-9DD3-30969302866A%40anarazel.de
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0002-jit-Prefer-clang-from-llvm-config-bindir-in-confi.patch | text/plain | 4.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2026-10-30 13:26:56 | Re: PL/pgSQL: apply the too_many_rows extra check to EXECUTE ... INTO |
| Previous Message | Greg Burd | 2026-10-30 13:16:49 | Re: LLVM JIT: any JIT-compiled query crashes (SIGILL) on a libLLVM 19 + ASAN build |