[glib/wip/visibility2] configure.ac: change our visibility policy



commit e270596cdbb7092ca872f51d0e4596c3fa464572
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Dec 6 13:42:06 2012 -0500

    configure.ac: change our visibility policy
    
    Check for -fvisibility=hidden as a supported CFLAG.
    
    If it is supported, use it and emit an AC_DEFINE to change the meaning
    of _GLIB_EXTERN to include the GNU attribute for marking symbols as
    public: __attribute((visibility("default"))).
    
    This will override the public definition of _GLIB_EXTERN for any file
    which does #include "config.h" (forcing all our .c files to do so, as a
    side effect).
    
    It's possible that there may be compilers that accept
    -fvisibility=hidden but don't accept the GNU attribute for making
    symbols public again -- we will hopefully receive bugs if any of those
    exist.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688681

 configure.ac |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5cb21df..fcbbfbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3566,6 +3566,27 @@ fi
 
 AC_SUBST(GLIB_LINK_FLAGS)
 
+
+dnl
+dnl Check for -fvisibility=hidden to determine if we can do GNU-style
+dnl visibility attributes for symbol export control
+dnl
+SAVED_CFLAGS="${CFLAGS}"
+CFLAGS="-fvisibility=hidden"
+AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
+AC_TRY_COMPILE([], [int main (void) { return 0; }],
+               AC_MSG_RESULT(yes)
+               enable_fvisibility_hidden=yes,
+               AC_MSG_RESULT(no)
+               enable_fvisibility_hidden=no)
+CFLAGS="${SAVED_CFLAGS}"
+
+AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
+  AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) extern],
+            [defines how to decorate public symbols while building])
+  CFLAGS="${CFLAGS} -fvisibility=hidden"
+])
+
 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]