summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-08-18 13:06:36 +0200
committerMark Wielaard <mark@klomp.org>2017-08-18 22:32:44 +0200
commit1127470a3ebf507981af5d2864bfe57ee67e868a (patch)
treeddc7c4eb260bdb5cc677d7af958618f5a779d0ae /configure.ac
parent07737584e73714eff3481fcf17f9f0331c8a5b88 (diff)
Check if gcc complains about __attribute__ (visibility(..))
If so, define attribute_hidden to be empty. Also, use attribute_hidden in all places where we hide symbols. If this attribute is missing, it simply means that we cannot hide private symbols in the binary using attributes. This disables some optimizations and may increase the risk of symbol name clashes with other libraries, but is not fatal. However, we still employ linker version scripts to explicitly define the exported symbols. This serves much of the same purpose. Also, as all our symbols are prefixed with the library name, and "__" for private ones, the chance of clashes is low anyway. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac16
1 files changed, 16 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index e6e3b675..c4fc7e3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,6 +127,22 @@ CFLAGS="$old_CFLAGS"])
AS_IF([test "x$ac_cv_c99" != xyes],
AC_MSG_ERROR([gcc with GNU99 support required]))
+AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))],
+ ac_cv_visibility, [dnl
+save_CFLAGS="$CFLAGS"
+CFLAGS="$save_CFLAGS -Werror"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
+int __attribute__((visibility("hidden")))
+foo (int a)
+{
+ return a;
+}])], ac_cv_visibility=yes, ac_cv_visibility=no)
+CFLAGS="$save_CFLAGS"])
+if test "$ac_cv_visibility" = "yes"; then
+ AC_DEFINE([HAVE_VISIBILITY], [1],
+ [Defined if __attribute__((visibility())) is supported])
+fi
+
AC_CACHE_CHECK([whether gcc supports -fPIC], ac_cv_fpic, [dnl
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -fPIC -Werror"