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-23 13:39:28
Message-ID: CAN55FZ1FmSdbs5A8rYLjcHT=91=mfviv58-K66y5h2RTB_4hjw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

Thank you for looking into this!

On Thu, 19 Mar 2026 at 01:23, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
> + bitcode_targets += custom_target(
> + targetname,
> + depends: [bitcode_obj],
> + input: [srcfile],
> + output: targetname,
> + command: [llvm_irgen_command, bitcode_cflags_gen_local],
> + install: true,
> + install_dir: dir_bitcode,
> + )
>
> This seems overeager to rebuild to me. If I touch a single header
> file, it rebuilds all bc files because bitcode_obj (postgres_lib)
> changes.

bitcode_obj is equal to postgres_lib only for postgres.index.bc.

> Wouldn't something like the following work?
>
> 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

Could you mean 'bitcode_cflags_gen_local' instead of
'bitcode_cflags_local' here? Otherwise code doesn't compile.

> depfile: targetname + '.d', # added
> install: true,
> install_dir: dir_bitcode,
> )
>
> It seems to work in my testing, and results in less rebuilds. But I
> also have a fairly recent meson version, there might be some
> issues/limitations with earlier versions?

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?

> +bitcode_modules += {
> + 'target': hstore_plpython,
> + 'srcfiles': hstore_plpython_sources,
> + 'additional_flags': [
> + '-I(at)0@'.format(hstore_dir_up),
> + '-DPLPYTHON_LIBNAME="plpython3"',
> + '-I(at)0@'.format(python3_incdir),
> + '-I(at)0@'.format(plpython_dir),
> + perl_ccflags,
> + ]
> +}
>
> Do we need perl_ccflags for python?

No, it seems I mixed plpython and plperl. Fixed.

> +meson_args = ' '.join(args.meson_args)
> ...
> + if meson_args:
> + meson_setup_command = [meson_bin, meson_args, 'setup',
> test_args, test_out_dir]
> + else:
>
> Will this properly work with multiple args?

Updated. Previous version was merging all args into one string, now
each argument is one string.

> +
> +project('auth_delay', 'c')
> +
>
> Seems like a copy paste mistake, this is in postgres_fdw

Fixed.

> + if meson_args:
> + meson_setup_command = [meson_bin, meson_args, 'setup',
> test_args, test_out_dir]
> + else:
> + meson_setup_command = [meson_bin, 'setup', test_args, test_out_dir]
> +
> + meson_compile_command = ['meson', 'compile', '-C', test_out_dir, '-v']
>
> last one should also be meson_bin

Fixed.

> +
> +exit_code = 0
> +
>
> This is an unused variable

Removed.

> src/makefiles/meson.build contains the following, this should be
> updated with this patch?
>
> # TODO: requires bitcode generation to be implemented for meson
> 'BITCODE_CFLAGS': '',
> 'BITCODE_CXXFLAGS': '',

You are right, done.

--
Regards,
Nazir Bilal Yavuz
Microsoft

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-03-23 13:44:06 Re: Fix bug with accessing to temporary tables of other sessions
Previous Message Jim Jones 2026-03-23 13:31:33 Re: Fix bug with accessing to temporary tables of other sessions