Re: pgsql: tests: Add a test C++ extension module

Поиск
Список
Период
Сортировка
Искать

Re: pgsql: tests: Add a test C++ extension module

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Tue, Jan 20, 2026 at 10:43 AM Peter Eisentraut  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


Re: pgsql: tests: Add a test C++ extension module

От:
Jelte Fennema-Nio <postgres@jeltef.nl>
Дата:
On Wed, 21 Jan 2026 at 21:25, Robert Haas  wrote:
>
> On Tue, Jan 20, 2026 at 10:43 AM Peter Eisentraut  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'


Re: pgsql: tests: Add a test C++ extension module

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Jelte Fennema-Nio  writes:
> On Wed, 21 Jan 2026 at 21:25, Robert Haas  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


Re: pgsql: tests: Add a test C++ extension module

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Wed, Jan 21, 2026 at 4:00 PM Jelte Fennema-Nio  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


FAQ