pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: tests: Add a test C++ extension module
10+ messages / 5 participants
[nested] [flat]

Commits from this thread:
  2026-01-22 ae4fe737ae  Detect if flags are needed for C++11 support
* pgsql: tests: Add a test C++ extension module
@ 2026-01-20 15:43 Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 03:27 ` Re: pgsql: tests: Add a test C++ extension module Peter Smith <smithpb2250@gmail.com>
  2026-01-21 20:25 ` Re: pgsql: tests: Add a test C++ extension module Robert Haas <robertmhaas@gmail.com>
  0 siblings, 2 replies; 10+ messages in thread

From: Peter Eisentraut @ 2026-01-20 15:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

tests: Add a test C++ extension module

While we already test that our headers are valid C++ using
headerscheck, it turns out that the macros we define might still
expand to invalid C++ code.  This adds a minimal test extension that
is compiled using C++ to test that it's actually possible to build and
run extensions written in C++.  Future commits will improve C++
compatibility of some of our macros and add usage of them to this
extension make sure that they don't regress in the future.

The test module is for the moment disabled when using MSVC.  In
particular, the use of designated initializers in PG_MODULE_MAGIC
would require C++20, for which we are currently not set up.  (GCC and
Clang support it as extensions.)  It is planned to fix this.

Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail....

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/476b35d4e311a3d77a550280d93393e518908b27

Modified Files
--------------
configure                                          |  8 +++++
configure.ac                                       |  7 ++++
src/Makefile.global.in                             |  2 ++
src/makefiles/meson.build                          |  2 ++
src/test/modules/Makefile                          |  6 ++++
src/test/modules/meson.build                       |  1 +
src/test/modules/test_cplusplusext/.gitignore      |  3 ++
src/test/modules/test_cplusplusext/Makefile        | 26 ++++++++++++++
src/test/modules/test_cplusplusext/README          | 10 ++++++
.../expected/test_cplusplusext.out                 |  7 ++++
src/test/modules/test_cplusplusext/meson.build     | 42 ++++++++++++++++++++++
.../test_cplusplusext/sql/test_cplusplusext.sql    |  3 ++
.../test_cplusplusext/test_cplusplusext--1.0.sql   |  8 +++++
.../test_cplusplusext/test_cplusplusext.control    |  4 +++
.../test_cplusplusext/test_cplusplusext.cpp        | 37 +++++++++++++++++++
15 files changed, 166 insertions(+)



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
@ 2026-01-21 03:27 ` Peter Smith <smithpb2250@gmail.com>
  2026-01-21 08:50   ` Re: pgsql: tests: Add a test C++ extension module Jelte Fennema-Nio <postgres@jeltef.nl>
  1 sibling, 1 reply; 10+ messages in thread

From: Peter Smith @ 2026-01-21 03:27 UTC (permalink / raw)
  To: Peter Eisentraut <peter@eisentraut.org>; +Cc: pgsql-committers@lists.postgresql.org

On Wed, Jan 21, 2026 at 2:43 AM Peter Eisentraut <peter@eisentraut.org> wrote:
>
> tests: Add a test C++ extension module
>
> While we already test that our headers are valid C++ using
> headerscheck, it turns out that the macros we define might still
> expand to invalid C++ code.  This adds a minimal test extension that
> is compiled using C++ to test that it's actually possible to build and
> run extensions written in C++.  Future commits will improve C++
> compatibility of some of our macros and add usage of them to this
> extension make sure that they don't regress in the future.
>
> The test module is for the moment disabled when using MSVC.  In
> particular, the use of designated initializers in PG_MODULE_MAGIC
> would require C++20, for which we are currently not set up.  (GCC and
> Clang support it as extensions.)  It is planned to fix this.
>
> Author: Jelte Fennema-Nio <postgres@jeltef.nl>
> Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail....
>
> Branch
> ------
> master
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/476b35d4e311a3d77a550280d93393e518908b27
>
> Modified Files
> --------------
> configure                                          |  8 +++++
> configure.ac                                       |  7 ++++
> src/Makefile.global.in                             |  2 ++
> src/makefiles/meson.build                          |  2 ++
> src/test/modules/Makefile                          |  6 ++++
> src/test/modules/meson.build                       |  1 +
> src/test/modules/test_cplusplusext/.gitignore      |  3 ++
> src/test/modules/test_cplusplusext/Makefile        | 26 ++++++++++++++
> src/test/modules/test_cplusplusext/README          | 10 ++++++
> .../expected/test_cplusplusext.out                 |  7 ++++
> src/test/modules/test_cplusplusext/meson.build     | 42 ++++++++++++++++++++++
> .../test_cplusplusext/sql/test_cplusplusext.sql    |  3 ++
> .../test_cplusplusext/test_cplusplusext--1.0.sql   |  8 +++++
> .../test_cplusplusext/test_cplusplusext.control    |  4 +++
> .../test_cplusplusext/test_cplusplusext.cpp        | 37 +++++++++++++++++++
> 15 files changed, 166 insertions(+)
>

