summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2022-09-09 22:53:02 -0700
committerAndres Freund <andres@anarazel.de>2022-09-09 22:53:02 -0700
commitbe7c15b194ab91d28904a0e656f3f6600883ab68 (patch)
tree10791e772bfb66db590999550100924bbd82fcb3 /configure.ac
parentfe6a64a58ab3e5bda3aceee2f1ee3e8efdb03865 (diff)
downloadpostgresql-be7c15b194ab91d28904a0e656f3f6600883ab68.tar.gz
configure: Expand -fvisibility checks to more compilers, test for -qvisibility
It looks like icc and sunpro both support -fvisibility=hidden and xlc supports -qvisibility=hidden. I tested this on AIX and solaris with their proprietary compilers as well as gcc, and with gcc or clang on freebsd, linux, macos, netbsd and openbsd. Apparently my prior commit fe6a64a58ab only works in combination with this patch. While I tried to test them separately, an unknown caching issue prevented me from noticing the problem. Per discussion with Tom Lane and buildfarm member hoverfly. Discussion: https://postgr.es/m/20220910052741.t7w7csyrggwus2ze%40awork3.anarazel.de Discussion: https://postgr.es/m/20220820174213.d574qde4ptwdzoqz@awork3.anarazel.de
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac39
1 files changed, 28 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac
index 993b5d5cb0..7792ae5bad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -525,17 +525,6 @@ if test "$GCC" = yes -a "$ICC" = no; then
# Optimization flags for specific files that benefit from vectorization
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTORIZE, [-ftree-vectorize])
#
- # If the compiler knows how to hide symbols add the switch needed for that
- # to CFLAGS_SL_MODULE and define HAVE_VISIBILITY_ATTRIBUTE.
- PGAC_PROG_CC_VAR_OPT(CFLAGS_SL_MODULE, [-fvisibility=hidden])
- if test "$pgac_cv_prog_CC_cflags__fvisibility_hidden" = yes; then
- AC_DEFINE([HAVE_VISIBILITY_ATTRIBUTE], 1,
- [Define to 1 if your compiler knows the visibility("hidden") attribute.])
- fi
- # For C++ we additionally want -fvisibility-inlines-hidden
- PGAC_PROG_VARCXX_VARFLAGS_OPT(CXX, CXXFLAGS_SL_MODULE, [-fvisibility=hidden])
- PGAC_PROG_VARCXX_VARFLAGS_OPT(CXX, CXXFLAGS_SL_MODULE, [-fvisibility-inlines-hidden])
- #
# The following tests want to suppress various unhelpful warnings by adding
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
# switches, so we have to test for the positive form and if that works,
@@ -582,6 +571,34 @@ elif test "$PORTNAME" = "aix"; then
PGAC_PROG_CXX_CFLAGS_OPT([-qlonglong])
fi
+# If the compiler knows how to hide symbols, add the switch needed for that to
+# CFLAGS_SL_MODULE and define HAVE_VISIBILITY_ATTRIBUTE.
+#
+# This is done separately from the above because -fvisibility is supported by
+# quite a few different compilers, making the required repetition bothersome.
+#
+# We might need to add a separate test to check if
+# __attribute__((visibility("hidden"))) is supported, if we encounter a
+# compiler that supports one of the supported variants of -fvisibility=hidden
+# but uses a different syntax to mark a symbol as exported.
+if test "$GCC" = yes -o "$SUN_STUDIO_CC" = yes ; then
+ PGAC_PROG_CC_VAR_OPT(CFLAGS_SL_MODULE, [-fvisibility=hidden])
+ # For C++ we additionally want -fvisibility-inlines-hidden
+ PGAC_PROG_VARCXX_VARFLAGS_OPT(CXX, CXXFLAGS_SL_MODULE, [-fvisibility=hidden])
+ PGAC_PROG_VARCXX_VARFLAGS_OPT(CXX, CXXFLAGS_SL_MODULE, [-fvisibility-inlines-hidden])
+ have_visibility_attribute=$pgac_cv_prog_CC_cflags__fvisibility_hidden
+elif test "$PORTNAME" = "aix"; then
+ # Note that xlc accepts -fvisibility=hidden as a file.
+ PGAC_PROG_CC_VAR_OPT(CFLAGS_SL_MODULE, [-qvisibility=hidden])
+ PGAC_PROG_VARCXX_VARFLAGS_OPT(CXX, CXXFLAGS_SL_MODULE, [-qvisibility=hidden])
+ have_visibility_attribute=$pgac_cv_prog_CC_cflags__qvisibility_hidden
+fi
+
+if test "$have_visibility_attribute" = "yes"; then
+ AC_DEFINE([HAVE_VISIBILITY_ATTRIBUTE], 1,
+ [Define to 1 if your compiler knows the visibility("hidden") attribute.])
+fi
+
AC_SUBST(CFLAGS_UNROLL_LOOPS)
AC_SUBST(CFLAGS_VECTORIZE)
AC_SUBST(CFLAGS_SL_MODULE)