pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feed From: TalGloz <glozmantal@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Compiling C Extension Functions against PostgreSQL 12
Date: Sat, 2 May 2020 16:03:57 -0700 (MST)
Message-ID: <1588460637089-0.post@n3.nabble.com> (raw )
In-Reply-To: <1610.1588454290@sss.pgh.pa.us >
References: <1588447687198-0.post@n3.nabble.com >
<4edd59f3-4d95-c41c-6839-7d022946f8d4@aklaver.com >
<1588448354769-0.post@n3.nabble.com >
<1b0a4606-2964-48ef-0736-ff51db2d2e1d@aklaver.com >
<1588449802471-0.post@n3.nabble.com >
<ec76736a-7842-d1ed-13a9-82789ed08017@aklaver.com >
<1588450167090-0.post@n3.nabble.com >
<9443e9f9-1eec-d4f5-eb19-fb6d1da9c587@aklaver.com >
<1588452776591-0.post@n3.nabble.com >
<1610.1588454290@sss.pgh.pa.us >
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
view thread (20+ messages) latest in thread
Message-ID: <1588460637089-0.post@n3.nabble.com>
Permalink: ../1588460637089-0.post@n3.nabble.com/
Also on: postgresql.org/message-id/1588460637089-0.post@n3.nabble.com
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: glozmantal@gmail.com
Subject: Re: Compiling C Extension Functions against PostgreSQL 12
In-Reply-To: <1588460637089-0.post@n3.nabble.com>
References: <1588447687198-0.post@n3.nabble.com> <4edd59f3-4d95-c41c-6839-7d022946f8d4@aklaver.com> <1588448354769-0.post@n3.nabble.com> <1b0a4606-2964-48ef-0736-ff51db2d2e1d@aklaver.com> <1588449802471-0.post@n3.nabble.com> <ec76736a-7842-d1ed-13a9-82789ed08017@aklaver.com> <1588450167090-0.post@n3.nabble.com> <9443e9f9-1eec-d4f5-eb19-fb6d1da9c587@aklaver.com> <1588452776591-0.post@n3.nabble.com> <1610.1588454290@sss.pgh.pa.us> <1588460637089-0.post@n3.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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