Hi.

'make check-world' is suddenly failing for me, apparently caused by
this new test.

FYI - I am building in a 'Linux CentOS7-x64 ' environment, which I
know has reached end-of-life, but even so, everything was fine before
this test appeared.

======
Kind Regards,
Peter Smith.
Fujitsu Australia

~~~

install.log output is below:

make[4]: Entering directory
`/home/postgres/oss_postgres_misc/src/test/modules/test_cplusplusext'
for extra in src/test/modules/test_cplusplusext; do make -C
'../../../..'/$extra
DESTDIR='/home/postgres/oss_postgres_misc'/tmp_install install ||
exit; done
make[5]: Entering directory
`/home/postgres/oss_postgres_misc/src/test/modules/test_cplusplusext'
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -fPIC
-fvisibility=hidden -fvisibility-inlines-hidden -I. -I.
-I../../../../src/include -D_GNU_SOURCE      -c -o test_cplusplusext.o
test_cplusplusext.cpp
In file included from test_cplusplusext.cpp:19:0:
../../../../src/include/fmgr.h:510:1: warning: identifier
‘static_assert’ is a keyword in C++11 [-Wc++0x-compat]
 StaticAssertDecl(sizeof(FMGR_ABI_EXTRA) <= sizeof(((Pg_abi_values *)
0)->abi_extra),
 ^
In file included from ../../../../src/include/c.h:57:0,
                 from ../../../../src/include/postgres.h:48,
                 from test_cplusplusext.cpp:18:
../../../../src/include/pg_config.h:552:25: error: expected identifier
before numeric constant
 #define MAXIMUM_ALIGNOF 8
                         ^
../../../../src/include/c.h:1113:10: note: in expansion of macro
‘MAXIMUM_ALIGNOF’
  alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ];
          ^
../../../../src/include/pg_config.h:552:25: error: expected ‘,’ or
‘...’ before numeric constant
 #define MAXIMUM_ALIGNOF 8
                         ^
../../../../src/include/c.h:1113:10: note: in expansion of macro
‘MAXIMUM_ALIGNOF’
  alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ];
          ^
In file included from ../../../../src/include/postgres.h:48:0,
                 from test_cplusplusext.cpp:18:
../../../../src/include/c.h:1113:25: error: ISO C++ forbids
declaration of ‘alignas’ with no type [-fpermissive]
  alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ];
                         ^
../../../../src/include/c.h:1113:25: error: expected ‘;’ at end of
member declaration
In file included from ../../../../src/include/c.h:58:0,
                 from ../../../../src/include/postgres.h:48,
                 from test_cplusplusext.cpp:18:
../../../../src/include/pg_config_manual.h:223:27: error: expected
identifier before numeric constant
 #define PG_IO_ALIGN_SIZE  4096
                           ^
../../../../src/include/c.h:1113:25: error: expected ‘;’ at end of
member declaration
In file included from ../../../../src/include/c.h:58:0,
                 from ../../../../src/include/postgres.h:48,
                 from test_cplusplusext.cpp:18:
../../../../src/include/pg_config_manual.h:223:27: error: expected
identifier before numeric constant
 #define PG_IO_ALIGN_SIZE  4096
                           ^
../../../../src/include/c.h:1126:10: note: in expansion of macro
‘PG_IO_ALIGN_SIZE’
  alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ];
          ^
