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

BharatDB <bharatdbpg@gmail.com>

From: BharatDB <bharatdbpg@gmail.com>
To: Josef Šimánek <josef.simanek@gmail.com>
Cc: Tristan Partin <tristan@partin.io>, pgsql-hackers <pgsql-hackers@postgresql.org>, Andres Freund <andres@anarazel.de>, Jelte Fennema-Nio <me@jeltef.nl>
Date: 2025-11-05T07:04:22Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Decouple C++ support in Meson's PGXS from LLVM enablement

  2. ci: Configure g++ with 32-bit for 32-bit build

  3. meson: Rename cpp variable to cxx

  4. Refactor to avoid code duplication in transformPLAssignStmt.

Attachments

Hi Tristan, Andres, Jelte, and pgsql-hackers,

Thank you for the excellent work on decoupling C++ support in Meson from
LLVM

SUMMARY: v2 PATCH TESTED AND WORKS PERFECTLY

- Built PostgreSQL 19devel (current master) with Meson

- Config: -Dllvm=disabled -Dcpp_support=auto

- Before patch: CXX = (empty) → extension fails with shell error

- After patch: CXX = ccache c++ → extension builds successfully

- Tested with minimal C++ extension → cpp_test.so created

 REPRODUCTION & FIX STEPS

1. git remote add tristan https://github.com/tristan957/postgres.git

   git fetch tristan

   git checkout -b meson-cpp tristan/meson-cpp

2. meson setup build-fixed .. -Dllvm=disabled -Dcpp_support=auto

   meson compile && meson install

3. Built test C++ extension:

    cd ~/cpp_test_ext && make clean && make


VERIFIED OUTPUT
$ grep -E "^(CXX|CXXFLAGS) =" build-fixed/src/Makefile.global

CXX = ccache c++

CXXFLAGS = -fno-strict-aliasing -fwrapv -Wall -g -O0 ...

$ ls -l ~/cpp_test_ext/*.so

  -rwxr-xr-x 1 boss boss 21568 Nov  4 12:18
/home/boss/cpp_test_ext/cpp_test.so

Patch applies cleanly and works perfectly on 19devel.

While testing the C++ PGXS patch, I noticed a usability gap:

> If no C++ compiler is installed (e.g., `g++` missing), Meson silently

> proceeds with C++ disabled — users only discover the issue when extensions

> like pg_duckdb fail with confusing build errors.

This patch adds a clear, single warning during configuration:

WARNING: No C++ compiler found on your system.

Extensions using C++ (e.g. pg_duckdb) will FAIL to build.

Install g++ or clang++ to enable C++ support.


- Only shown when `add_languages('cpp')` returns `false`

- No warning when C++ is available

- Tested on PostgreSQL 19devel (with and without `g++`)

Attached: `0001-meson-warn-when-no-C-compiler-is-found.patch`

Happy to revise if there are better ways to surface this — open to
suggestions!

Thanks again for the great work on Meson C++ support.

Best regards,

Lakshmi