Re: meson vs. llvm bitcode files

From: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: meson vs. llvm bitcode files
Date: 2026-03-26 11:27:15
Message-ID: CAN55FZ1=Tby+wibH1TkWMaKu_Xkj9aw9-XAToZBov0ovqzmHKg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, 26 Mar 2026 at 00:56, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> > I couldn't reproduce this. There are 43 .bc files and header change (I
> > changed simd.h) triggers a recompilation of only 'postgres.index.bc'
> > on my end. This behavior seems correct to me. Could you please share
> > steps to reproduce the behavior you saw?
>
> I can reliably reproduce it on multiple computers.
>
> patch applied on top of 009833ef2002430b1f8fae3a8e47718642b7a5d9,
> default meson build with only -Dllvm=enabled
>
> both on ubuntu 24.04/openSUSE tumbleweed with meson 1.3.2, ninja 1.11.1/1.13.2
>
> ninja # to ensure I built everything
> ninja # nothing happens, up to date
>
> touch ../src/include/port/simd.h && time ninja -j$(nproc) 2>&1
> [884/884] Generating src/backend/jit/llvm/bitcode/postgres with a custom command
> ninja -j$(nproc) 2>&1 188.04s user 31.36s system 4541% cpu 4.831 total
>
> touch ../src/include/port/simd.h && ninja -j$(nproc) 2>&1 -n | grep bc | wc -l
> 796

Thank you! I am able to reproduce the problem and your suggested fix
[1] fixes the problem for non-generated source files. However, when we
use [1] for the generated sources, then some of the generated sources
are added to the dependency (targetname + '.d') file. The problem is
that generated sources in the dependency file do not exist in the
source directory, they exist in the build directory as they are
generated. For example:

```
$ninja -t missingdeps
Missing dep: src/backend/jit/llvm/bitcode/postgres_src_backend_bootstrap_bootscanner_c.bc
uses src/backend/bootstrap/bootparse.h (generated by CUSTOM_COMMAND)
Missing dep: src/backend/jit/llvm/bitcode/postgres_src_backend_replication_repl_scanner_c.bc
uses src/backend/replication/repl_gram.h (generated by CUSTOM_COMMAND)
Missing dep: src/backend/jit/llvm/bitcode/postgres_src_backend_replication_syncrep_scanner_c.bc
uses src/backend/replication/syncrep_gram.h (generated by
CUSTOM_COMMAND)
Missing dep: src/backend/jit/llvm/bitcode/cube_contrib_cube_cubescan_c.bc
uses contrib/cube/cubeparse.h (generated by CUSTOM_COMMAND)
Missing dep: src/backend/jit/llvm/bitcode/seg_contrib_seg_segscan_c.bc
uses contrib/seg/segparse.h (generated by CUSTOM_COMMAND)
Processed 3443 nodes.
Error: There are 5 missing dependency paths.
5 targets had depfile dependencies on 5 distinct generated inputs
(from 1 rules) without a non-depfile dep path to the generator.
There might be build flakiness if any of the targets listed above are
built alone, or not late enough, in a clean output directory.
```

cubeparse.h is doesn't exist in the source directory as default but it
is generated by the:

```
cube_parse = custom_target('cubeparse',
input: 'cubeparse.y',
kwargs: bison_kw,
)
```

I solved that by adding them as extra dependencies:

```
bc_cube_gen_sources = [
{
'srcfiles': [cube_scan],
'extra_depends': [cube_parse]
}
]
```

[1]
bitcode_targets += custom_target(
targetname,
depends: [generated_backend_headers_stamp], # instead of [postgres_lib]
input: [srcfile],
output: targetname,
command: [llvm_irgen_command, llvm_irgen_dep_args,
bitcode_cflags_local], # added llvm_irgen_dep_args
depfile: targetname + '.d', # added
install: true,
install_dir: dir_bitcode,
)

--
Regards,
Nazir Bilal Yavuz
Microsoft

Attachment Content-Type Size
v12-0001-meson-Add-postgresql-extension.pc-for-building-e.patch text/x-patch 4.9 KB
v12-0002-meson-Test-building-extensions-by-using-postgres.patch text/x-patch 10.9 KB
v12-0003-meson-Add-docs-for-postgresql-extension.pc.patch text/x-patch 13.0 KB
v12-0004-meson-Add-architecture-for-LLVM-bitcode-emission.patch text/x-patch 10.7 KB
v12-0005-meson-Add-LLVM-bitcode-emissions-for-contrib-lib.patch text/x-patch 22.5 KB
v12-0006-meson-Add-LLVM-bitcode-emission-for-backend-sour.patch text/x-patch 5.0 KB
v12-0007-WIP-Generate-postgresql-extension.pc-in-autoconf.patch text/x-patch 4.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Sharma 2026-03-26 11:52:52 Re: synchronized_standby_slots behavior inconsistent with quorum-based synchronous replication
Previous Message Antonin Houska 2026-03-26 11:25:51 Re: VACUUM FULL, CLUSTER, and REPACK block on other sessions' temp tables