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

From: BharatDB <bharatdbpg(at)gmail(dot)com>
To: Josef Šimánek <josef(dot)simanek(at)gmail(dot)com>
Cc: Tristan Partin <tristan(at)partin(dot)io>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Jelte Fennema-Nio <me(at)jeltef(dot)nl>
Subject: Re: Decouple C++ support in Meson's PGXS from LLVM enablement
Date: 2025-11-05 07:04:22
Message-ID: CAAh00EQUwG5khqJO7nSV0nsqsG1OP=kA6ACfxV3rnNSVd4b6TQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
0001-meson-warn-when-no-C-compiler-is-found.patch text/x-patch 4.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2025-11-05 07:12:19 Re: Adding REPACK [concurrently]
Previous Message Vaibhav Dalvi 2025-11-05 06:59:53 Re: Non-text mode for pg_dumpall