In file included from ../../../../src/include/postgres.h:48:0,
                 from test_cplusplusext.cpp:18:
../../../../src/include/c.h:1126:26: error: ISO C++ forbids
declaration of ‘alignas’ with no type [-fpermissive]
  alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ];
                          ^
../../../../src/include/c.h:1126:26: error: expected ‘;’ at end of
member declaration
In file included from ../../../../src/include/c.h:58:0,
                 from ../../../../src/include/postgres.h:48,
                 from test_cplusplusext.cpp:18:
../../../../src/include/pg_config_manual.h:223:27: error: expected
identifier before numeric constant
 #define PG_IO_ALIGN_SIZE  4096
                           ^
../../../../src/include/c.h:1132:10: note: in expansion of macro
‘PG_IO_ALIGN_SIZE’
  alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
          ^
../../../../src/include/pg_config_manual.h:223:27: error: expected ‘,’
or ‘...’ before numeric constant
 #define PG_IO_ALIGN_SIZE  4096
                           ^
../../../../src/include/c.h:1132:10: note: in expansion of macro
‘PG_IO_ALIGN_SIZE’
  alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
          ^
In file included from ../../../../src/include/postgres.h:48:0,
                 from test_cplusplusext.cpp:18:
../../../../src/include/c.h:1132:26: error: ISO C++ forbids
declaration of ‘alignas’ with no type [-fpermissive]
  alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
                          ^
