Hello, I’ve recently tried to build an extension that employs C++ files and also passes them to a linker to make a shared library. I’ve discovered a few issues with them:
- in v10 CFLAGS_SL is not appended to the CXXFLAGS in Makefile.shlib, resulting in cpp files compiled without -fPIC, leading to errors when creating the shared library out of them. In v11 and above CFLAGS_SL is prepended to the PG_CXXFLAGS, but there are no PG_CXXFLAGS on v10, and the Makefile does nothing to add them to CXXFLAGS. Patch is attached. - not just with v10, when building bc files from cpp, there are no CXXFLAGS passed; as a result, when building a source with non-standard flags (i.e -std=c++11) one would get an error during building of bc files. The rules in the Makefile.global.(in) look like: ifndef COMPILE.c.bc # -Wno-ignored-attributes added so gnu_printf doesn't trigger # warnings, when the main binary is compiled with C. COMPILE.c.bc = $(CLANG) -Wno-ignored-attributes $(BITCODE_CFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c endif ifndef COMPILE.cxx.bc COMPILE.cxx.bc = $(CLANG) -xc++ -Wno-ignored-attributes $(BITCODE_CXXFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c endif %.bc : %.c $(COMPILE.c.bc) -o $@ $< %.bc : %.cpp $(COMPILE.cxx.bc) -o $@ $< However, there seems to be no way to override BITCODE_CXXFLAGS to include any specific C++ compilation flags that are also required to build object files from cpp. Same applies to .bc derived from .c files with BITCODE_CFLAGS respectively. I am wondering if we could define something like PG_BITCODE_CXXFLAGS and PG_BITCODE_CFLAGS in pgxs.mk to be able to override those. If this sound like a right strategy, I’ll prepare a patch. Cheers, Oleksii “Alex” Kluukin
cxxflags_shared_libraries_pg10.diff
Description: Binary data