Обсуждение: Compiling C Extension Functions against PostgreSQL 12
I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all my
manually created C extension functions against PostrgreSQL 12 before
starting the upgrade process. I have this Makefile that compiles perfectly
the seal_diff_cpp.cpp C extension function against PostgreSQL 10:
MODULES = seal_diff_cpp
PG_CONFIG = /usr/pgsql-10/bin/pg_config
PGXS = $(shell $(PG_CONFIG) --pgxs)
INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server)
INCLUDE_SEAL = /usr/local/include
INCLUDE_SEAL_LIB = /usr/local/lib
INCLUDE_CPPCODEC = /usr/local/include/cppcodec
CXX = g++
CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \
-I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC)
SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
include $(PGXS)
seal_diff_cpp.so: seal_diff_cpp.o
# $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so
seal_diff_cpp.o $(LDFLAGS) $(SEAL_LDFLAGS)
$(CXX) -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS)
$(SEAL_LDFLAGS)
seal_diff_cpp.o: seal_diff_cpp.cpp
$(CXX) $(CXXFLAGS) -o seal_diff_cpp.o -c seal_diff_cpp.cpp
When I execute it the output looks like this:
g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
-I/usr/pgsql-10/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-10/lib
-L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-10/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread
And the seal_diff_cpp.so gets created without any problems. But when I use
PG_CONFIG = /usr/pgsql-12/bin/pg_config I get:
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
seal_diff_cpp.cpp
seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
2 | #include <postgres.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:19: seal_diff_cpp.o] Error 1
The Makefile has all the needed information to compile the seal_diff_cpp.so
against PostgreSQL 12:
/usr/pgsql-10/bin/pg_config --pgxs --->
/usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk
/usr/pgsql-12/bin/pg_config --pgxs --->
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk
/usr/pgsql-10/bin/pg_config --includedir-server --->
/usr/pgsql-10/include/server
/usr/pgsql-12/bin/pg_config --includedir-server --->
/usr/pgsql-12/include/server (postgres.h is there)
I can't understand why it doesn't work.
TalGloz
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
On 5/2/20 12:28 PM, TalGloz wrote: > I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all my > manually created C extension functions against PostrgreSQL 12 before > starting the upgrade process. I have this Makefile that compiles perfectly > the seal_diff_cpp.cpp C extension function against PostgreSQL 10: > > MODULES = seal_diff_cpp > PG_CONFIG = /usr/pgsql-10/bin/pg_config > PGXS = $(shell $(PG_CONFIG) --pgxs) > INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server) > INCLUDE_SEAL = /usr/local/include > INCLUDE_SEAL_LIB = /usr/local/lib > INCLUDE_CPPCODEC = /usr/local/include/cppcodec > CXX = g++ > CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \ > -I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC) > SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread > include $(PGXS) > seal_diff_cpp.so: seal_diff_cpp.o > # $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so > seal_diff_cpp.o $(LDFLAGS) $(SEAL_LDFLAGS) > $(CXX) -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS) > $(SEAL_LDFLAGS) > seal_diff_cpp.o: seal_diff_cpp.cpp > $(CXX) $(CXXFLAGS) -o seal_diff_cpp.o -c seal_diff_cpp.cpp > > When I execute it the output looks like this: > > g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread > -I/usr/pgsql-10/include/server -I/usr/local/include > -I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp > g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-10/lib > -L/usr/lib64 -Wl,--as-needed > -Wl,-rpath,'/usr/pgsql-10/lib',--enable-new-dtags -L/usr/local/lib -lseal > -pthread > > And the seal_diff_cpp.so gets created without any problems. But when I use > PG_CONFIG = /usr/pgsql-12/bin/pg_config I get: > > g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute > -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c > seal_diff_cpp.cpp > seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory > 2 | #include <postgres.h> > | ^~~~~~~~~~~~ > compilation terminated. > make: *** [Makefile:19: seal_diff_cpp.o] Error 1 > > The Makefile has all the needed information to compile the seal_diff_cpp.so > against PostgreSQL 12: > /usr/pgsql-10/bin/pg_config --pgxs ---> > /usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk > /usr/pgsql-12/bin/pg_config --pgxs ---> > /usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk > > /usr/pgsql-10/bin/pg_config --includedir-server ---> > /usr/pgsql-10/include/server > /usr/pgsql-12/bin/pg_config --includedir-server ---> > /usr/pgsql-12/include/server (postgres.h is there) > > I can't understand why it doesn't work. Do you have Postgres 12 -dev package installed? > > TalGloz > > > > -- > Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html > > -- Adrian Klaver adrian.klaver@aklaver.com
Adrian Klaver-4 wrote > On 5/2/20 12:28 PM, TalGloz wrote: >> I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all >> my >> manually created C extension functions against PostrgreSQL 12 before >> starting the upgrade process. I have this Makefile that compiles >> perfectly >> the seal_diff_cpp.cpp C extension function against PostgreSQL 10: >> >> MODULES = seal_diff_cpp >> PG_CONFIG = /usr/pgsql-10/bin/pg_config >> PGXS = $(shell $(PG_CONFIG) --pgxs) >> INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server) >> INCLUDE_SEAL = /usr/local/include >> INCLUDE_SEAL_LIB = /usr/local/lib >> INCLUDE_CPPCODEC = /usr/local/include/cppcodec >> CXX = g++ >> CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \ >> -I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC) >> SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread >> include $(PGXS) >> seal_diff_cpp.so: seal_diff_cpp.o >> # $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so >> seal_diff_cpp.o $(LDFLAGS) $(SEAL_LDFLAGS) >> $(CXX) -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS) >> $(SEAL_LDFLAGS) >> seal_diff_cpp.o: seal_diff_cpp.cpp >> $(CXX) $(CXXFLAGS) -o seal_diff_cpp.o -c seal_diff_cpp.cpp >> >> When I execute it the output looks like this: >> >> g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread >> -I/usr/pgsql-10/include/server -I/usr/local/include >> -I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp >> g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-10/lib >> -L/usr/lib64 -Wl,--as-needed >> -Wl,-rpath,'/usr/pgsql-10/lib',--enable-new-dtags -L/usr/local/lib -lseal >> -pthread >> >> And the seal_diff_cpp.so gets created without any problems. But when I >> use >> PG_CONFIG = /usr/pgsql-12/bin/pg_config I get: >> >> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute >> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c >> seal_diff_cpp.cpp >> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or >> directory >> 2 | #include > <postgres.h> >> | ^~~~~~~~~~~~ >> compilation terminated. >> make: *** [Makefile:19: seal_diff_cpp.o] Error 1 >> >> The Makefile has all the needed information to compile the >> seal_diff_cpp.so >> against PostgreSQL 12: >> /usr/pgsql-10/bin/pg_config --pgxs ---> >> /usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk >> /usr/pgsql-12/bin/pg_config --pgxs ---> >> /usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk >> >> /usr/pgsql-10/bin/pg_config --includedir-server ---> >> /usr/pgsql-10/include/server >> /usr/pgsql-12/bin/pg_config --includedir-server ---> >> /usr/pgsql-12/include/server (postgres.h is there) >> >> I can't understand why it doesn't work. > > Do you have Postgres 12 -dev package installed? > >> >> TalGloz >> >> >> >> -- >> Sent from: >> https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html >> >> > > > -- > Adrian Klaver > adrian.klaver@ Yes, I've installed everything PostgreSQL 12 has to offer: dnf list installed | grep "postgresql12" postgresql12.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-contrib.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-devel.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-docs.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-libs.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-llvmjit.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-odbc.x86_64 12.01.0000-1PGDG.f31 @pgdg12 postgresql12-plperl.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-plpython.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-plpython3.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-pltcl.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-server.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-tcl.x86_64 2.4.0-2.f31.2 @pgdg12 postgresql12-test.x86_64 12.2-2PGDG.f31 @pgdg12 -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
On 5/2/20 12:39 PM, TalGloz wrote: > Adrian Klaver-4 wrote >> On 5/2/20 12:28 PM, TalGloz wrote: >>> I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all >>> my >>> manually created C extension functions against PostrgreSQL 12 before >>> starting the upgrade process. I have this Makefile that compiles >>> perfectly >>> the seal_diff_cpp.cpp C extension function against PostgreSQL 10: >>> > > Yes, I've installed everything PostgreSQL 12 has to offer: > > dnf list installed | grep "postgresql12" > postgresql12.x86_64 12.2-2PGDG.f31 > @pgdg12 > postgresql12-contrib.x86_64 12.2-2PGDG.f31 > @pgdg12 > postgresql12-devel.x86_64 12.2-2PGDG.f31 > @pgdg12 Yeah, I missed part in your OP where said postgres.h was there. So: 1) Did you do both makes in the same directory? 2) If so did you do a make clean between builds? -- Adrian Klaver adrian.klaver@aklaver.com
Adrian Klaver-4 wrote > On 5/2/20 12:39 PM, TalGloz wrote: >> Adrian Klaver-4 wrote >>> On 5/2/20 12:28 PM, TalGloz wrote: >>>> I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile >>>> all >>>> my >>>> manually created C extension functions against PostrgreSQL 12 before >>>> starting the upgrade process. I have this Makefile that compiles >>>> perfectly >>>> the seal_diff_cpp.cpp C extension function against PostgreSQL 10: >>>> > >> >> Yes, I've installed everything PostgreSQL 12 has to offer: >> >> dnf list installed | grep "postgresql12" >> postgresql12.x86_64 12.2-2PGDG.f31 >> @pgdg12 >> postgresql12-contrib.x86_64 12.2-2PGDG.f31 >> @pgdg12 >> postgresql12-devel.x86_64 12.2-2PGDG.f31 >> @pgdg12 > > Yeah, I missed part in your OP where said postgres.h was there. So: > > 1) Did you do both makes in the same directory? > > 2) If so did you do a make clean between builds? > > > > -- > Adrian Klaver > adrian.klaver@ 1) Yes I did. 2) Yes I did, though no .o .bc or .so files get created because of the error when using PostgreSQL 12 settings. -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
On 5/2/20 1:03 PM, TalGloz wrote: > Adrian Klaver-4 wrote >> On 5/2/20 12:39 PM, TalGloz wrote: >>> Adrian Klaver-4 wrote >>>> On 5/2/20 12:28 PM, TalGloz wrote: >>>>> I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile >>>>> all >>>>> my >>>>> manually created C extension functions against PostrgreSQL 12 before >>>>> starting the upgrade process. I have this Makefile that compiles >>>>> perfectly >>>>> the seal_diff_cpp.cpp C extension function against PostgreSQL 10: >>>>> >> >>> >>> Yes, I've installed everything PostgreSQL 12 has to offer: >>> >>> dnf list installed | grep "postgresql12" >>> postgresql12.x86_64 12.2-2PGDG.f31 >>> @pgdg12 >>> postgresql12-contrib.x86_64 12.2-2PGDG.f31 >>> @pgdg12 >>> postgresql12-devel.x86_64 12.2-2PGDG.f31 >>> @pgdg12 >> >> Yeah, I missed part in your OP where said postgres.h was there. So: >> >> 1) Did you do both makes in the same directory? >> >> 2) If so did you do a make clean between builds? >> >> >> >> -- >> Adrian Klaver > >> adrian.klaver@ > > 1) Yes I did. > 2) Yes I did, though no .o .bc or .so files get created because of the error > when using PostgreSQL 12 settings. But they where created when you did the make against Postgres 10, correct? So where those cleaned up? > > > > -- > Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html > > -- Adrian Klaver adrian.klaver@aklaver.com
Adrian Klaver-4 wrote > On 5/2/20 1:03 PM, TalGloz wrote: >> Adrian Klaver-4 wrote >>> On 5/2/20 12:39 PM, TalGloz wrote: >>>> Adrian Klaver-4 wrote >>>>> On 5/2/20 12:28 PM, TalGloz wrote: >>>>>> I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile >>>>>> all >>>>>> my >>>>>> manually created C extension functions against PostrgreSQL 12 before >>>>>> starting the upgrade process. I have this Makefile that compiles >>>>>> perfectly >>>>>> the seal_diff_cpp.cpp C extension function against PostgreSQL 10: >>>>>> >>> >>>> >>>> Yes, I've installed everything PostgreSQL 12 has to offer: >>>> >>>> dnf list installed | grep "postgresql12" >>>> postgresql12.x86_64 12.2-2PGDG.f31 >>>> @pgdg12 >>>> postgresql12-contrib.x86_64 12.2-2PGDG.f31 >>>> @pgdg12 >>>> postgresql12-devel.x86_64 12.2-2PGDG.f31 >>>> @pgdg12 >>> >>> Yeah, I missed part in your OP where said postgres.h was there. So: >>> >>> 1) Did you do both makes in the same directory? >>> >>> 2) If so did you do a make clean between builds? >>> >>> >>> >>> -- >>> Adrian Klaver >> >>> adrian.klaver@ >> >> 1) Yes I did. >> 2) Yes I did, though no .o .bc or .so files get created because of the >> error >> when using PostgreSQL 12 settings. > > But they where created when you did the make against Postgres 10, correct? > So where those cleaned up? >> >> >> >> -- >> Sent from: >> https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html >> >> > > > -- > Adrian Klaver > adrian.klaver@ Yes, they were created when using make against Postgres 10 and I clean them every time when I try a different version of Postgres. TalGloz -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
On 5/2/20 1:09 PM, TalGloz wrote: > Adrian Klaver-4 wrote > > Yes, they were created when using make against Postgres 10 and I clean them > every time when I try a different version of Postgres. Well I'm reaching the end of what I can do. All I have left is that the examples I have seen use: #include "postgres.h" not #include <postgres.h> > > TalGloz -- Adrian Klaver adrian.klaver@aklaver.com
Adrian Klaver-4 wrote
> On 5/2/20 1:09 PM, TalGloz wrote:
>> Adrian Klaver-4 wrote
>
>>
>> Yes, they were created when using make against Postgres 10 and I clean
>> them
>> every time when I try a different version of Postgres.
>
> Well I'm reaching the end of what I can do. All I have left is that the
> examples I have seen use:
>
> #include "postgres.h"
>
> not
>
> #include
> <postgres.h>
>>
>> TalGloz
>
>
>
> --
> Adrian Klaver
> adrian.klaver@
If it works for Postgres 10 it should also work for 12. I've changed from
#include <postgres.h> to #include "postgres.h" and I still get the same
error with Postgres 12 and it complies without any problem with Postgres 10
I dont understand why the output for Postgres 12
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
seal_diff_cpp.cpp
seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
2 | #include "postgres.h"
| ^~~~~~~~~~~~
looks different form the ones of Postgres 10
g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
-I/usr/pgsql-10/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-12/lib
-L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread
All the includes with "-I" and "-std=c++17 -fPIC" are from the first line
gone. I even tried to use fixed paths in my Makefiles: "PGXS =
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk" and "INCLUDEDIR =
/usr/pgsql-12/include/server".
TalGloz
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
TalGloz <glozmantal@gmail.com> writes:
> I dont understand why the output for Postgres 12
> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
> seal_diff_cpp.cpp
> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
> 2 | #include "postgres.h"
> | ^~~~~~~~~~~~
> looks different form the ones of Postgres 10
Looking at your Makefile, it seems to be expecting that CXXFLAGS will
be honored in the build, and it isn't being.
As far as I can see from pgxs.mk, you're supposed to spell that
PG_CXXFLAGS. Probably, it accidentally worked to do it the other
way in v10, but no longer does, likely as a result of the fact that
there's now some minimal amount of C++ code in core PG.
I'm a little dubious about whether overriding CXX is a good idea now, too.
(Likely the core setting is the same, but if it were pointing at a
different compiler that could cause trouble.)
regards, tom lane
On 5/2/20 2:18 PM, Tom Lane wrote: > TalGloz <glozmantal@gmail.com> writes: >> I dont understand why the output for Postgres 12 >> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute >> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c >> seal_diff_cpp.cpp >> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory >> 2 | #include "postgres.h" >> | ^~~~~~~~~~~~ > >> looks different form the ones of Postgres 10 > > Looking at your Makefile, it seems to be expecting that CXXFLAGS will > be honored in the build, and it isn't being. > > As far as I can see from pgxs.mk, you're supposed to spell that > PG_CXXFLAGS. Probably, it accidentally worked to do it the other > way in v10, but no longer does, likely as a result of the fact that > there's now some minimal amount of C++ code in core PG. I was looking at that and was trying to figure out this from pgxs.mk: # PG_CXXFLAGS -- will be appended to CXXFLAGS ... ifdef PG_CXXFLAGS override CXXFLAGS := $(CXXFLAGS) $(PG_CXXFLAGS) Was wondering if this might be culprit(from example in pgxs.mk): # include $(PGXS) The OP does not have that in their make file. > > I'm a little dubious about whether overriding CXX is a good idea now, too. > (Likely the core setting is the same, but if it were pointing at a > different compiler that could cause trouble.) > > regards, tom lane > > -- Adrian Klaver adrian.klaver@aklaver.com
Adrian Klaver-4 wrote
> On 5/2/20 2:18 PM, Tom Lane wrote:
>> TalGloz <
> glozmantal@
> > writes:
>>> I dont understand why the output for Postgres 12
>>> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
>>> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
>>> seal_diff_cpp.cpp
>>> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or
>>> directory
>>> 2 | #include "postgres.h"
>>> | ^~~~~~~~~~~~
>>
>>> looks different form the ones of Postgres 10
>>
>> Looking at your Makefile, it seems to be expecting that CXXFLAGS will
>> be honored in the build, and it isn't being.
>>
>> As far as I can see from pgxs.mk, you're supposed to spell that
>> PG_CXXFLAGS. Probably, it accidentally worked to do it the other
>> way in v10, but no longer does, likely as a result of the fact that
>> there's now some minimal amount of C++ code in core PG.
>
> I was looking at that and was trying to figure out this from pgxs.mk:
>
> # PG_CXXFLAGS -- will be appended to CXXFLAGS
>
> ...
>
> ifdef PG_CXXFLAGS
> override CXXFLAGS := $(CXXFLAGS) $(PG_CXXFLAGS)
>
> Was wondering if this might be culprit(from example in pgxs.mk):
>
> # include $(PGXS)
>
> The OP does not have that in their make file.
>
>>
>> I'm a little dubious about whether overriding CXX is a good idea now,
>> too.
>> (Likely the core setting is the same, but if it were pointing at a
>> different compiler that could cause trouble.)
>>
>> regards, tom lane
>>
>>
>
>
> --
> Adrian Klaver
> adrian.klaver@
The "include $(PGXS)" is defined in the Makefile. After changig the CXXFLAGS
to PG_CXXFLAGS I get:
*g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
-I/usr/pgsql-12/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-12/lib
-L/usr/lib64 -L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread
/usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
-fwrapv -O2 -I. -I./ -I/usr/pgsql-12/include/server
-I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2
-I/usr/include -flto=thin -emit-llvm -c -o seal_diff_cpp.bc
seal_diff_cpp.cpp*
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:12:50: error: no template named
'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
using ReaderLock = std::shared_lock<std::shared_mutex>;
~~~~~^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: 'shared_ptr' declared here
class shared_ptr : public __shared_ptr<_Tp>
^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:12:50: error: use of class template
'std::shared_ptr' requires template arguments
using ReaderLock = std::shared_lock<std::shared_mutex>;
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: template is declared here
class shared_ptr : public __shared_ptr<_Tp>
^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:14:50: error: no template named
'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
using WriterLock = std::unique_lock<std::shared_mutex>;
~~~~~^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: 'shared_ptr' declared here
class shared_ptr : public __shared_ptr<_Tp>
^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:14:50: error: use of class template
'std::shared_ptr' requires template arguments
using WriterLock = std::unique_lock<std::shared_mutex>;
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: template is declared here
class shared_ptr : public __shared_ptr<_Tp>
^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:21:20: error: unknown type name
'ReaderLock'
inline ReaderLock acquire_read()
^
/usr/local/include/seal/util/locks.h:26:20: error: unknown type name
'WriterLock'
inline WriterLock acquire_write()
^
/usr/local/include/seal/util/locks.h:31:20: error: unknown type name
'ReaderLock'
inline ReaderLock try_acquire_read()
^
/usr/local/include/seal/util/locks.h:36:20: error: unknown type name
'WriterLock'
inline WriterLock try_acquire_write()
^
/usr/local/include/seal/util/locks.h:46:18: error: no type named
'shared_mutex' in namespace 'std'
std::shared_mutex rw_lock_mutex_;
~~~~~^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
/usr/local/include/seal/util/mempool.h:561:17: error: unknown type name
'ReaderLock'
ReaderLock lock(pools_locker_.acquire_read());
^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
/usr/local/include/seal/memorypoolhandle.h:144:20: error: no matching
conversion for functional-style cast from
'shared_ptr<seal::util::MemoryPoolMT>' to 'seal::MemoryPoolHandle'
return MemoryPoolHandle(std::make_shared<util::MemoryPoolMT>());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/seal/memorypoolhandle.h:70:9: note: candidate constructor
not viable: no known conversion from 'shared_ptr<seal::util::MemoryPoolMT>'
to 'const seal::MemoryPoolHandle' for 1st argument
MemoryPoolHandle(const MemoryPoolHandle ©)
^
/usr/local/include/seal/memorypoolhandle.h:81:9: note: candidate constructor
not viable: no known conversion from 'shared_ptr<seal::util::MemoryPoolMT>'
to 'seal::MemoryPoolHandle' for 1st argument
MemoryPoolHandle(MemoryPoolHandle &&source) noexcept
^
/usr/local/include/seal/memorypoolhandle.h:243:9: note: candidate
constructor not viable: no known conversion from
'shared_ptr<seal::util::MemoryPoolMT>' to 'shared_ptr<util::MemoryPool>' for
1st argument
MemoryPoolHandle(std::shared_ptr<util::MemoryPool> pool) noexcept :
^
/usr/local/include/seal/memorypoolhandle.h:61:9: note: candidate constructor
not viable: requires 0 arguments, but 1 was provided
MemoryPoolHandle() = default;
^
11 errors generated.
make: ***
[/usr/pgsql-12/lib/pgxs/src/makefiles/../../src/Makefile.global:1047:
seal_diff_cpp.bc] Error 1
Does it try to comply the seal related code using the llvm compiler? If yes,
can I force it to se the GNU compiler instead? In my knolage the seal
library doesn't work with llvm.
Best regards,
TalGloz
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
On 5/2/20 2:44 PM, TalGloz wrote: > Adrian Klaver-4 wrote >> On 5/2/20 2:18 PM, Tom Lane wrote: >>> TalGloz < > > >> adrian.klaver@ > > The "include $(PGXS)" is defined in the Makefile. After changig the CXXFLAGS Hmm, time to clean my glasses. Have no idea what the below means. > to PG_CXXFLAGS I get: > > *g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread > -I/usr/pgsql-12/include/server -I/usr/local/include > -I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp > g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-12/lib > -L/usr/lib64 -L/usr/lib64 -Wl,--as-needed > -Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal > -pthread > /usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing > -fwrapv -O2 -I. -I./ -I/usr/pgsql-12/include/server > -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 > -I/usr/include -flto=thin -emit-llvm -c -o seal_diff_cpp.bc > seal_diff_cpp.cpp* > In file included from seal_diff_cpp.cpp:23: > In file included from /usr/local/include/seal/seal.h:3: > In file included from /usr/local/include/seal/bigpoly.h:9: > In file included from /usr/local/include/seal/biguint.h:6: > In file included from /usr/local/include/seal/memorypoolhandle.h:6: > In file included from /usr/local/include/seal/util/mempool.h:12: > /usr/local/include/seal/util/locks.h:12:50: error: no template named > 'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'? > using ReaderLock = std::shared_lock<std::shared_mutex>; > ~~~~~^ > /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11: > note: 'shared_ptr' declared here > class shared_ptr : public __shared_ptr<_Tp> > ^ -- Adrian Klaver adrian.klaver@aklaver.com
Tom Lane-2 wrote
> TalGloz <
> glozmantal@
> > writes:
>> I dont understand why the output for Postgres 12
>> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
>> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
>> seal_diff_cpp.cpp
>> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or
>> directory
>> 2 | #include "postgres.h"
>> | ^~~~~~~~~~~~
>
>> looks different form the ones of Postgres 10
>
> Looking at your Makefile, it seems to be expecting that CXXFLAGS will
> be honored in the build, and it isn't being.
>
> As far as I can see from pgxs.mk, you're supposed to spell that
> PG_CXXFLAGS. Probably, it accidentally worked to do it the other
> way in v10, but no longer does, likely as a result of the fact that
> there's now some minimal amount of C++ code in core PG.
>
> I'm a little dubious about whether overriding CXX is a good idea now, too.
> (Likely the core setting is the same, but if it were pointing at a
> different compiler that could cause trouble.)
>
> regards, tom lane
I've added some output to a different module Makefile that uses the same
libraries and Changed "CXXFLAGS" to "PG_CXXFLAGS" and "LDFLAGS" to
"PG_LDFLAGS":
# This file crates the seal_mean_cxx_v2.so library for the PostgreSQL
# Usage:
# make # compiles all
# make clean # clean all binaries and objects
MODULES = seal_mean_cxx_v2
# Location of PostgreSQL pg_config file
PG_CONFIG = /usr/pgsql-10/bin/pg_config
# PostgreSQL path to PGXS
PGXS = $(shell $(PG_CONFIG) --pgxs)
# PostgreSQL path to server header files
INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server)
# PostgreSQL path to executable shared libraries
POSGRESLIBINSTALL = $(shell $(PG_CONFIG) --pkglibdir)
# Location of the installed seal library
INCLUDE_SEAL = /usr/local/include
# Location of the compiled seal lib library
INCLUDE_SEAL_LIB = /usr/local/lib
# Location of the installed cppcodec library
INCLUDE_CPPCODEC = /usr/local/include/cppcodec
# Compiler to use
CXX = g++
# Compiler flags
PG_CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \
-I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC)
#PG_LDFLAGS= -L$(INCLUDE_SEAL_LIB) -lseal -pthread
# Seal linker flags
SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
include $(PGXS)
seal_mean_cxx_v2.so: seal_mean_cxx_v2.o # Create the .so file
@echo ""
@echo "Cereating .so file."
# Needed when checking the linker errors against the external SEAL library
and must be commented when creating .so file
# $(CXX) -Wl,--no-undefined -shared -o seal_mean_cxx.so seal_mean_cxx.o
$(PG_LDFLAGS) $(SEAL_LDFLAGS)
# Creates the .so file
$(CXX) -shared -o seal_mean_cxx_v2.so seal_mean_cxx_v2.o $(PG_LDFLAGS)
$(SEAL_LDFLAGS)
@echo "Done."
@echo ""
@echo "Copying the created .so library to \"${POSGRESLIBINSTALL}\"."
# Copies the .so file to PostgreSQL shared libraries
cp seal_mean_cxx_v2.so $(POSGRESLIBINSTALL)
@echo "Done."
@echo ""
seal_mean_cxx_v2.o: seal_mean_cxx_v2.cpp # Create the .o file
@echo ""
@echo "Creating .o file."
$(CXX) $(PG_CXXFLAGS) -o seal_mean_cxx_v2.o -c seal_mean_cxx_v2.cpp
@echo "Done."
.PHONY = clean
clean: # Clean .so and .o files
@echo ""
@echo "Cleaning the .so and .o files"
rm -f seal_mean_cxx_v2.so rm seal_mean_cxx_v2.o
@echo "Done."
@echo ""
I get this part for my code in the Makefile:
Makefile:57: warning: overriding recipe for target 'clean'
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk:342: warning: ignoring old
recipe for target 'clean'
Cleaning the .so and .o files
rm -f seal_mean_cxx_v2.so rm seal_mean_cxx_v2.o
Done.
[root@www seal_mean]# make
Makefile:57: warning: overriding recipe for target 'clean'
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk:342: warning: ignoring old
recipe for target 'clean'
Creating .o file.
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -std=c++17 -fPIC -Wall
-Werror -g -O0 -pthread -I/usr/pgsql-12/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_mean_cxx_v2.o -c seal_mean_cxx_v2.cpp
Done.
Cereating .so file.
g++ -shared -o seal_mean_cxx_v2.so seal_mean_cxx_v2.o -L/usr/pgsql-12/lib
-L/usr/lib64 -L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread
Done.
Copying the created .so library to "/usr/pgsql-12/lib".
cp seal_mean_cxx_v2.so /usr/pgsql-12/lib
Done.
Which is good, my seal_mean_cxx_v2.so being created and copied to
/usr/pgsql-12/lib/. But right after that I get this and it doesn't seem to
effect my seal_mean_cxx_v2.so library:
/usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
-fwrapv -O2 -I. -I./ -I/usr/pgsql-12/include/server
-I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2
-I/usr/include -flto=thin -emit-llvm -c -o seal_mean_cxx_v2.bc
seal_mean_cxx_v2.cpp
In file included from seal_mean_cxx_v2.cpp:25:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:12:50: error: no template named
'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
using ReaderLock = std::shared_lock<std::shared_mutex>;
~~~~~^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: 'shared_ptr' declared here
class shared_ptr : public __shared_ptr<_Tp>
^
In file included from seal_mean_cxx_v2.cpp:25:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:12:50: error: use of class template
'std::shared_ptr' requires template arguments
using ReaderLock = std::shared_lock<std::shared_mutex>;
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: template is declared here
class shared_ptr : public __shared_ptr<_Tp>
^
In file included from seal_mean_cxx_v2.cpp:25:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:14:50: error: no template named
'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
using WriterLock = std::unique_lock<std::shared_mutex>;
~~~~~^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: 'shared_ptr' declared here
class shared_ptr : public __shared_ptr<_Tp>
^
In file included from seal_mean_cxx_v2.cpp:25:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:14:50: error: use of class template
'std::shared_ptr' requires template arguments
using WriterLock = std::unique_lock<std::shared_mutex>;
^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: template is declared here
class shared_ptr : public __shared_ptr<_Tp>
^
In file included from seal_mean_cxx_v2.cpp:25:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:21:20: error: unknown type name
'ReaderLock'
inline ReaderLock acquire_read()
^
/usr/local/include/seal/util/locks.h:26:20: error: unknown type name
'WriterLock'
inline WriterLock acquire_write()
^
/usr/local/include/seal/util/locks.h:31:20: error: unknown type name
'ReaderLock'
inline ReaderLock try_acquire_read()
^
/usr/local/include/seal/util/locks.h:36:20: error: unknown type name
'WriterLock'
inline WriterLock try_acquire_write()
^
/usr/local/include/seal/util/locks.h:46:18: error: no type named
'shared_mutex' in namespace 'std'
std::shared_mutex rw_lock_mutex_;
~~~~~^
In file included from seal_mean_cxx_v2.cpp:25:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
/usr/local/include/seal/util/mempool.h:561:17: error: unknown type name
'ReaderLock'
ReaderLock lock(pools_locker_.acquire_read());
^
In file included from seal_mean_cxx_v2.cpp:25:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
/usr/local/include/seal/memorypoolhandle.h:144:20: error: no matching
conversion for functional-style cast from
'shared_ptr<seal::util::MemoryPoolMT>' to 'seal::MemoryPoolHandle'
return MemoryPoolHandle(std::make_shared<util::MemoryPoolMT>());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/seal/memorypoolhandle.h:70:9: note: candidate constructor
not viable: no known conversion from 'shared_ptr<seal::util::MemoryPoolMT>'
to 'const seal::MemoryPoolHandle' for 1st argument
MemoryPoolHandle(const MemoryPoolHandle ©)
^
/usr/local/include/seal/memorypoolhandle.h:81:9: note: candidate constructor
not viable: no known conversion from 'shared_ptr<seal::util::MemoryPoolMT>'
to 'seal::MemoryPoolHandle' for 1st argument
MemoryPoolHandle(MemoryPoolHandle &&source) noexcept
^
/usr/local/include/seal/memorypoolhandle.h:243:9: note: candidate
constructor not viable: no known conversion from
'shared_ptr<seal::util::MemoryPoolMT>' to 'shared_ptr<util::MemoryPool>' for
1st argument
MemoryPoolHandle(std::shared_ptr<util::MemoryPool> pool) noexcept :
^
/usr/local/include/seal/memorypoolhandle.h:61:9: note: candidate constructor
not viable: requires 0 arguments, but 1 was provided
MemoryPoolHandle() = default;
^
11 errors generated.
make: ***
[/usr/pgsql-12/lib/pgxs/src/makefiles/../../src/Makefile.global:1047:
seal_mean_cxx_v2.bc] Error 1
Why does it start executing the following after it did what it was supposed
to do?
/usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
-fwrapv -O2 -I. -I./ -I/usr/pgsql-12/include/server
-I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2
-I/usr/include -flto=thin -emit-llvm -c -o seal_mean_cxx_v2.bc
seal_mean_cxx_v2.cpp
Best regards,
TalGloz
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
On 5/2/20 4:03 PM, TalGloz wrote:
> Tom Lane-2 wrote
>> TalGloz <
>
>> glozmantal@
>
>> > writes:
>>> I dont understand why the output for Postgres 12
>>> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
>>> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
>>> seal_diff_cpp.cpp
>>> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or
>>> directory
>>> 2 | #include "postgres.h"
>>> | ^~~~~~~~~~~~
>>
>>> looks different form the ones of Postgres 10
>>
>> Looking at your Makefile, it seems to be expecting that CXXFLAGS will
>> be honored in the build, and it isn't being.
>>
>> As far as I can see from pgxs.mk, you're supposed to spell that
>> PG_CXXFLAGS. Probably, it accidentally worked to do it the other
>> way in v10, but no longer does, likely as a result of the fact that
>> there's now some minimal amount of C++ code in core PG.
>>
>> I'm a little dubious about whether overriding CXX is a good idea now, too.
>> (Likely the core setting is the same, but if it were pointing at a
>> different compiler that could cause trouble.)
>>
>> regards, tom lane
>
> I've added some output to a different module Makefile that uses the same
> libraries and Changed "CXXFLAGS" to "PG_CXXFLAGS" and "LDFLAGS" to
> "PG_LDFLAGS":
Did you?
In Makefile below I see:
#PG_LDFLAGS= -L$(INCLUDE_SEAL_LIB) -lseal -pthread
# Seal linker flags
SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
>
> # This file crates the seal_mean_cxx_v2.so library for the PostgreSQL
> # Usage:
> # make # compiles all
> # make clean # clean all binaries and objects
>
> MODULES = seal_mean_cxx_v2
>
> # Location of PostgreSQL pg_config file
> PG_CONFIG = /usr/pgsql-10/bin/pg_config
> # PostgreSQL path to PGXS
> PGXS = $(shell $(PG_CONFIG) --pgxs)
> # PostgreSQL path to server header files
> INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server)
> # PostgreSQL path to executable shared libraries
> POSGRESLIBINSTALL = $(shell $(PG_CONFIG) --pkglibdir)
>
> # Location of the installed seal library
> INCLUDE_SEAL = /usr/local/include
> # Location of the compiled seal lib library
> INCLUDE_SEAL_LIB = /usr/local/lib
> # Location of the installed cppcodec library
> INCLUDE_CPPCODEC = /usr/local/include/cppcodec
>
> # Compiler to use
> CXX = g++
> # Compiler flags
> PG_CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \
> -I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC)
> #PG_LDFLAGS= -L$(INCLUDE_SEAL_LIB) -lseal -pthread
> # Seal linker flags
> SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
> include $(PGXS)
>
> seal_mean_cxx_v2.so: seal_mean_cxx_v2.o # Create the .so file
> @echo ""
> @echo "Cereating .so file."
> # Needed when checking the linker errors against the external SEAL library
> and must be commented when creating .so file
> # $(CXX) -Wl,--no-undefined -shared -o seal_mean_cxx.so seal_mean_cxx.o
> $(PG_LDFLAGS) $(SEAL_LDFLAGS)
> # Creates the .so file
> $(CXX) -shared -o seal_mean_cxx_v2.so seal_mean_cxx_v2.o $(PG_LDFLAGS)
> $(SEAL_LDFLAGS)
> @echo "Done."
> @echo ""
> @echo "Copying the created .so library to \"${POSGRESLIBINSTALL}\"."
> # Copies the .so file to PostgreSQL shared libraries
> cp seal_mean_cxx_v2.so $(POSGRESLIBINSTALL)
> @echo "Done."
> @echo ""
>
> seal_mean_cxx_v2.o: seal_mean_cxx_v2.cpp # Create the .o file
> @echo ""
> @echo "Creating .o file."
> $(CXX) $(PG_CXXFLAGS) -o seal_mean_cxx_v2.o -c seal_mean_cxx_v2.cpp
> @echo "Done."
>
> .PHONY = clean
> clean: # Clean .so and .o files
> @echo ""
> @echo "Cleaning the .so and .o files"
> rm -f seal_mean_cxx_v2.so rm seal_mean_cxx_v2.o
> @echo "Done."
> @echo ""
>
> I get this part for my code in the Makefile:
>
> Makefile:57: warning: overriding recipe for target 'clean'
> /usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk:342: warning: ignoring old
> recipe for target 'clean'
>
> Cleaning the .so and .o files
> rm -f seal_mean_cxx_v2.so rm seal_mean_cxx_v2.o
> Done.
>
> [root@www seal_mean]# make
> Makefile:57: warning: overriding recipe for target 'clean'
> /usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk:342: warning: ignoring old
> recipe for target 'clean'
>
> Creating .o file.
> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -std=c++17 -fPIC -Wall
> -Werror -g -O0 -pthread -I/usr/pgsql-12/include/server -I/usr/local/include
> -I/usr/local/include/cppcodec -o seal_mean_cxx_v2.o -c seal_mean_cxx_v2.cpp
> Done.
>
> Cereating .so file.
> g++ -shared -o seal_mean_cxx_v2.so seal_mean_cxx_v2.o -L/usr/pgsql-12/lib
> -L/usr/lib64 -L/usr/lib64 -Wl,--as-needed
> -Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
> -pthread
> Done.
>
> Copying the created .so library to "/usr/pgsql-12/lib".
> cp seal_mean_cxx_v2.so /usr/pgsql-12/lib
> Done.
>
>
> Which is good, my seal_mean_cxx_v2.so being created and copied to
> /usr/pgsql-12/lib/. But right after that I get this and it doesn't seem to
> effect my seal_mean_cxx_v2.so library:
> /usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
> -fwrapv -O2 -I. -I./ -I/usr/pgsql-12/include/server
> -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2
> -I/usr/include -flto=thin -emit-llvm -c -o seal_mean_cxx_v2.bc
> seal_mean_cxx_v2.cpp
> In file included from seal_mean_cxx_v2.cpp:25:
> In file included from /usr/local/include/seal/seal.h:3:
> In file included from /usr/local/include/seal/bigpoly.h:9:
> In file included from /usr/local/include/seal/biguint.h:6:
> In file included from /usr/local/include/seal/memorypoolhandle.h:6:
> In file included from /usr/local/include/seal/util/mempool.h:12:
> /usr/local/include/seal/util/locks.h:12:50: error: no template named
> 'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
> using ReaderLock = std::shared_lock<std::shared_mutex>;
> ~~~~~^
> /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
> note: 'shared_ptr' declared here
> class shared_ptr : public __shared_ptr<_Tp>
> ^
> In file included from seal_mean_cxx_v2.cpp:25:
> In file included from /usr/local/include/seal/seal.h:3:
> In file included from /usr/local/include/seal/bigpoly.h:9:
> In file included from /usr/local/include/seal/biguint.h:6:
> In file included from /usr/local/include/seal/memorypoolhandle.h:6:
> In file included from /usr/local/include/seal/util/mempool.h:12:
> /usr/local/include/seal/util/locks.h:12:50: error: use of class template
> 'std::shared_ptr' requires template arguments
> using ReaderLock = std::shared_lock<std::shared_mutex>;
> ^
> /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
> note: template is declared here
> class shared_ptr : public __shared_ptr<_Tp>
> ^
> In file included from seal_mean_cxx_v2.cpp:25:
> In file included from /usr/local/include/seal/seal.h:3:
> In file included from /usr/local/include/seal/bigpoly.h:9:
> In file included from /usr/local/include/seal/biguint.h:6:
> In file included from /usr/local/include/seal/memorypoolhandle.h:6:
> In file included from /usr/local/include/seal/util/mempool.h:12:
> /usr/local/include/seal/util/locks.h:14:50: error: no template named
> 'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
> using WriterLock = std::unique_lock<std::shared_mutex>;
> ~~~~~^
> /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
> note: 'shared_ptr' declared here
> class shared_ptr : public __shared_ptr<_Tp>
> ^
> In file included from seal_mean_cxx_v2.cpp:25:
> In file included from /usr/local/include/seal/seal.h:3:
> In file included from /usr/local/include/seal/bigpoly.h:9:
> In file included from /usr/local/include/seal/biguint.h:6:
> In file included from /usr/local/include/seal/memorypoolhandle.h:6:
> In file included from /usr/local/include/seal/util/mempool.h:12:
> /usr/local/include/seal/util/locks.h:14:50: error: use of class template
> 'std::shared_ptr' requires template arguments
> using WriterLock = std::unique_lock<std::shared_mutex>;
> ^
> /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
> note: template is declared here
> class shared_ptr : public __shared_ptr<_Tp>
> ^
> In file included from seal_mean_cxx_v2.cpp:25:
> In file included from /usr/local/include/seal/seal.h:3:
> In file included from /usr/local/include/seal/bigpoly.h:9:
> In file included from /usr/local/include/seal/biguint.h:6:
> In file included from /usr/local/include/seal/memorypoolhandle.h:6:
> In file included from /usr/local/include/seal/util/mempool.h:12:
> /usr/local/include/seal/util/locks.h:21:20: error: unknown type name
> 'ReaderLock'
> inline ReaderLock acquire_read()
> ^
> /usr/local/include/seal/util/locks.h:26:20: error: unknown type name
> 'WriterLock'
> inline WriterLock acquire_write()
> ^
> /usr/local/include/seal/util/locks.h:31:20: error: unknown type name
> 'ReaderLock'
> inline ReaderLock try_acquire_read()
> ^
> /usr/local/include/seal/util/locks.h:36:20: error: unknown type name
> 'WriterLock'
> inline WriterLock try_acquire_write()
> ^
> /usr/local/include/seal/util/locks.h:46:18: error: no type named
> 'shared_mutex' in namespace 'std'
> std::shared_mutex rw_lock_mutex_;
> ~~~~~^
> In file included from seal_mean_cxx_v2.cpp:25:
> In file included from /usr/local/include/seal/seal.h:3:
> In file included from /usr/local/include/seal/bigpoly.h:9:
> In file included from /usr/local/include/seal/biguint.h:6:
> In file included from /usr/local/include/seal/memorypoolhandle.h:6:
> /usr/local/include/seal/util/mempool.h:561:17: error: unknown type name
> 'ReaderLock'
> ReaderLock lock(pools_locker_.acquire_read());
> ^
> In file included from seal_mean_cxx_v2.cpp:25:
> In file included from /usr/local/include/seal/seal.h:3:
> In file included from /usr/local/include/seal/bigpoly.h:9:
> In file included from /usr/local/include/seal/biguint.h:6:
> /usr/local/include/seal/memorypoolhandle.h:144:20: error: no matching
> conversion for functional-style cast from
> 'shared_ptr<seal::util::MemoryPoolMT>' to 'seal::MemoryPoolHandle'
> return MemoryPoolHandle(std::make_shared<util::MemoryPoolMT>());
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/local/include/seal/memorypoolhandle.h:70:9: note: candidate constructor
> not viable: no known conversion from 'shared_ptr<seal::util::MemoryPoolMT>'
> to 'const seal::MemoryPoolHandle' for 1st argument
> MemoryPoolHandle(const MemoryPoolHandle ©)
> ^
> /usr/local/include/seal/memorypoolhandle.h:81:9: note: candidate constructor
> not viable: no known conversion from 'shared_ptr<seal::util::MemoryPoolMT>'
> to 'seal::MemoryPoolHandle' for 1st argument
> MemoryPoolHandle(MemoryPoolHandle &&source) noexcept
> ^
> /usr/local/include/seal/memorypoolhandle.h:243:9: note: candidate
> constructor not viable: no known conversion from
> 'shared_ptr<seal::util::MemoryPoolMT>' to 'shared_ptr<util::MemoryPool>' for
> 1st argument
> MemoryPoolHandle(std::shared_ptr<util::MemoryPool> pool) noexcept :
> ^
> /usr/local/include/seal/memorypoolhandle.h:61:9: note: candidate constructor
> not viable: requires 0 arguments, but 1 was provided
> MemoryPoolHandle() = default;
> ^
> 11 errors generated.
> make: ***
> [/usr/pgsql-12/lib/pgxs/src/makefiles/../../src/Makefile.global:1047:
> seal_mean_cxx_v2.bc] Error 1
>
> Why does it start executing the following after it did what it was supposed
> to do?
> /usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
> -fwrapv -O2 -I. -I./ -I/usr/pgsql-12/include/server
> -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2
> -I/usr/include -flto=thin -emit-llvm -c -o seal_mean_cxx_v2.bc
> seal_mean_cxx_v2.cpp
>
>
> Best regards,
> TalGloz
>
>
>
> --
> Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Adrian Klaver-4 wrote
> On 5/2/20 4:03 PM, TalGloz wrote:
>
> Did you?
>
> In Makefile below I see:
>
> #PG_LDFLAGS= -L$(INCLUDE_SEAL_LIB) -lseal -pthread
> # Seal linker flags
> SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
>
> --
> Adrian Klaver
> adrian.klaver@
It actually didn't change a thing but since they are the same I've removed
the "SEAL_LDFLAGS" and used "PG_LDFLAGS" instead.
The maigor breakthrough was changing "CXXFLAGS" to "PG_CXXFLAGS" this has
removed the error:
seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
2 | #include <postgres.h>
| ^~~~~~~~~~~~
All the Makefile steps and their outputs get generated as should. My only
concern is regarding the last part below that comes after
"seal_mean_cxx_v2.so" was generated and copied to "/usr/pgsql-12/lib" and
generates all the errors regarding the seal library I've listed in previous
posts. I don't know what triggers it in my Makefile and it not supposed to
be executed.
/usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
-fwrapv -O2 -I. -I./ -I/usr/pgsql-12/include/server
-I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2
-I/us /include -flto=thin -emit-llvm -c -o seal_mean_cxx_v2.bc
seal_mean_cxx_v2.cpp
Maybe it is being triggered by the "pgxs.mk" because as of Postgres 12 it
has "with_llvm" parts e.g.:
ifeq ($(with_llvm), yes)
all: $(addsuffix .bc, $(MODULES)) $(patsubst %.o,%.bc, $(OBJS))
endif
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
>>>>> "TalGloz" == TalGloz <glozmantal@gmail.com> writes: TalGloz> Which is good, my seal_mean_cxx_v2.so being created and copied TalGloz> to /usr/pgsql-12/lib/. But right after that I get this and it TalGloz> doesn't seem to effect my seal_mean_cxx_v2.so library: What's happening here is that it's attempting to build LLVM bitcode files for your library for the benefit of the JIT compiler that exists in recent postgres versions - without these files, your extension functions cannot be inlined into generated code. This requires that your code be compilable using clang (as well as gcc if that's what was used to build PG itself), and there's clearly some disagreement going on between clang and your system header files that's causing the failure. I didn't see an easy way of disabling bitcode emission for a module, though I think that has been discussed before. -- Andrew (irc:RhodiumToad)
Andrew Gierth wrote >>>>>> "TalGloz" == TalGloz < > glozmantal@ > > writes: > > TalGloz> Which is good, my seal_mean_cxx_v2.so being created and copied > TalGloz> to /usr/pgsql-12/lib/. But right after that I get this and it > TalGloz> doesn't seem to effect my seal_mean_cxx_v2.so library: > > What's happening here is that it's attempting to build LLVM bitcode > files for your library for the benefit of the JIT compiler that exists > in recent postgres versions - without these files, your extension > functions cannot be inlined into generated code. > > This requires that your code be compilable using clang (as well as gcc > if that's what was used to build PG itself), and there's clearly some > disagreement going on between clang and your system header files that's > causing the failure. > > I didn't see an easy way of disabling bitcode emission for a module, > though I think that has been discussed before. > > -- > Andrew (irc:RhodiumToad) Will the absence of LLVM bit-code files effect the functionality of my "seal_mean_cxx_v2.so" library in Postgresql12 or I just won't benefit from Postgres JIT compiler (postgresql12-llvmjit package)? The "seal_mean_cxx_v2.so" was enough to use with Postgres 10. All the errors occurring for the llvm compilation part relate to the Microsoft SEAL <https://github.com/microsoft/SEAL> library that my seal_mean_cxx_v2.cpp uses. Since it is a third party library then maybe I should post the errors output there and see what they have to say about it... Best regerds, TalGloz -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
TalGloz <glozmantal@gmail.com> writes:
> Andrew Gierth wrote
>> I didn't see an easy way of disabling bitcode emission for a module,
>> though I think that has been discussed before.
After taking a quick look through pgxs.mk, it looks like you might
be able to do something like
override with_llvm := no
in your Makefile before including the PG parts.
> Will the absence of LLVM bit-code files effect the functionality of my
> "seal_mean_cxx_v2.so" library in Postgresql12 or I just won't benefit from
> Postgres JIT compiler (postgresql12-llvmjit package)?
Should just prevent the possibility of "inline"-ing your functions
in JIT compilation.
> All the errors occurring for the llvm compilation part relate to the
> Microsoft SEAL <https://github.com/microsoft/SEAL> library that my
> seal_mean_cxx_v2.cpp uses. Since it is a third party library then maybe I
> should post the errors output there and see what they have to say about
> it...
Yeah, the ultimate solution is clearly over on that side. These
last errors you've posted don't seem particularly Postgres-related.
regards, tom lane
Tom Lane-2 wrote > TalGloz < > glozmantal@ > > writes: >> Andrew Gierth wrote >>> I didn't see an easy way of disabling bitcode emission for a module, >>> though I think that has been discussed before. > > After taking a quick look through pgxs.mk, it looks like you might > be able to do something like > override with_llvm := no > in your Makefile before including the PG parts. > >> Will the absence of LLVM bit-code files effect the functionality of my >> "seal_mean_cxx_v2.so" library in Postgresql12 or I just won't benefit >> from >> Postgres JIT compiler (postgresql12-llvmjit package)? > > Should just prevent the possibility of "inline"-ing your functions > in JIT compilation. > >> All the errors occurring for the llvm compilation part relate to the >> Microsoft SEAL <https://github.com/microsoft/SEAL> library that >> my >> seal_mean_cxx_v2.cpp uses. Since it is a third party library then maybe I >> should post the errors output there and see what they have to say about >> it... > > Yeah, the ultimate solution is clearly over on that side. These > last errors you've posted don't seem particularly Postgres-related. > > regards, tom lane Setting "override with_llvm := no" did make the compilation step with llvm go away. I'm using an older version of SEAL and I wanted to maintain my code functionality after upgrading to Postgres 12. I'll be posting the llvm related errors on the SEAL project page for more clarification, maybe the usage of the old SEAL version is the problem. Anyways, after retaining the original functionality with Postgres 12 I'll be focusing on updating my code to comply with the latest SEAL version. Thanks to all of you for helping me with this "issue". Best regards, TalGloz -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html