Decouple C++ support in Meson's PGXS from LLVM enablement

From: "Tristan Partin" <tristan(at)partin(dot)io>
To: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Cc: "Andres Freund" <andres(at)anarazel(dot)de>, "Jelte Fennema-Nio" <me(at)jeltef(dot)nl>
Subject: Decouple C++ support in Meson's PGXS from LLVM enablement
Date: 2025-04-17 01:57:26
Message-ID: D98JHQF7H2A8.VSE3I4CJBTAB@partin.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Howdy folks,

While playing around with pg_duckdb[0], a Postgres extension written in
C++ which uses PGXS, I came across a strange build error:

std=c++17 -Wno-sign-compare...
/bin/sh: line 1: -Wno-sign-compare: command not found

I was very confused by the error, but reading the command line, it made
sense. After talking to Jelte off-list, he told me to try a Postgres
installation that had been built with autotools. Today, I finally had
a chance to try that tip, and building pg_duckdb succeeded.

I spent some time exploring the Meson build a bit, and I realized that
C++ support in PGXS is tied to LLVM enablement. Checking the autotools
build in the configure.ac script indicates that that is not the case for
it.

On master, C++ support looks like:

llvmopt = get_option('llvm')
llvm = not_found_dep
if add_languages('cpp', required: llvmopt, native: false)
llvm = dependency('llvm', version: '>=14', method: 'config-tool', required: llvmopt)
if llvm.found()

cdata.set('USE_LLVM', 1)

cpp = meson.get_compiler('cpp')

By default, the `llvm` option is disabled, which Meson takes to mean,
"do not check for C++ support". Thusly, add_languages() returns false.
In addition, every check for adding to cxxflags, et. al. is gated on
llvm.found(), which is always false for the `not_found_dep`. All this
considered, the Makefile.global of a Postgres build roughly looked like:

CXX =
CXXFLAGS =
...

This then accounts for the original pg_duckdb command line looking the
way that it did.

Attached is a patch which decouples C++ support in PGXS from LLVM for
a Meson-compiled Postgres.

[0]: https://github.com/duckdb/pg_duckdb

--
Tristan Partin
Neon (https://neon.tech)

Attachment Content-Type Size
0001-Decouple-C-support-in-Meson-s-PGXS-from-LLVM-enablem.patch text/x-patch 4.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message wenhui qiu 2025-04-17 03:16:29 Re: POC: Parallel processing of indexes in autovacuum
Previous Message Fujii Masao 2025-04-17 01:01:08 Re: use correct variable in error message in _allocAH function (pg_backup_archiver.c)