../../../../src/include/c.h:1132:26: error: expected ‘;’ at end of
member declaration
../../../../src/include/c.h:943:15: error: expected constructor,
destructor, or type conversion before ‘(’ token
  static_assert(condition, errmessage)
               ^
../../../../src/include/fmgr.h:510:1: note: in expansion of macro
‘StaticAssertDecl’
 StaticAssertDecl(sizeof(FMGR_ABI_EXTRA) <= sizeof(((Pg_abi_values *)
0)->abi_extra),
 ^
make[5]: *** [test_cplusplusext.o] Error 1
make[5]: Leaving directory
`/home/postgres/oss_postgres_misc/src/test/modules/test_cplusplusext'
make[4]: *** [checkprep] Error 2
make[4]: Leaving directory
`/home/postgres/oss_postgres_misc/src/test/modules/test_cplusplusext'
make[3]: *** [checkprep-test_cplusplusext-recurse] Error 2





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 03:27 ` Re: pgsql: tests: Add a test C++ extension module Peter Smith <smithpb2250@gmail.com>
@ 2026-01-21 08:50   ` Jelte Fennema-Nio <postgres@jeltef.nl>
  2026-01-21 09:44     ` Re: pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 22:22     ` Re: pgsql: tests: Add a test C++ extension module Peter Smith <smithpb2250@gmail.com>
  0 siblings, 2 replies; 10+ messages in thread

From: Jelte Fennema-Nio @ 2026-01-21 08:50 UTC (permalink / raw)
  To: Peter Smith <smithpb2250@gmail.com>; Peter Eisentraut <peter@eisentraut.org>; +Cc: pgsql-committers@lists.postgresql.org

On Wed Jan 21, 2026 at 4:27 AM CET, Peter Smith wrote:
> 'make check-world' is suddenly failing for me, apparently caused by
> this new test.
>
> FYI - I am building in a 'Linux CentOS7-x64 ' environment, which I
> know has reached end-of-life, but even so, everything was fine before
> this test appeared.


I'm still not clear on what our policy is on supporting such EOL
distros. But this patch seems sensible regardless and it fixes
compilation for me when running on a centos 7 docker image.

Attachments:

v1-0001-Detect-if-flags-are-needed-for-C-11-support.patch (text/x-patch, 5.3K) download From 2af93c10fe716090f8d8ab1f884f11ee9b9a86cc Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <postgres@jeltef.nl> Date: Wed, 21 Jan 2026 09:18:53 +0100 Subject: [PATCH v1] Detect if flags are needed for C++11 support Just like we only support compiling with C11, we only support compiling extensions with C++11 and up. Some compilers support C++11 but don't enable it by default. This detects if flags are needed to enable C++11 support, in a similar way to how we check the same for C11 support. --- configure | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++- configure.ac | 28 +++++++++++++++++++++++++- meson.build | 28 ++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 04eeb1a741c..4c6f604c276 100755 --- a/configure +++ b/configure @@ -4770,7 +4770,61 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_ct_CXX"; then +# Detect option needed for C++11 +# PostgreSQL headers use C11 features (like alignas) which require C++11. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CXX option to accept ISO C++11" >&5 +$as_echo_n "checking for $CXX option to accept ISO C++11... " >&6; } + +if ${pgac_cv_prog_cxx_cxx11+:} false; then : + $as_echo_n "(cached) " >&6 +else + pgac_cv_prog_cxx_cxx11=no +pgac_save_CXX=$CXX +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +for pgac_arg in '' '-std=gnu++11' '-std=c++11'; do + CXX="$pgac_save_CXX $pgac_arg" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if !defined __cplusplus || __cplusplus < 201103L +# error "Compiler does not advertise C++11 conformance" +#endif +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + pgac_cv_prog_cxx_cxx11=$pgac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test x"$pgac_cv_prog_cxx_cxx11" != x"no" && break +done +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CXX=$pgac_save_CXX +fi + + +if test x"$pgac_cv_prog_cxx_cxx11" = x"no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C++ compiler \"$CXX\" does not support C++11" >&5 +$as_echo "$as_me: WARNING: C++ compiler \"$CXX\" does not support C++11" >&2;} +elif test x"$pgac_cv_prog_cxx_cxx11" = x""; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cxx_cxx11" >&5 +$as_echo "$pgac_cv_prog_cxx_cxx11" >&6; } + CXX="$CXX $pgac_cv_prog_cxx_cxx11" +fi + +if test -n "$ac_ct_CXX" -a x"$pgac_cv_prog_cxx_cxx11" != x"no"; then have_cxx=yes else have_cxx=no diff --git a/configure.ac b/configure.ac index 13c75170f7a..a329484e426 100644 --- a/configure.ac +++ b/configure.ac @@ -387,7 +387,33 @@ fi AC_PROG_CXX([$pgac_cxx_list]) -if test -n "$ac_ct_CXX"; then +# Detect option needed for C++11 +AC_MSG_CHECKING([for $CXX option to accept ISO C++11]) +AC_CACHE_VAL([pgac_cv_prog_cxx_cxx11], +[pgac_cv_prog_cxx_cxx11=no +pgac_save_CXX=$CXX +AC_LANG_PUSH([C++]) +for pgac_arg in '' '-std=gnu++11' '-std=c++11'; do + CXX="$pgac_save_CXX $pgac_arg" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if !defined __cplusplus || __cplusplus < 201103L +# error "Compiler does not advertise C++11 conformance" +#endif]])], [[pgac_cv_prog_cxx_cxx11=$pgac_arg]]) + test x"$pgac_cv_prog_cxx_cxx11" != x"no" && break +done +AC_LANG_POP([C++]) +CXX=$pgac_save_CXX]) + +if test x"$pgac_cv_prog_cxx_cxx11" = x"no"; then + AC_MSG_RESULT([unsupported]) + AC_MSG_WARN([C++ compiler "$CXX" does not support C++11]) +elif test x"$pgac_cv_prog_cxx_cxx11" = x""; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT([$pgac_cv_prog_cxx_cxx11]) + CXX="$CXX $pgac_cv_prog_cxx_cxx11" +fi + +if test -n "$ac_ct_CXX" -a x"$pgac_cv_prog_cxx_cxx11" != x"no"; then have_cxx=yes else have_cxx=no diff --git a/meson.build b/meson.build index 6d304f32fb0..f88a23b9f3a 100644 --- a/meson.build +++ b/meson.build @@ -585,6 +585,34 @@ if not cc.compiles(c11_test, name: 'C11') endif endif +# Do we need an option to enable C++11? +if have_cxx + cxx11_test = ''' +#if !defined __cplusplus || __cplusplus < 201103L +# error "Compiler does not advertise C++11 conformance" +#endif +''' + + if not cxx.compiles(cxx11_test, name: 'C++11') + have_cxx = false + if cxx.get_id() == 'msvc' + cxx11_test_args = ['/std:c++11'] + else + cxx11_test_args = ['-std=gnu++11', '-std=c++11'] + endif + foreach arg : cxx11_test_args + if cxx.compiles(cxx11_test, name: 'C++11 with @0@'.format(arg), args: [arg]) + have_cxx = true + cxxflags += arg + break + endif + endforeach + if not have_cxx + warning('C++ compiler does not support C++11') + endif + endif +endif + postgres_inc = [include_directories(postgres_inc_d)] test_lib_d = postgres_lib_d base-commit: b4555cb070f134c04328df54ce31d4ef1970f3bb -- 2.52.0
^ permalink raw reply [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 03:27 ` Re: pgsql: tests: Add a test C++ extension module Peter Smith <smithpb2250@gmail.com>
  2026-01-21 08:50   ` Re: pgsql: tests: Add a test C++ extension module Jelte Fennema-Nio <postgres@jeltef.nl>
@ 2026-01-21 09:44     ` Peter Eisentraut <peter@eisentraut.org>
  2026-01-22 13:47       ` Re: pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  1 sibling, 1 reply; 10+ messages in thread

From: Peter Eisentraut @ 2026-01-21 09:44 UTC (permalink / raw)
  To: Jelte Fennema-Nio <postgres@jeltef.nl>; Peter Smith <smithpb2250@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org

On 21.01.26 09:50, Jelte Fennema-Nio wrote:
> On Wed Jan 21, 2026 at 4:27 AM CET, Peter Smith wrote:
>> 'make check-world' is suddenly failing for me, apparently caused by
>> this new test.
>>
>> FYI - I am building in a 'Linux CentOS7-x64 ' environment, which I
>> know has reached end-of-life, but even so, everything was fine before
>> this test appeared.
> 
> 
> I'm still not clear on what our policy is on supporting such EOL
> distros. But this patch seems sensible regardless and it fixes
> compilation for me when running on a centos 7 docker image.

Yes, I was just in the process of writing that same patch.  I'll see if 
there are any differences and then move ahead with this.






^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 03:27 ` Re: pgsql: tests: Add a test C++ extension module Peter Smith <smithpb2250@gmail.com>
  2026-01-21 08:50   ` Re: pgsql: tests: Add a test C++ extension module Jelte Fennema-Nio <postgres@jeltef.nl>
  2026-01-21 09:44     ` Re: pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
@ 2026-01-22 13:47       ` Peter Eisentraut <peter@eisentraut.org>
  0 siblings, 0 replies; 10+ messages in thread

From: Peter Eisentraut @ 2026-01-22 13:47 UTC (permalink / raw)
  To: Jelte Fennema-Nio <postgres@jeltef.nl>; Peter Smith <smithpb2250@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org

On 21.01.26 10:44, Peter Eisentraut wrote:
> On 21.01.26 09:50, Jelte Fennema-Nio wrote:
>> On Wed Jan 21, 2026 at 4:27 AM CET, Peter Smith wrote:
>>> 'make check-world' is suddenly failing for me, apparently caused by
>>> this new test.
>>>
>>> FYI - I am building in a 'Linux CentOS7-x64 ' environment, which I
>>> know has reached end-of-life, but even so, everything was fine before
>>> this test appeared.
>>
>>
>> I'm still not clear on what our policy is on supporting such EOL
>> distros. But this patch seems sensible regardless and it fixes
>> compilation for me when running on a centos 7 docker image.
> 
> Yes, I was just in the process of writing that same patch.  I'll see if 
> there are any differences and then move ahead with this.

This has been committed, and at least one buildfarm member has confirmed 
so far.  The other ones are just very slow.

During testing, I noticed that my hack from an earlier patch to compute 
have_cxx in configure didn't work well when you specify CXX from the 
environment.  So I implemented a different solution for that.  Also, my 
reading and testing showed that MSVC doesn't have a /std:c++11 option, 
the oldest one is /std:c++14, so I went with that.






^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 03:27 ` Re: pgsql: tests: Add a test C++ extension module Peter Smith <smithpb2250@gmail.com>
  2026-01-21 08:50   ` Re: pgsql: tests: Add a test C++ extension module Jelte Fennema-Nio <postgres@jeltef.nl>
@ 2026-01-21 22:22     ` Peter Smith <smithpb2250@gmail.com>
  1 sibling, 0 replies; 10+ messages in thread

From: Peter Smith @ 2026-01-21 22:22 UTC (permalink / raw)
  To: Jelte Fennema-Nio <postgres@jeltef.nl>; +Cc: Peter Eisentraut <peter@eisentraut.org>; pgsql-committers@lists.postgresql.org

On Wed, Jan 21, 2026 at 7:50 PM Jelte Fennema-Nio <postgres@jeltef.nl> wrote:
>
> On Wed Jan 21, 2026 at 4:27 AM CET, Peter Smith wrote:
> > 'make check-world' is suddenly failing for me, apparently caused by
> > this new test.
> >
> > FYI - I am building in a 'Linux CentOS7-x64 ' environment, which I
> > know has reached end-of-life, but even so, everything was fine before
> > this test appeared.
>
>
> I'm still not clear on what our policy is on supporting such EOL
> distros. But this patch seems sensible regardless and it fixes
> compilation for me when running on a centos 7 docker image.

The patch fixed my problem. Thanks.

======
Kind Regards,
Peter Smith.
Fujitsu Australia





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
@ 2026-01-21 20:25 ` Robert Haas <robertmhaas@gmail.com>
  2026-01-21 21:00   ` Re: pgsql: tests: Add a test C++ extension module Jelte Fennema-Nio <postgres@jeltef.nl>
  1 sibling, 1 reply; 10+ messages in thread

From: Robert Haas @ 2026-01-21 20:25 UTC (permalink / raw)
  To: Peter Eisentraut <peter@eisentraut.org>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; Jelte Fennema <postgres@jeltef.nl>

On Tue, Jan 20, 2026 at 10:43 AM Peter Eisentraut <peter@eisentraut.org> wrote:
> tests: Add a test C++ extension module

This patch caused my usual build process to fail. I have been setting
CC='ccache clang' in my environment, and I was able to fix make it
work again by also setting CXX='ccache clang'. Before that, I was
getting my macPorts version of clang (21.1.2) for C source files but
the OS version of clang (15.0.0) for c++ files. But I still don't
really understand how that caused this failure, which doesn't look
like it has anything to do with mixing compilers:

[1/3] Compiling C++ object src/test/mo...plusext.dylib.p/test_cplusplusext.cpp.
FAILED: [code=1]
src/test/modules/test_cplusplusext/test_cplusplusext.dylib.p/test_cplusplusext.cpp.o
ccache c++ -Isrc/test/modules/test_cplusplusext/test_cplusplusext.dylib.p
-Isrc/include -I../pgsql/src/include -I/opt/local/include
-I/opt/local/include/libxml2 -I/opt/local/libexec/openssl3/include
-fdiagnostics-color=always -D_LIBCPP_ENABLE_ASSERTIONS=1 -Wall
-Winvalid-pch -O2 -g -fno-strict-aliasing -fwrapv -Wmissing-prototypes
-Wpointer-arith -Werror=vla -Werror=unguarded-availability-new
-Wendif-labels -Wmissing-format-attribute -Wcast-function-type
-Wformat-security -Wno-unused-command-line-argument
-Wno-compound-token-split-by-macro -fvisibility=hidden
-fvisibility=hidden -fvisibility-inlines-hidden -MD -MQ
src/test/modules/test_cplusplusext/test_cplusplusext.dylib.p/test_cplusplusext.cpp.o
-MF src/test/modules/test_cplusplusext/test_cplusplusext.dylib.p/test_cplusplusext.cpp.o.d
-o src/test/modules/test_cplusplusext/test_cplusplusext.dylib.p/test_cplusplusext.cpp.o
-c ../pgsql/src/test/modules/test_cplusplusext/test_cplusplusext.cpp
In file included from
../pgsql/src/test/modules/test_cplusplusext/test_cplusplusext.cpp:18:
In file included from ../pgsql/src/include/postgres.h:48:
../pgsql/src/include/c.h:1113:10: error: expected parameter declarator
        alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ];
                ^
src/include/pg_config.h:342:25: note: expanded from macro 'MAXIMUM_ALIGNOF'
#define MAXIMUM_ALIGNOF 8
                        ^
In file included from
../pgsql/src/test/modules/test_cplusplusext/test_cplusplusext.cpp:18:
In file included from ../pgsql/src/include/postgres.h:48:
../pgsql/src/include/c.h:1113:10: error: expected ')'
src/include/pg_config.h:342:25: note: expanded from macro 'MAXIMUM_ALIGNOF'
#define MAXIMUM_ALIGNOF 8
                        ^
../pgsql/src/include/c.h:1113:9: note: to match this '('
        alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ];
               ^
../pgsql/src/include/c.h:1113:2: error: a type specifier is required
for all declarations
        alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ];
        ^
../pgsql/src/include/c.h:1113:26: error: expected ';' at end of declaration list
        alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ];
                                ^
                                ;
../pgsql/src/include/c.h:1126:10: error: expected parameter declarator
        alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ];
                ^
../pgsql/src/include/pg_config_manual.h:223:27: note: expanded from
macro 'PG_IO_ALIGN_SIZE'
#define PG_IO_ALIGN_SIZE                4096
                                        ^
In file included from
../pgsql/src/test/modules/test_cplusplusext/test_cplusplusext.cpp:18:
In file included from ../pgsql/src/include/postgres.h:48:
../pgsql/src/include/c.h:1126:10: error: expected ')'
../pgsql/src/include/pg_config_manual.h:223:27: note: expanded from
macro 'PG_IO_ALIGN_SIZE'
#define PG_IO_ALIGN_SIZE                4096
                                        ^
../pgsql/src/include/c.h:1126:9: note: to match this '('
        alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ];
               ^
../pgsql/src/include/c.h:1126:2: error: a type specifier is required
for all declarations
        alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ];
        ^
../pgsql/src/include/c.h:1126:27: error: expected ';' at end of declaration list
        alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ];
                                 ^
                                 ;
../pgsql/src/include/c.h:1132:10: error: expected parameter declarator
        alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
                ^
../pgsql/src/include/pg_config_manual.h:223:27: note: expanded from
macro 'PG_IO_ALIGN_SIZE'
#define PG_IO_ALIGN_SIZE                4096
                                        ^
In file included from
../pgsql/src/test/modules/test_cplusplusext/test_cplusplusext.cpp:18:
In file included from ../pgsql/src/include/postgres.h:48:
../pgsql/src/include/c.h:1132:10: error: expected ')'
../pgsql/src/include/pg_config_manual.h:223:27: note: expanded from
macro 'PG_IO_ALIGN_SIZE'
#define PG_IO_ALIGN_SIZE                4096
                                        ^
../pgsql/src/include/c.h:1132:9: note: to match this '('
        alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
               ^
../pgsql/src/include/c.h:1132:2: error: a type specifier is required
for all declarations
        alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
        ^
../pgsql/src/include/c.h:1132:27: error: expected ';' at end of declaration list
        alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
                                 ^
                                 ;
12 errors generated.
ninja: build stopped: subcommand failed.

-- 
Robert Haas
EDB: http://www.enterprisedb.com





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 20:25 ` Re: pgsql: tests: Add a test C++ extension module Robert Haas <robertmhaas@gmail.com>
@ 2026-01-21 21:00   ` Jelte Fennema-Nio <postgres@jeltef.nl>
  2026-01-21 21:13     ` Re: pgsql: tests: Add a test C++ extension module Tom Lane <tgl@sss.pgh.pa.us>
  2026-01-21 21:16     ` Re: pgsql: tests: Add a test C++ extension module Robert Haas <robertmhaas@gmail.com>
  0 siblings, 2 replies; 10+ messages in thread

From: Jelte Fennema-Nio @ 2026-01-21 21:00 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Peter Eisentraut <peter@eisentraut.org>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

On Wed, 21 Jan 2026 at 21:25, Robert Haas <robertmhaas@gmail.com> wrote:
>
> On Tue, Jan 20, 2026 at 10:43 AM Peter Eisentraut <peter@eisentraut.org> wrote:
> > tests: Add a test C++ extension module
>
> This patch caused my usual build process to fail. I have been setting
> CC='ccache clang' in my environment, and I was able to fix make it
> work again by also setting CXX='ccache clang'. Before that, I was
> getting my macPorts version of clang (21.1.2) for C source files but
> the OS version of clang (15.0.0) for c++ files. But I still don't
> really understand how that caused this failure, which doesn't look
> like it has anything to do with mixing compilers:

Seems like the same error as Peter Smith. So I guess clang 15 doesn't
use C++11 by default. Did you try if my proposed patch solves it?
Another way of fixing your problem would have been:
CXX='/path/to/os-version/clang -std=gnu++11'





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 20:25 ` Re: pgsql: tests: Add a test C++ extension module Robert Haas <robertmhaas@gmail.com>
  2026-01-21 21:00   ` Re: pgsql: tests: Add a test C++ extension module Jelte Fennema-Nio <postgres@jeltef.nl>
@ 2026-01-21 21:13     ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 10+ messages in thread

From: Tom Lane @ 2026-01-21 21:13 UTC (permalink / raw)
  To: Jelte Fennema-Nio <postgres@jeltef.nl>; +Cc: Robert Haas <robertmhaas@gmail.com>; Peter Eisentraut <peter@eisentraut.org>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

Jelte Fennema-Nio <postgres@jeltef.nl> writes:
> On Wed, 21 Jan 2026 at 21:25, Robert Haas <robertmhaas@gmail.com> wrote:
>> This patch caused my usual build process to fail. I have been setting
>> CC='ccache clang' in my environment, and I was able to fix make it
>> work again by also setting CXX='ccache clang'. Before that, I was
>> getting my macPorts version of clang (21.1.2) for C source files but
>> the OS version of clang (15.0.0) for c++ files. But I still don't
>> really understand how that caused this failure, which doesn't look
>> like it has anything to do with mixing compilers:

> Seems like the same error as Peter Smith.

BF member sevengill is showing the identical error, but my
various macOS-based animals are OK.  Maybe comparing their
configuration choices would yield insight.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: pgsql: tests: Add a test C++ extension module
  2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
  2026-01-21 20:25 ` Re: pgsql: tests: Add a test C++ extension module Robert Haas <robertmhaas@gmail.com>
  2026-01-21 21:00   ` Re: pgsql: tests: Add a test C++ extension module Jelte Fennema-Nio <postgres@jeltef.nl>
@ 2026-01-21 21:16     ` Robert Haas <robertmhaas@gmail.com>
  1 sibling, 0 replies; 10+ messages in thread

From: Robert Haas @ 2026-01-21 21:16 UTC (permalink / raw)
  To: Jelte Fennema-Nio <postgres@jeltef.nl>; +Cc: Peter Eisentraut <peter@eisentraut.org>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

On Wed, Jan 21, 2026 at 4:00 PM Jelte Fennema-Nio <postgres@jeltef.nl> wrote:
> Seems like the same error as Peter Smith. So I guess clang 15 doesn't
> use C++11 by default. Did you try if my proposed patch solves it?
> Another way of fixing your problem would have been:
> CXX='/path/to/os-version/clang -std=gnu++11'

Oh, I didn't realize that it was the same problem. I've now tested
your patch and I find that it makes the build work for me without
needing to set CXX. IOW, yes, it does fix the problem.

The worst part about this, IMHO, is that the error message was totally
impenetrable. But I guess we can't do much about that.

-- 
Robert Haas
EDB: http://www.enterprisedb.com





^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2026-01-22 13:47 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-01-20 15:43 pgsql: tests: Add a test C++ extension module Peter Eisentraut <peter@eisentraut.org>
2026-01-21 03:27 ` Peter Smith <smithpb2250@gmail.com>
2026-01-21 08:50   ` Jelte Fennema-Nio <postgres@jeltef.nl>
2026-01-21 09:44     ` Peter Eisentraut <peter@eisentraut.org>
2026-01-22 13:47       ` Peter Eisentraut <peter@eisentraut.org>
2026-01-21 22:22     ` Peter Smith <smithpb2250@gmail.com>
2026-01-21 20:25 ` Robert Haas <robertmhaas@gmail.com>
2026-01-21 21:00   ` Jelte Fennema-Nio <postgres@jeltef.nl>
2026-01-21 21:13     ` Tom Lane <tgl@sss.pgh.pa.us>
2026-01-21 21:16     ` Robert Haas <robertmhaas@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox