[clutter/clutter-1.18] New visibility handling in Clutter



commit 386be83f249f81bdb95bdccda473f8f1e9cad2c2
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Mar 17 18:45:56 2014 +0000

    New visibility handling in Clutter
    
    Instead of listing every public symbol inside an ancillary file, we can
    use compiler annotations. This scheme is also used by GLib and GTK+.
    
    The symbols file is left in tree until the Visual Studio rules are
    fixed, but it's not used any more during distcheck.
    
    I double-checked that the exposed ABI is the same before and after this
    change, except for symbols that were never meant to be public in the
    first place, and that escaped our attention when we generated the first
    version of the symbols file.

 clutter/Makefile.am |    2 +-
 configure.ac        |   30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/clutter/Makefile.am b/clutter/Makefile.am
index fbea892..7a67ea5 100644
--- a/clutter/Makefile.am
+++ b/clutter/Makefile.am
@@ -29,6 +29,7 @@ AM_CPPFLAGS = \
        $(CLUTTER_DEPRECATED_CFLAGS)            \
        $(CLUTTER_DEBUG_CFLAGS)                 \
        $(CLUTTER_PROFILE_CFLAGS)               \
+       $(CLUTTER_HIDDEN_VISIBILITY_CFLAGS)     \
        $(NULL)
 
 AM_CFLAGS = $(CLUTTER_CFLAGS) $(MAINTAINER_CFLAGS)
@@ -850,7 +851,6 @@ libclutter_ CLUTTER_API_VERSION@_la_LDFLAGS = \
        $(CLUTTER_LINK_FLAGS) \
        $(CLUTTER_LT_LDFLAGS) \
        -export-dynamic \
-       -export-symbols-regex "^(clutter|cally).*" \
        -rpath $(libdir) \
        $(win32_resources_ldflag) \
        $(NULL)
diff --git a/configure.ac b/configure.ac
index 94322b5..27e31c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,6 +193,36 @@ AC_ARG_ENABLE([Bsymbolic],
 AS_IF([test "x$enable_Bsymbolic" = "xyes"], [CLUTTER_LINK_FLAGS=-Wl[,]-Bsymbolic-functions])
 AC_SUBST(CLUTTER_LINK_FLAGS)
 
+# Check for the visibility flags
+CLUTTER_HIDDEN_VISIBILITY_CFLAGS=""
+case "$host" in
+  *-*-mingw*)
+    dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+    AC_DEFINE([_CLUTTER_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
+              [defines how to decorate public symbols while building])
+    CFLAGS="${CFLAGS} -fvisibility=hidden"
+    ;;
+  *)
+    dnl on other compilers, check if we can do -fvisibility=hidden
+    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([_CLUTTER_EXTERN], [__attribute__((visibility("default"))) extern],
+                [defines how to decorate public symbols while building])
+      CLUTTER_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
+    ])
+    ;;
+esac
+AC_SUBST(CLUTTER_HIDDEN_VISIBILITY_CFLAGS)
+
 AC_CACHE_SAVE
 
 dnl ========================================================================


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