Re: meson vs. llvm bitcode files - Mailing list pgsql-hackers

From Nazir Bilal Yavuz
Subject Re: meson vs. llvm bitcode files
Date
Msg-id CAN55FZ1=Tby+wibH1TkWMaKu_Xkj9aw9-XAToZBov0ovqzmHKg@mail.gmail.com
Whole thread
In response to Re: meson vs. llvm bitcode files  (Zsolt Parragi <zsolt.parragi@percona.com>)
Responses Re: meson vs. llvm bitcode files
List pgsql-hackers
Hi,

On Thu, 26 Mar 2026 at 00:56, Zsolt Parragi <zsolt.parragi@percona.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

pgsql-hackers by date:

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