JIT works only partially with meson build?

Started by Yugo Nagataover 1 year ago10 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliessuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t51635
psql -h localhost -U postgres

Built from patchset v9 (message #9), September 20, 2026 at 12:17 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t51635_9 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t51635_9 && git checkout t51635_9

Patchset v9 (message #9) is on t51635_9

Jump to latest
#1Yugo Nagata
nagata@sraoss.co.jp

Hi,

While building PostgreSQL 17 on Windows, I noticed bitcode files (.bc) are not
generated with meson. Does this means that "inlining" of JIT doesn't
work when PostgreSQL is build with meson?

If so, is it better to describe that in the meson build and JIT sections in the
documentation so that users and packagers would except JIT doesn't work in the same
way when built with meson and autoconf/make?

Regards,
Yugo Nagata

--
Yugo Nagata <nagata@sraoss.co.jp>

#2David Rowley
dgrowleyml@gmail.com
In reply to: Yugo Nagata (#1)
Re: JIT works only partially with meson build?

On Mon, 26 May 2025 at 18:08, Yugo Nagata <nagata@sraoss.co.jp> wrote:

While building PostgreSQL 17 on Windows, I noticed bitcode files (.bc) are not
generated with meson. Does this means that "inlining" of JIT doesn't
work when PostgreSQL is build with meson?

Yes. I believe [1]https://commitfest.postgresql.org/patch/5671/ aims to fix this.

David

[1]: https://commitfest.postgresql.org/patch/5671/

#3Yugo Nagata
nagata@sraoss.co.jp
In reply to: David Rowley (#2)
Re: JIT works only partially with meson build?

On Mon, 26 May 2025 19:17:53 +1200
David Rowley <dgrowleyml@gmail.com> wrote:

On Mon, 26 May 2025 at 18:08, Yugo Nagata <nagata@sraoss.co.jp> wrote:

While building PostgreSQL 17 on Windows, I noticed bitcode files (.bc) are not
generated with meson. Does this means that "inlining" of JIT doesn't
work when PostgreSQL is build with meson?

Yes. I believe [1] aims to fix this.

David

[1] https://commitfest.postgresql.org/patch/5671/

Thank you for the clarification.

I've attached a patch to update the documentation.
I believe it's worth stating this explicitly, since the fix will not be
applied until at the earliest PostgreSQL 19.

Regards,
Yugo Nagata

--
Yugo Nagata <nagata@sraoss.co.jp>

Attachments:

fix_doc_jit_meson.patchtext/x-diff; name=fix_doc_jit_meson.patchDownload+11-1
#4Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Yugo Nagata (#3)
Re: JIT works only partially with meson build?

On Fri, 2025-06-27 at 16:19 +0900, Yugo Nagata wrote:

On Mon, 26 May 2025 19:17:53 +1200
David Rowley <dgrowleyml@gmail.com> wrote:

On Mon, 26 May 2025 at 18:08, Yugo Nagata <nagata@sraoss.co.jp> wrote:

While building PostgreSQL 17 on Windows, I noticed bitcode files (.bc) are not
generated with meson. Does this means that "inlining" of JIT doesn't
work when PostgreSQL is build with meson?

Yes. I believe [1] aims to fix this.

[1] https://commitfest.postgresql.org/patch/5671/

Thank you for the clarification.

I've attached a patch to update the documentation.
I believe it's worth stating this explicitly, since the fix will not be
applied until at the earliest PostgreSQL 19.

I think that it is a good idea to document this lack of functionality.

One thing stood out to me:

--- a/doc/src/sgml/jit.sgml
+++ b/doc/src/sgml/jit.sgml
@@ -36,7 +36,8 @@
<acronym>JIT</acronym> compilation using <ulink
url="https://llvm.org/"><productname>LLVM</productname></ulink> when
<productname>PostgreSQL</productname> is built with
-   <link linkend="configure-with-llvm"><literal>--with-llvm</literal></link>.
+   <link linkend="configure-with-llvm"><literal>--with-llvm</literal></link>
+   or <link linkend="configure-with-llvm-meson"><option>-Dllvm</option></link>.

You used the <option> tag, which I believe is correct, but the surrounding
code uses <literal>. I don't think it renders differently, but I think it
would be good to use the same tag. I suggest that you change the
surrounding code to use <option> as well.

v18 is already shipped, and we don't know if the patch to produce bitcode
with Meson will make v19 or not. Consequently, I don't know if we should
apply the patch to git HEAD yet. But I believe that it should be
backpatched to all older releases, since this is a shortcoming in the
documentation.

Yours,
Laurenz Albe

#5Yugo Nagata
nagata@sraoss.co.jp
In reply to: Laurenz Albe (#4)
Re: JIT works only partially with meson build?

On Tue, 30 Sep 2025 14:04:13 +0200
Laurenz Albe <laurenz.albe@cybertec.at> wrote:

On Fri, 2025-06-27 at 16:19 +0900, Yugo Nagata wrote:

On Mon, 26 May 2025 19:17:53 +1200
David Rowley <dgrowleyml@gmail.com> wrote:

On Mon, 26 May 2025 at 18:08, Yugo Nagata <nagata@sraoss.co.jp> wrote:

While building PostgreSQL 17 on Windows, I noticed bitcode files (.bc) are not
generated with meson. Does this means that "inlining" of JIT doesn't
work when PostgreSQL is build with meson?

Yes. I believe [1] aims to fix this.

[1] https://commitfest.postgresql.org/patch/5671/

Thank you for the clarification.

I've attached a patch to update the documentation.
I believe it's worth stating this explicitly, since the fix will not be
applied until at the earliest PostgreSQL 19.

I think that it is a good idea to document this lack of functionality.

Thank you for taking a look at it.

One thing stood out to me:

--- a/doc/src/sgml/jit.sgml
+++ b/doc/src/sgml/jit.sgml
@@ -36,7 +36,8 @@
<acronym>JIT</acronym> compilation using <ulink
url="https://llvm.org/"><productname>LLVM</productname></ulink> when
<productname>PostgreSQL</productname> is built with
-   <link linkend="configure-with-llvm"><literal>--with-llvm</literal></link>.
+   <link linkend="configure-with-llvm"><literal>--with-llvm</literal></link>
+   or <link linkend="configure-with-llvm-meson"><option>-Dllvm</option></link>.

You used the <option> tag, which I believe is correct, but the surrounding
code uses <literal>. I don't think it renders differently, but I think it
would be good to use the same tag. I suggest that you change the
surrounding code to use <option> as well.

Agreed. I fixed it to use <option>, as well as in other place where I think
<option> is appropriate. Please find the attached patch.

v18 is already shipped, and we don't know if the patch to produce bitcode
with Meson will make v19 or not. Consequently, I don't know if we should
apply the patch to git HEAD yet. But I believe that it should be
backpatched to all older releases, since this is a shortcoming in the
documentation.

+1.

Regards,
Yugo Nagata

--
Yugo Nagata <nagata@sraoss.co.jp>

Attachments:

t51635_5
v2_fix_doc_jit_meson.patchtext/x-diff; name=v2_fix_doc_jit_meson.patchDownload+12-2
#6Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Yugo Nagata (#5)
Re: JIT works only partially with meson build?

On Tue, 2025-09-30 at 22:31 +0900, Yugo Nagata wrote:

You used the <option> tag, which I believe is correct, but the surrounding
code uses <literal>. I don't think it renders differently, but I think it
would be good to use the same tag. I suggest that you change the
surrounding code to use <option> as well.

Agreed. I fixed it to use <option>, as well as in other place where I think
<option> is appropriate. Please find the attached patch.

I'll mark it "eeady for committer". A committer can decide whether to apply
this to HEAD or not. I probably would, and revert it if PostgreSQL + Meson +
Windows learns to produce bitcode.

Yours,
Laurenz Albe

#7Yugo Nagata
nagata@sraoss.co.jp
In reply to: Laurenz Albe (#6)
Re: JIT works only partially with meson build?

On Wed, 01 Oct 2025 15:25:51 +0200
Laurenz Albe <laurenz.albe@cybertec.at> wrote:

On Tue, 2025-09-30 at 22:31 +0900, Yugo Nagata wrote:

You used the <option> tag, which I believe is correct, but the surrounding
code uses <literal>. I don't think it renders differently, but I think it
would be good to use the same tag. I suggest that you change the
surrounding code to use <option> as well.

Agreed. I fixed it to use <option>, as well as in other place where I think
<option> is appropriate. Please find the attached patch.

I'm just resending the same patch because CommitFest reports that it needs a
rebase, although it still applies cleanly.

Regards,
Yugo Nagata

I'll mark it "eeady for committer". A committer can decide whether to apply
this to HEAD or not. I probably would, and revert it if PostgreSQL + Meson +
Windows learns to produce bitcode.

Yours,
Laurenz Albe

--
Yugo Nagata <nagata@sraoss.co.jp>

Attachments:

t51635_7
v2_fix_doc_jit_meson.patchtext/x-diff; name=v2_fix_doc_jit_meson.patchDownload+12-2
#8shihao zhong
zhong950419@gmail.com
In reply to: Yugo Nagata (#7)
Re: JIT works only partially with meson build?

Hi Yugo,

cfbot fails because v2 is a plain diff, and git am cannot apply it.
Attached v3 is the same change made with git format-patch, plus a
commit message. It applies to master and REL_16_STABLE through
REL_19_STABLE.

One suggestion: EXPLAIN still shows "Inlining: true" in this case,
since it only checks PGJIT_INLINE. Maybe the note should say so.

Regards,
Shihao

Attachments:

t51635_8
v3_fix_doc_jit_meson.patchapplication/octet-stream; name=v3_fix_doc_jit_meson.patchDownload+12-4
#9Yugo Nagata
nagata@sraoss.co.jp
In reply to: shihao zhong (#8)
Re: JIT works only partially with meson build?

Hi Shihao,

On Thu, 17 Sep 2026 22:13:02 -0400
shihao zhong <zhong950419@gmail.com> wrote:

Hi Yugo,

cfbot fails because v2 is a plain diff, and git am cannot apply it.
Attached v3 is the same change made with git format-patch, plus a
commit message. It applies to master and REL_16_STABLE through
REL_19_STABLE.

One suggestion: EXPLAIN still shows "Inlining: true" in this case,
since it only checks PGJIT_INLINE. Maybe the note should say so.

Thak you for updating the patch.
I've attached an updated path incorporating your suggestion.

Regards,]
Yugo Nagata

--
Yugo Nagata <nagata@sraoss.co.jp>

Attachments:

t51635_9
v4-0001-doc-Mention-that-JIT-inlining-does-not-work-with-.patchtext/x-diff; name=v4-0001-doc-Mention-that-JIT-inlining-does-not-work-with-.patchDownload+13-4
#10Yugo Nagata
nagata@sraoss.co.jp
In reply to: Yugo Nagata (#9)
Re: JIT works only partially with meson build?

On Fri, 18 Sep 2026 21:00:20 +0900
Yugo Nagata <nagata@sraoss.co.jp> wrote:

Hi Shihao,

On Thu, 17 Sep 2026 22:13:02 -0400
shihao zhong <zhong950419@gmail.com> wrote:

Hi Yugo,

cfbot fails because v2 is a plain diff, and git am cannot apply it.
Attached v3 is the same change made with git format-patch, plus a
commit message. It applies to master and REL_16_STABLE through
REL_19_STABLE.

One suggestion: EXPLAIN still shows "Inlining: true" in this case,
since it only checks PGJIT_INLINE. Maybe the note should say so.

Thak you for updating the patch.
I've attached an updated path incorporating your suggestion.

It may be unnecessary once the LLVM bitcode emission patches [1]/messages/by-id/CAN55FZ26ohMftt20NUtVAxU8Feqjhz-jEfUvFKATYEaRR+xmqg@mail.gmail.com are
committed, though.

[1]: /messages/by-id/CAN55FZ26ohMftt20NUtVAxU8Feqjhz-jEfUvFKATYEaRR+xmqg@mail.gmail.com

Regards,
Yugo Nagata

--
Yugo Nagata <nagata@sraoss.co.jp>