summaryrefslogtreecommitdiff
path: root/src/makefiles
diff options
context:
space:
mode:
authorAndres Freund2022-07-18 00:49:51 +0000
committerAndres Freund2022-07-18 00:49:51 +0000
commit089480c077056fc20fa8d8f5a3032a9dcf5ed812 (patch)
treee5b2ad0c9a66073ea08306e5539e0f3b4df159ba /src/makefiles
parentfd4bad1655391582f639527c325fc4a99680cc64 (diff)
Default to hidden visibility for extension libraries where possible
Until now postgres built extension libraries with global visibility, i.e. exporting all symbols. On the one platform where that behavior is not natively available, namely windows, we emulate it by analyzing the input files to the shared library and exporting all the symbols therein. Not exporting all symbols is actually desirable, as it can improve loading speed, reduces the likelihood of symbol conflicts and can improve intra extension library function call performance. It also makes the non-windows builds more similar to windows builds. Additionally, with meson implementing the export-all-symbols behavior for windows, turns out to be more verbose than desirable. This patch adds support for hiding symbols by default and, to counteract that, explicit symbol visibility annotation for compilers that support __attribute__((visibility("default"))) and -fvisibility=hidden. That is expected to be most, if not all, compilers except msvc (for which we already support explicit symbol export annotations). Now that extension library symbols are explicitly exported, we don't need to export all symbols on windows anymore, hence remove that behavior from src/tools/msvc. The supporting code can't be removed, as we still need to export all symbols from the main postgres binary. Author: Andres Freund <[email protected]> Author: Tom Lane <[email protected]> Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/makefiles')
-rw-r--r--src/makefiles/pgxs.mk5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 0f71fa293d0..7ba8d5bc980 100644
--- a/src/makefiles/pgxs.mk
+++ b/src/makefiles/pgxs.mk
@@ -101,8 +101,11 @@ endif # PGXS
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
+# See equivalent block in Makefile.shlib
ifdef MODULES
-override CFLAGS += $(CFLAGS_SL)
+override LDFLAGS_SL += $(CFLAGS_SL_MODULE)
+override CFLAGS += $(CFLAGS_SL) $(CFLAGS_SL_MODULE)
+override CXXFLAGS += $(CFLAGS_SL) $(CXXFLAGS_SL_MODULE)
endif
ifdef MODULEDIR