Re: Decouple C++ support in Meson's PGXS from LLVM enablement - Mailing list pgsql-hackers

From BharatDB
Subject Re: Decouple C++ support in Meson's PGXS from LLVM enablement
Date
Msg-id CAAh00EQUwG5khqJO7nSV0nsqsG1OP=kA6ACfxV3rnNSVd4b6TQ@mail.gmail.com
Whole thread Raw
In response to Re: Decouple C++ support in Meson's PGXS from LLVM enablement  (Josef Šimánek <josef.simanek@gmail.com>)
List 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

pgsql-hackers by date:

Previous
From: Vaibhav Dalvi
Date:
Subject: Re: Non-text mode for pg_dumpall
Next
From: Antonin Houska
Date:
Subject: Re: Adding REPACK [concurrently]