[glib/wip/symbol-visibility: 5/6] Use -fvisibility=hidden by default



commit a9e9887d0cd55c0c9140094c0f118180c4368e3e
Author: Colin Walters <walters verbum org>
Date:   Wed Nov 28 16:22:48 2012 -0500

    Use -fvisibility=hidden by default
    
    Now that we have all symbols annotated as GLIB_PUBLIC, we can switch
    the build to default to hiding symbols.  The major advantage of this
    is that it's much harder to accidentally leak symbols.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688681

 configure.ac |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 548fa1c..43bc54c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -868,6 +868,12 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if defined(__SUNPRO_C) || (__SUNPRO_C >= 0
 AC_MSG_RESULT($g_have_sunstudio_visibility)
 AM_CONDITIONAL(HAVE_SUNSTUDIO_VISIBILITY, [test x$g_have_sunstudio_visibility = xyes])
 
+dnl See https://bugzilla.gnome.org/show_bug.cgi?id=688681
+dnl First half of symbol visibility; search for "Second half of symbol
+dnl visibility" below to find the second part.
+AS_IF([test x$g_have_gnuc_visibility = x && test x$g_have_sunstudio_visibility = x], [
+  AC_MSG_ERROR([GLib does not know how to control symbol visibility on this platform])])
+
 # check for bytesex stuff
 AC_C_BIGENDIAN
 if test x$ac_cv_c_bigendian = xuniversal ; then
@@ -3542,6 +3548,15 @@ fi
 
 AC_SUBST(GLIB_LINK_FLAGS)
 
+dnl See https://bugzilla.gnome.org/show_bug.cgi?id=688681
+dnl Second half of symbol visibility; search for "First half of symbol
+dnl visibility" above to find the first part.  They are separated for
+dnl the same reason the -Werror bits below are last - so we don't affect
+dnl any autoconf tests.
+AS_IF([test x$GCC = xyes], [CFLAGS="$CFLAGS -fvisibility=hidden"],
+      [test x$g_have_sunstudio_visibility != x], [CFLAGS="$CFLAGS -xldscope=hidden"],
+      [AC_MSG_ERROR([GLib does not know how to make symbols hidden by default with this compiler])])
+
 dnl Compiler flags; macro originates from systemd
 dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953
 CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]