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.
This commit is contained in:
Emmanuele Bassi 2014-03-17 18:45:56 +00:00
parent 5c4c2aa52f
commit 386be83f24
2 changed files with 31 additions and 1 deletions

View File

@ -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)

View File

@ -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 ========================================================================